我正在为我的网络使用3D卷积。在我的网络节点中,我需要将我的图像从[5,50,50,10,256]调整为[5,100,100,10,256]。我只想调整图像的轴1和轴2的大小。
我尝试使用tf.image.resize_images,但它似乎只适用于3D或4G张量。
任何建议我该怎么办?
答案 0 :(得分:4)
没问题,我们仍然可以使用tf.image.resize_images。我们需要做的是将数据以所需的形状发送到 tf.image.resize_images ,这是一个张量(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]