lc222/attention-over-attention-tf-QA

TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

Opened this issue · 2 comments

/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py:110: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
"Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Traceback (most recent call last):
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2409, in get_attr
c_api.TF_OperationGetAttrValueProto(self._c_op, name, buf)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Operation 'UnsortedSegmentSum' has no attr named '_XlaCompile'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py", line 415, in _MaybeCompile
xla_compile = op.get_attr("_XlaCompile")
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2413, in get_attr
raise ValueError(str(e))
ValueError: Operation 'UnsortedSegmentSum' has no attr named '_XlaCompile'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/summer-sun/Desktop/new_paper/attention-over-attention/model.py", line 205, in
main()
File "/Users/summer-sun/Desktop/new_paper/attention-over-attention/model.py", line 146, in main
loss, train_op, global_step, accuracy = train(y_hat, reg, document_batch, document_weights, answer_batch)
File "/Users/summer-sun/Desktop/new_paper/attention-over-attention/model.py", line 132, in train
grads_and_vars = optimizer.compute_gradients(loss)
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 512, in compute_gradients
colocate_gradients_with_ops=colocate_gradients_with_ops)
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py", line 664, in gradients
unconnected_gradients)
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py", line 965, in _GradientsHelper
lambda: grad_fn(op, *out_grads))
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py", line 420, in _MaybeCompile
return grad_fn() # Exit early
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gradients_impl.py", line 965, in
lambda: grad_fn(op, *out_grads))
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/math_grad.py", line 328, in _UnsortedSegmentSumGrad
return _GatherDropNegatives(grad, op.inputs[1])[0], None, None
File "/Users/summer-sun/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/math_grad.py", line 296, in _GatherDropNegatives
for _ in range(gathered.shape.ndims - is_positive.shape.ndims):
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

I meet this issue too.Have you fixed this problem?

OK! Let me solve this problem.
I spent many days to find the solution. And the problem is on the environment. When I change tensorflow=1.14 to tensorflow=1.0 this code could run successfully!