-1

I have images in a tensor [batch, height, width, depth], I want to extract patches from every single batch, and every single depth by using ksize=5x5 and stride=1x1.

tf.extract_image_patches(images=images, ksizes=[1, 5, 5, 1], strides=[1, 1, 1, 1], rates=[1, 1, 1, 1], padding='same')

Now the problem is I get different outcome when the input tensor is different in depth, but I use the same image. Case 1: input tensor, a batch of images [4,28,28,1] produces output tensor [4,28,28,25].

Case2: input tensor, a batch of images, [4,28,28,8] produces output tensor [4,28,28,200].

Please note that the image in case 1 [0, :, :, :] is the same with case 2 [0, :, :, 0].

I supposed the value of output tensor of Case 1 [0, :, :, :] is the same with the value of Case 2 tensor [0, :, :, 0:25]. But I found out my assumption is wrong when I check the matrix by using case1 == case 2, which returns false.

Any idea how to do produce the same outcome as case 1 when the input tensor contains more than 1 depth without loop?

Soon
  • 1
  • 4

1 Answers1

0

Do not do case1 == case2; use tf.equal(case1, case2) instead to create an operation which, when run, will evaluate to whether they are equal or not.

Alexandre Passos
  • 5,186
  • 1
  • 14
  • 19