Tensorflow 2. 0 自动求梯度
Tensorflow 自动求梯度import tensorflow as tfimport timeita = tf.constant(1.)b = tf.constant(2.)c = tf.constant(3.)w = tf.constant(4.)with tf.GradientTape() as tape: tape.watch([w]) y = a * w **2 + b *w +c[dy_dw] = tape.gradient(y, [w])print
原创
2020-11-27 14:57:21 ·
167 阅读 ·
0 评论