如何使用张量流梯度带找到解析梯度
假设我们有一些函数 y=x^2
然后我们可以使用梯度带自动计算梯度(当我们向tensorflow提供一些x值时,
x = tf.Variable(3.0)
with tf.GradientTape() as tape:
y = x**2
dy_dx = tape.gradient(y, x)
我是否可以找出tensorflow对我的输入做了什么?例如在本例中是 容易找出 dy/dx=2x,这是否意味着张量流会将 2 乘以我的 x 输入值,然后返回 6(即 3*2)?
很 区分所以我想要从 TensorFlow 梯度带中找到见解,看看 TensorFlow 如何使用我的 x 输入计算出导数。
Suppose we have some function
y=x^2
We can then use gradient tape to automatically calculate the gradient for us (when we provide some values of x to tensorflow
x = tf.Variable(3.0)
with tf.GradientTape() as tape:
y = x**2
dy_dx = tape.gradient(y, x)
Is there anyway I can find out what did tensorflow do to my input? For example in this case it is easy to find out the dy/dx=2x, does that mean tensorflow will multiply 2 to my input value of x and then return me 6 (which is 3*2)?
I have a very complicated function which I don't know how to differentiate so I want to find insights from tensorflow gradienttape to see how tensorflow works out the derivative using my input of x.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种可能的选择是使用
tensorboard
并打印tf.Graph
的操作:在终端中打开tensorboard:
One possible option is using
tensorboard
and also printing the operations of thetf.Graph
:Open tensorboard in your terminal: