Reputation: 938
Suppose I have a tensor of varying height, i.e. shape [batch_size=32, height=None, width=25, n_channels=128]. I'd like to upsample this tensor with the conv2d_transpose
op, but I'm not sure how to generate the required output_shape
argument. With a known height, I'd do something like
def get_conv_transpose_shape(input, out_channels):
out_shape = input.get_shape().as_list()
out_shape[1] *= 2
out_shape[2] *= 2
out_shape[3] = out_channels
return out_shape
But when height=None, this produces the following error
TypeError: unsupported operand type(s) for *= 'NoneType' and 'int'
Is there a solution to this other than zero-padding all of my inputs to a standard size? That's a computation cost I'd like to avoid.
Upvotes: 0
Views: 288
Reputation: 7063
When you call .get_shape().as_list()
, you end up in "static python land" trying to multiply a None
with an int
.
The operation should be carried in the symbolic domain, that is multiplying tensorflow.get_shape(input)
with another symbolic variable of type int
.
Upvotes: 1