1

我想在 tf.learn 中尝试一些二阶优化,但我不知道怎么做。提前致谢!

4

1 回答 1

0

使用较旧的 TensorFlow(将其与您的问题联系起来):

import tensorflow as tf
vector = tf.Variable([7., 7.], 'vector')
# Make vector norm as small as possible.
loss = tf.reduce_sum(tf.square(vector))

optimizer = tf.contrib.opt.ScipyOptimizerInterface(
    loss, options={'maxiter': 100})

with tf.Session() as session:
    session.run(tf.global_variables_initializer())
    print(session.run(vector))  # results: [7.0, 7.0]
    optimizer.minimize(session)
    print(session.run(vector))  # results: [ -1.88996808e-06  -1.88996808e-06]
于 2020-06-26T19:34:03.587 回答