1

My frozen graph in tensorflow is throwing an error if I use a different image resolution than the one used for training at the "tf.reshape" command.

My network is fully convolutional and before having to use the tf.reshape command I was able to use different resolution input images in my code.

Now I have a function in my code that reshapes the tensor (it just does a shuffle like in Shufflenet2) and this is throwing an error now. I have tried getting the shape dynamically using tf.shape and its still not working.

def channel_shuffle( x, num_groups=2,name='channelshuf',reuse=False):
    with tf.variable_scope(name+'shuffle', reuse=reuse):
        #n, h, w, c = x.shape.as_list()
        n, h, w, c =  tf.shape(x)[0],tf.shape(x)[1],tf.shape(x)[2],tf.shape(x)[3]
        x_reshaped = tf.reshape(x, [n, h, w, num_groups, c // num_groups])
        x_transposed = tf.transpose(x_reshaped, [0, 1, 2, 4, 3])
        output = tf.reshape(x_transposed, [n, h, w, c])
        return output

The error I am getting is this:

InvalidArgumentError (see above for traceback): Input to reshape is a tensor with 3340800 values, but the requested shape has 835200

thank you!

IMParasharG
  • 1,869
  • 1
  • 15
  • 26
JohnVS
  • 113
  • 1
  • 6

0 Answers0