tgisaturday / Seq2CNN

Word Embedding Annealing Using Sequence-to-sequence Model
Apache License 2.0
16 stars 4 forks source link

InvalidArgumentError while running the code #3

Open Aivi001 opened 4 years ago

Aivi001 commented 4 years ago

Hi, I get the following error while running with yelp_review_polarity, I'm quite new to ML. Kindly look into the error and help me, thanks in advance! I'm using tensorflow: 1.13.1 and python 3.7

2020-02-18 19:43:36.158943: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at conv_ops.cc:437 : Invalid argument: Computed output size would be negative: -2 [input_size: 2, effective_filter_size: 5, stride: 1] Traceback (most recent call last): File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call return fn(*args) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: Computed output size would be negative: -47 [input_size: 0, effective_filter_size: 48, stride: 1] [[{{node textCNN/conv-maxpool-3/pool}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train.py", line 312, in train_cnn(sys.argv[1]) File "train.py", line 271, in train_cnn train_loss, train_seq_loss, train_cnn_loss,train_acc,examples = train_step(x_train_batch, y_train_batch,target_train_batch,t_train_batch,s_train_batch,seq_lambda) File "train.py", line 229, in trainstep summary, , logits, step, loss,seq_loss, cnn_loss, acc = sess.run([cnn.merged,train_op,cnn.training_logits, global_step, cnn.loss, cnn.seq_loss, cnn.cnn_loss, cnn.accuracy], feed_dict) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1152, in _run feed_dict_tensor, options, run_metadata) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run run_metadata) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Computed output size would be negative: -47 [input_size: 0, effective_filter_size: 48, stride: 1] [[node textCNN/conv-maxpool-3/pool (defined at /home/ice/fyp/Seq2CNN-master/seq2CNN/model.py:75) ]]

Caused by op 'textCNN/conv-maxpool-3/pool', defined at: File "train.py", line 312, in train_cnn(sys.argv[1]) File "train.py", line 187, in train_cnn embedding_size=params['embedding_dim'] File "/home/ice/fyp/Seq2CNN-master/seq2CNN/model.py", line 75, in init padding='VALID', name='pool') File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/nn_ops.py", line 2748, in max_pool name=name) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 5137, in max_pool data_format=data_format, name=name) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op op_def=op_def) File "/home/ice/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1801, in init self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Computed output size would be negative: -47 [input_size: 0, effective_filter_size: 48, stride: 1] [[node textCNN/conv-maxpool-3/pool (defined at /home/ice/fyp/Seq2CNN-master/seq2CNN/model.py:75) ]]

tgisaturday commented 4 years ago

First thing worth trying might be downgrading Tensorflow version. Since this repo is really outdated, version difference can cause serious problems. Around version 0.5.0 ~ 1.5.0 may be working but I recommend rewriting the code from the scratch.

Aivi001 commented 4 years ago

Thank you for reaching out regarding this, I just tried running it using tf 1.5.0 and python 3.5 and still got the following error:

2020-02-20 12:23:22.170039: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA 2020-02-20 12:23:25.707186: W tensorflow/core/framework/op_kernel.cc:1198] Invalid argument: computed output size would be negative 2020-02-20 12:23:25.707278: W tensorflow/core/framework/op_kernel.cc:1198] Invalid argument: computed output size would be negative 2020-02-20 12:23:25.707365: W tensorflow/core/framework/op_kernel.cc:1198] Invalid argument: computed output size would be negative Traceback (most recent call last): File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _do_call return fn(*args) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1329, in _run_fn status, run_metadata) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: computed output size would be negative [[Node: textCNN/conv-maxpool-5/conv = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](textCNN/BatchNorm/cond/Merge, textCNN/conv-maxpool-5/W/read)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train.py", line 312, in train_cnn(sys.argv[1]) File "train.py", line 271, in train_cnn train_loss, train_seq_loss, train_cnn_loss,train_acc,examples = train_step(x_train_batch, y_train_batch,target_train_batch,t_train_batch,s_train_batch,seq_lambda) File "train.py", line 229, in trainstep summary, , logits, step, loss,seq_loss, cnn_loss, acc = sess.run([cnn.merged,train_op,cnn.training_logits, global_step, cnn.loss, cnn.seq_loss, cnn.cnn_loss, cnn.accuracy], feed_dict) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 895, in run run_metadata_ptr) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1128, in _run feed_dict_tensor, options, run_metadata) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1344, in _do_run options, run_metadata) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1363, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: computed output size would be negative [[Node: textCNN/conv-maxpool-5/conv = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](textCNN/BatchNorm/cond/Merge, textCNN/conv-maxpool-5/W/read)]]

Caused by op 'textCNN/conv-maxpool-5/conv', defined at: File "train.py", line 312, in train_cnn(sys.argv[1]) File "train.py", line 187, in train_cnn embedding_size=params['embedding_dim'] File "/home/ice/fyp/Seq2CNN-master/seq2CNN/model.py", line 69, in init conv = tf.nn.conv2d(cnn_input, W, strides=[1, 1, 1, 1], padding='VALID', name='conv') File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 639, in conv2d data_format=data_format, dilations=dilations, name=name) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3160, in create_op op_def=op_def) File "/home/ice/anaconda3/envs/ven/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1625, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): computed output size would be negative [[Node: textCNN/conv-maxpool-5/conv = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](textCNN/BatchNorm/cond/Merge, textCNN/conv-maxpool-5/W/read)]]

I also tried using tf 0.5.0 using python 2.7 ,but, it throws no module named layers.core