Relation-Classification-using-Bidirectional-LSTM-Tree icon indicating copy to clipboard operation
Relation-Classification-using-Bidirectional-LSTM-Tree copied to clipboard

Invalid Argument Error

Open arunzz opened this issue 6 years ago • 18 comments

Hi Shanu

I tried Model3v1 for 10 samples. Accordingly I generated train_paths and when i run, I get the below error. PLease let know. I have attached the source file too - model3v1.txt

File "", line 1, in [elided 1 identical lines from previous traceback] File "/usr/lib/python2.7/idlelib/run.py", line 324, in runcode exec code in self.locals File "/home/arunkumar/Downloads/Relation-Classification-master/model3v1.py", line 422, in s_seq.get_shape(), tf.TensorShape([None, 100])]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 3096, in while_loop result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 2874, in BuildLoop pred, body, original_loop_vars, loop_vars, shape_invariants) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 2814, in _BuildLoop body_result = body(*packed_vars_for_body) File "/home/arunkumar/Downloads/Relation-Classification-master/model3v1.py", line 415, in matmul_hl temp = tf.tanh(tf.matmul(input_seq[j], W) + b) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 588, in _slice_helper name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 754, in strided_slice shrink_axis_mask=shrink_axis_mask) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 5397, in strided_slice name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3271, in create_op op_def=op_def)

InvalidArgumentError (see above for traceback): slice index 1 of dimension 0 out of bounds. [[Node: gradients_1/hidden_layer_seq/while_3/strided_slice_grad/StridedSliceGrad = StridedSliceGrad[Index=DT_INT32, T=DT_FLOAT, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](gradients_1/hidden_layer_seq/while_3/strided_slice_grad/StridedSliceGrad/StackPopV2, gradients_1/hidden_layer_seq/while_3/strided_slice_grad/StridedSliceGrad/StackPopV2_1, gradients_1/hidden_layer_seq/while_3/strided_slice_grad/StridedSliceGrad/StackPopV2_2, gradients_1/hidden_layer_seq/while_3/strided_slice_grad/StridedSliceGrad/Const_3, gradients_1/hidden_layer_seq/while_3/MatMul_grad/tuple/control_dependency)]]

arunzz avatar Apr 24 '18 09:04 arunzz

Exact error and the code line InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'input/sp_childs' with dtype int32 and shape [5,2,20,20]

For complete model training ---> 29 _, _loss, step, _summary = sess.run([train_op, total_loss, global_step_dep, summary], feed_dict)

arunzz avatar Apr 24 '18 09:04 arunzz

first check whether [[childs_path1[k], childs_path2[k]] for k in range(s, end)] has the same dimension as [5, 2, 20, 20] and also the data type

Sshanu avatar Apr 24 '18 17:04 Sshanu

Thank you Shanu for the response. I tried for a small sample as it was slow. But now i tried with all 8000 and am running them in python2 All pickles are written with python2

Now I get this error. InvalidArgumentError (see above for traceback): Inputs to operation gradients_1/AddN_1101 of type AddN must have the same size and shape. Input 0: [2,20,1,100] != input 1: [2,1,1,100 This is in model3v2, this line of code For complete model training _, _loss, step, _summary = sess.run([train_op, total_loss, global_step_dep, summary], feed_dict)

Kindly help

arunzz avatar Apr 25 '18 11:04 arunzz

please try using python 3.

Just use printing the shapes of this tensors, then debug the code

Sshanu avatar Apr 25 '18 13:04 Sshanu

Hey shanu, why should there be a change in dimensions of the tensors, if i am using the same data as yours @arunzz were you able to solve the problem?

NeverInAsh avatar Jun 15 '18 05:06 NeverInAsh

Can you please post the error or for which tensors dimension problem is occurring?

Sshanu avatar Jun 15 '18 06:06 Sshanu

Yes Use python 3 It worked. No changes to any dimensions. But the label encoding also has to be passed into relation encoder. That part is missing i think

On Jun 15, 2018, at 11:33 AM, Shanu Kumar [email protected] wrote:

Can you please post the error or for which tensors dimension problem is occurring?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

arunzz avatar Jun 15 '18 07:06 arunzz

@arunzz can you share some more insights, actually i am currently learning about it meanwhile i am working on this. It will be a great help. or maybe you can share your version.

NeverInAsh avatar Jun 15 '18 09:06 NeverInAsh

Hi

Shanu is our guru :) He wrote the entire thing.

Regards Arun

On Fri, Jun 15, 2018 at 2:51 PM, NeverInAsh [email protected] wrote:

@arunzz https://github.com/arunzz can you share some more insights, actually i am currently learning about it meanwhile i am working on this. It will be a great help. or maybe you can share your version.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Sshanu/Relation-Classification/issues/9#issuecomment-397564692, or mute the thread https://github.com/notifications/unsubscribe-auth/AUJLxe8vgjyeDesR7_i7C6nubFghBQFSks5t83ySgaJpZM4ThR3G .

arunzz avatar Jun 18 '18 05:06 arunzz

It worked, thanks shanu :)

NeverInAsh avatar Jun 18 '18 05:06 NeverInAsh

@arunzz @NeverInAsh I'm wondering what you guys did to fix the error? I am running python 3

ProxyCausal avatar Jul 02 '18 14:07 ProxyCausal

Just python3 Initialize global variables after loading glove embeddings.

On Jul 2, 2018, at 7:59 PM, enmatics [email protected] wrote:

@arunzz @NeverInAsh I'm wondering what you guys did to fix the error? I am running python 3

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

arunzz avatar Jul 02 '18 16:07 arunzz

@arunzz I have meet the same problem. I am running python 3, but the problem still exist. Can you attached the worked model3v2 source file?

zy158 avatar May 14 '19 10:05 zy158

model3v2.py.zip

arunzz avatar May 14 '19 11:05 arunzz

@arunzz which version of tensorlfow and python you use?

zy158 avatar May 14 '19 15:05 zy158

@arunzz when I don't init glove embedding in your source file, it will exist the error: InvalidArgumentError (see above for traceback): slice index 1 of dimension 0 out of bounds. [[Node: gradients_1/hidden_layer_seq/while_3/strided_slice_grad/StridedSliceGrad = StridedSliceGrad[Index=DT_INT32, T=DT_FLOAT, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=1, _device="/job:localhost/replica:0/task:0/device:CPU:0"]

when I init glove embedding, it will exist the error: InvalidArgumentError (see above for traceback): Inputs to operation gradients_1/AddN_1101 of type AddN must have the same size and shape. Input 0: [2,20,1,100] != input 1: [2,1,1,100]

zy158 avatar May 15 '19 03:05 zy158

@arunzz When I use tensorflow 1.12.0, it will lead "ArithmeticOptimize" error. Then I replaced the version of tensorflow 1.8.0. and worked. But it will occur "concat" error and "hidden_layer" error. Then I replaced the version of tensorflow 1.10.0. Your source file finally worked.

zy158 avatar May 16 '19 05:05 zy158

@arunzz in model3v2 model = tf.train.latest_checkpoint(model_dir) saver.restore(sess, model) when I try to restore the error says 👎 ValueError: Can't load save_path when it is None. Please help

radhikagupta6 avatar Dec 13 '19 06:12 radhikagupta6