score:2
Accepted answer
Another alternative, if you know the size of the first dimension is 1, you can do:
tf.reshape(image, tf.shape(image)[1:])
As has been stated, though, tf.squeeze
seems to be the straightforward solution in your case.
score:2
You can use image[0]
to select the first "row" of the image. If image
is shape [1, w, h, c]
this will return a [w, h, c]
tensor. Although I don't understand what the issue with tf.squeeze
is. squeeze(image, axis=0)
does the same thing and protects against cases where other axes (e.g. the channel axis) are also size 1.
Credit To: stackoverflow.com