我想在tf.learn中尝试一些二阶优化,但我无法弄清楚如何。提前谢谢!
答案 0 :(得分: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]