I am using 3D convolution for my network. In a node of my network I need to resize my image from [5,50,50,10,256]
to [5,100,100,10,256]
. I just want to resize axis 1 and axis 2 of my image.
I tried to use tf.image.resize_images, but it seems it is only working on 3D or4D tensors.
Any suggestion what can I do?
No problem, we can still use tf.image.resize_images. What we need to do is send the data to tf.image.resize_images in the shape that it needs which is a tensor (4D).
# First reorder your dimensions to place them where tf.image.resize_images needs them
transposed = tf.transpose( yourData, [0,3,1,2,4] )
# it is now [5,10,50,50,256]
# but we need it to be 4 dimensions, not 5
reshaped = tf.reshape( transposed, [5*10,50,50,256] )
# and finally we use tf.image.resize_images
new_size = tf.constant( [ 100 , 100 ] )
resized = tf.image.resize_images( reshaped , new_size )
# your data is now [5*10,100,100,256]
undo_reshape = tf.reshape( resized, [5,10,100,100,256] )
# it is now [5,10,100,100,256] so lastly we need to reorder it
undo_transpose = tf.transpose( undo_reshape, [0,2,3,1,4] )
# your output is now [5,100,100,10,256]