标签: tensorflow2.0
在tensorflow 2.0中进行基本优化:
import tensorflow as tf import numpy as np x = tf.constant(3.0) with tf.GradientTape() as t: t.watch(x) y = (x - 10) ** 2 opt = tf.optimizers.Adam() opt.minimize(lambda: y, var_list=[x])