I would like to use this function in Tensorflow loss function:
def rectified_projection(self, disp_x, image):
H, W, B = self.HEIGHT, self.WIDTH, self.batch_size
disp_x = tf.cast(disp_x, tf.int32)
disp_x = self.bias_x + disp_x
disp = tf.concat([self.disp_y, disp_x], 3)
disp = tf.clip_by_value(disp, 0, W)
sdisp = tf.scatter_nd(disp, image, (B, H, W, 3), name="SCATTER")
return sdisp
This code moves pixels of image
in row by the value of disp_x
which is output from layer.
The problem is when I want to traing my network with this transformation. Tensorflow outputs that dont know how to propagate gradients through the network.. How can it be fixed?
EDIT:
Complete Error message:
ValueError:
No gradients provided for any variable,
check your graph for ops that do not support gradients,
between variables "last_layer" "loss_function"