【发布时间】:2019-07-08 15:14:18
【问题描述】:
我在损失函数中使用了 tf.conbrib.image.rotate,出现错误:
No gradients provided for any variable, check your graph for ops that do not support gradients,
我的代码是:
import tensorflow as tf
image_tensor = tf.placeholder(dtype=tf.float32, shape=[None,320,320,1])
target_tensor = tf.placeholder(dtype=tf.float32, shape=[None,320,320,1])
s = tf.concat([image_tensor, target_tensor],axis=3)
s = tf.layers.flatten(s)
w = tf.get_variable(initializer=tf.truncated_normal([204800,1], stddev=0.1),name='w')
b = tf.get_variable(initializer=tf.truncated_normal([1], stddev=0.1),name='b')
a = tf.matmul(s,w)+b
diff = tf.contrib.image.rotate(image_tensor, a[:,0], interpolation='BILINEAR') - target_tensor
loss = tf.reduce_sum(tf.square(diff))
optimizer = tf.train.GradientDescentOptimizer(0.001)
train = optimizer.minimize(loss)
我的tensorflow是:1.4.0,我的电脑是Win10。
顺便问一下,如何在 tensorflow 中旋转 3D 图像? tf.conbrib.image.rotate 仅适用于 2D 图像。
【问题讨论】:
标签: tensorflow rotation loss