我有一个问题,如何在TensorFlow中使用2x2内核获得梯度。
I’m studying KIND[1] and KIND++[2] paper. In this paper, they get gradient by using kernel_x and kernel_y and their shape is 2x2. In code, as follow :
kernel_x = tf.reshape(tf.constant([[0, 0], [-1, 1]], tf.float32), [2, 2, 1, 1])
kernel_y = tf.transpose(kernel_x, [1, 0, 2, 3])
gradient_orig = tf.abs(tf.nn.conv2d(input_tensor, kernel, strides=[1, 1, 1, 1], padding= SAME ))
In my knowledge, usual 2x2 derivative filter is Roberts cross as follow. Roberts cross
I use Pytorch, so I can’t understand the Tensorflow’s kernel shape exactly.
Is it same kernel or not? It seems [0,0],[-1,1] in code but Roberts cross has [1,0],[0,-1].
Please give me some information. Thanks.
[1] Y. Zhang et al. Kindling the Darkness: a Practical Low-light Image Enhancer. ACMMM 2019
[2] Y. Zhang et al. Beyond Brightening Low-light Images. IJCV 2021
我只是在查看Tensorflow文档,但是文档中的内核形状和代码中似乎不同。