timctho/shufflenet-v2-tensorflow

Forward pass Implementation

dhingratul opened this issue · 2 comments

@timctho I am trying to run the output node created in sess.run to pass it data, i get the following error
Caused by op u'shuffle_block_0/shuffle_v2_block/shuffle_unit/transpose', defined at:
File "main.py", line 12, in
model = ShuffleNetV2(input, 1001, model_scale=1.0, is_training=True)
File "/home/dhingratul/OneDrive/Projects/shufflenet-v2-tensorflow/net.py", line 15, in init
self._build_model()
File "/home/dhingratul/OneDrive/Projects/shufflenet-v2-tensorflow/net.py", line 40, in _build_model
out = shufflenet_v2_block(out, out_channel, 3, 2, shuffle_group=self.shuffle_group)
File "/home/dhingratul/OneDrive/Projects/shufflenet-v2-tensorflow/module.py", line 101, in shufflenet_v2_block
out = shuffle_unit(out, shuffle_group)
File "/home/dhingratul/OneDrive/Projects/shufflenet-v2-tensorflow/module.py", line 10, in shuffle_unit
x = tf.transpose(x, tf.convert_to_tensor([tf.shape(x)[0], 1, 2, 4, 3]))
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1484, in transpose
ret = transpose_fn(a, perm, name=name)
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 8552, in transpose
"Transpose", x=x, perm=perm, name=name)
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op
op_def=op_def)
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1718, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
InvalidArgumentError (see above for traceback): 0 is missing from {1,1,2,4,3}.

You should change line 10 in module.py to " x = tf.transpose(x, tf.convert_to_tensor([0, 1, 2, 4, 3])), and the network goes well.

@timctho I am trying to run the output node created in sess.run to pass it data, i get the following error
Caused by op u'shuffle_block_0/shuffle_v2_block/shuffle_unit/transpose', defined at:
File "main.py", line 12, in
model = ShuffleNetV2(input, 1001, model_scale=1.0, is_training=True)
File "/home/dhingratul/OneDrive/Projects/shufflenet-v2-tensorflow/net.py", line 15, in init
self._build_model()
File "/home/dhingratul/OneDrive/Projects/shufflenet-v2-tensorflow/net.py", line 40, in _build_model
out = shufflenet_v2_block(out, out_channel, 3, 2, shuffle_group=self.shuffle_group)
File "/home/dhingratul/OneDrive/Projects/shufflenet-v2-tensorflow/module.py", line 101, in shufflenet_v2_block
out = shuffle_unit(out, shuffle_group)
File "/home/dhingratul/OneDrive/Projects/shufflenet-v2-tensorflow/module.py", line 10, in shuffle_unit
x = tf.transpose(x, tf.convert_to_tensor([tf.shape(x)[0], 1, 2, 4, 3]))
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1484, in transpose
ret = transpose_fn(a, perm, name=name)
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 8552, in transpose
"Transpose", x=x, perm=perm, name=name)
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op
op_def=op_def)
File "/home/dhingratul/.virtualenvs/shufflenet-v2-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1718, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
InvalidArgumentError (see above for traceback): 0 is missing from {1,1,2,4,3}.

You should change line 10 in module.py to " x = tf.transpose(x, tf.convert_to_tensor([0, 1, 2, 4, 3])), and the network goes well.