我正在为我的网络使用 3D 卷积。在我的网络节点中,我需要将我的图像从 [5,50,50,10,256] 调整为 [5,100,100,10,256]。我只想调整图像的轴 1 和轴 2 的大小。
我尝试使用 tf.image.resize_images , 但它似乎只适用于 3D 或 4D 张量。
有什么建议我可以做什么?
请您参考如下方法:
没问题,我们仍然可以使用 tf.image.resize_images。我们需要做的是以张量 (4D) 所需的形状将数据发送到 tf.image.resize_images。
# 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]
