Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase shift concatenation fails with --scale 1 #11

Open
rzumer opened this issue Nov 27, 2018 · 1 comment
Open

Phase shift concatenation fails with --scale 1 #11

rzumer opened this issue Nov 27, 2018 · 1 comment

Comments

@rzumer
Copy link

rzumer commented Nov 27, 2018

I am trying to adapt the network for other applications than super-resolution, using --scale 1. However, in model._phase_shift(), I get the following error, on the concatenation:

  File "main.py", line 53, in <module>
    tf.app.run()
  File "/home/rzumer/dev/tensorflow/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "main.py", line 45, in main
    rdn.train(FLAGS)
  File "/home/rzumer/dev/RDN-TensorFlow/model.py", line 278, in train
    self.build_model(images_shape, labels_shape)
  File "/home/rzumer/dev/RDN-TensorFlow/model.py", line 190, in build_model
    self.pred = self.model()
  File "/home/rzumer/dev/RDN-TensorFlow/model.py", line 233, in model
    FU = self.UPN(FDF)
  File "/home/rzumer/dev/RDN-TensorFlow/model.py", line 202, in UPN
    x = self.PS(x, self.scale)
  File "/home/rzumer/dev/RDN-TensorFlow/model.py", line 265, in PS
    X = tf.concat([self._phase_shift(x, r) for x in Xc], 3) # Do the concat RGB
  File "/home/rzumer/dev/RDN-TensorFlow/model.py", line 265, in <listcomp>
    X = tf.concat([self._phase_shift(x, r) for x in Xc], 3) # Do the concat RGB
  File "/home/rzumer/dev/RDN-TensorFlow/model.py", line 246, in _phase_shift
    X = tf.concat([tf.squeeze(x) for x in X], 2)  # bsize, b, a*r, r
  File "/home/rzumer/dev/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1124, in concat
    return gen_array_ops.concat_v2(values=values, axis=axis, name=name)
  File "/home/rzumer/dev/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1033, in concat_v2
    "ConcatV2", values=values, axis=axis, name=name)
  File "/home/rzumer/dev/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/rzumer/dev/tensorflow/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/home/rzumer/dev/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
    op_def=op_def)
  File "/home/rzumer/dev/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1792, in __init__
    control_input_ops)
  File "/home/rzumer/dev/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1631, in _create_c_op
    raise ValueError(str(e))
ValueError: Shape must be at least rank 3 but is rank 2 for 'concat_16' (op: 'ConcatV2') with input shapes: [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [64,32], [] and with computed input tensors: input[32] = <2>.

From my research it seems to be due to attempting to concatenate over a non-existent dimension. However, I am not familiar enough with TensorFlow, RDN, or your implementation to debug this and could not find a reference to phase shifting in the original paper and implementation of RDN, so if --scale 1 is a special case that must be handled separately, please advise on how to make the necessary changes.

I confirmed that --scale 3 works correctly in my environment and restarted from the preprocessing phase to ensure that my data is correct.

@hengchuan
Copy link
Owner

@rzumer The phase shifting function is a third implement of the pixel shuffle layer in ESPCN. Theoretically it does not change the tensor if scale=1. You could try commenting out the x = self.PS(x, self.scale).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants