TensorFlow-ENet
TensorFlow-ENet copied to clipboard
Error with ScatterNd when running predict_segmentation.py
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!
Same problem when using a batch > 1 ...
Invalid indices: [43200,0] = [1, 90, 0, 0] does not index into [10,90,120,64]
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
Hi, where is the utilities.py file?
Can you try changing this line and see if it works?
https://github.com/kwotsin/TensorFlow-ENet/blob/master/enet.py#L101