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

Error with ScatterNd when running predict_segmentation.py #32

Open
bnurbekov opened this issue Oct 28, 2018 · 4 comments
Open

Error with ScatterNd when running predict_segmentation.py #32

bnurbekov opened this issue Oct 28, 2018 · 4 comments

Comments

@bnurbekov
Copy link

Hi, thanks so much for the great work! I am getting the following error when running predict_segmentation.py:

Traceback (most recent call last):
  File "predict_segmentation.py", line 107, in <module>
    segmentations = sess.run(predictions)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/client/session.py", line 887, in run
    run_metadata_ptr)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/client/session.py", line 1110, in _run
    feed_dict_tensor, options, run_metadata)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/client/session.py", line 1286, in _do_run
    run_metadata)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/client/session.py", line 1308, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[172800] = [1, 91, 1, 0] does not index into shape [10,90,120,64]
	 [[{{node ENet/unpool/ScatterNd}} = ScatterNd[T=DT_FLOAT, Tindices=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ENet/unpool/transpose, ENet/unpool/Reshape_2, ENet/unpool/ScatterNd/shape)]]

Caused by op u'ENet/unpool/ScatterNd', defined at:
  File "predict_segmentation.py", line 91, in <module>
    skip_connections=skip_connections)
  File "/Users/bnurbekov/Downloads/projects/TensorFlow-ENet/enet.py", line 464, in ENet
    pooling_indices=pooling_indices_2, output_shape=inputs_shape_2, scope=bottleneck_scope_name+'_0')
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 182, in func_with_args
    return func(*args, **current_args)
  File "/Users/bnurbekov/Downloads/projects/TensorFlow-ENet/enet.py", line 321, in bottleneck
    net_unpool = unpool(net_unpool, pooling_indices, output_shape=output_shape, scope='unpool')
  File "/Users/bnurbekov/Downloads/projects/TensorFlow-ENet/enet.py", line 110, in unpool
    ret = tf.scatter_nd(indices, values, output_shape)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/ops/gen_array_ops.py", line 6891, in scatter_nd
    "ScatterNd", indices=indices, updates=updates, shape=shape, name=name)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/framework/ops.py", line 3272, in create_op
    op_def=op_def)
  File "/Users/bnurbekov/Library/Python/2.7/lib/python/site-packages/tensorflow/python/framework/ops.py", line 1768, in __init__
    self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): indices[172800] = [1, 91, 1, 0] does not index into shape [10,90,120,64]
	 [[{{node ENet/unpool/ScatterNd}} = ScatterNd[T=DT_FLOAT, Tindices=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ENet/unpool/transpose, ENet/unpool/Reshape_2, ENet/unpool/ScatterNd/shape)]]

Have you encountered it before by any chance? Any help will be greatly appreciated!

@kmonachopoulos
Copy link

kmonachopoulos commented Nov 3, 2018

Same problem when using a batch > 1 ...

Invalid indices: [43200,0] = [1, 90, 0, 0] does not index into [10,90,120,64]

@benbenlijie
Copy link

try modify the utilities.py
line 51:
from:
y = pooling_indices//(output_shape[2]*output_shape[3])
to
y = pooling_indices//(output_shape[2]*output_shape[3]) % output_shape[1]

The indices in argmax are flattened, so that a maximum value at position [b, y, x, c] becomes flattened index ((b * height + y) * width + x) * channels + c.
check tensorflow.api

@Aakriti05
Copy link

Hi,
where is the utilities.py file?

@kmonachopoulos
Copy link

Can you try changing this line and see if it works?

https://github.com/kwotsin/TensorFlow-ENet/blob/master/enet.py#L101

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

4 participants