代码实现:
import tensorflow as tf
# 创建4个张量
a=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(dy_dw)
执行结果:
文章标签 tensorflow 代码实现 文章分类 后端开发
代码实现:
import tensorflow as tf
# 创建4个张量
a=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(dy_dw)
执行结果:
上一篇:Trie 树
在DNN中,每个隐藏层都可以学习
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M