我有一个张量流 UNet 风格的网络。目前我指定输入和目标图像如下:
self.inputTensors = tf.placeholder(tf.float32, [None, opt.inputHeight, opt.inputWidth, opt.inputChannels], name='inputTensors')
self.targetColors = tf.placeholder(tf.float32, [None, opt.inputHeight, opt.inputWidth, opt.outputChannels], name='targetColors')
但我希望它也能够对可变宽度和高度图像进行操作,即
self.inputTensors = tf.placeholder(tf.float32, [None, None, None, opt.inputChannels], name='inputTensors')
self.targetColors = tf.placeholder(tf.float32, [None, None, None, opt.outputChannels], name='targetColors')
并推断出中间层的宽度和高度。这对于我的池化层或跨步卷积层来说效果很好,但对于我使用 tf.image.resize_bilinear 的上采样层(尽管这个问题对于任何 tf.image.resize_images 都有效。)目前我的调整大小双线性代码如下所示:
def unpool2xBilinear(inputs, name = 'unpool2xBilinear'):
sh = inputs.get_shape().as_list()
newShape = (sh[1] * 2, sh[2] * 2)
return tf.image.resize_bilinear(inputs, newShape)
然而,这不能处理未知的输入形状,给出
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
有没有办法允许调整图像大小以接受与输入相关的尺寸?或者我是否必须为每个不同的输入图像大小构建一个全新的图表?