liushulinle / event_detection_without_triggers

Apache License 2.0
62 stars 17 forks source link

这里显示没有-1对应的向量,不知道哪里出了问题 #9

Open wuhua5027 opened 2 years ago

wuhua5027 commented 2 years ago

InvalidArgumentError (see above for traceback): indices[0,26] = -1 is not in [0, 114520) [[Node: embedding_lookup = Gather[Tindices=DT_INT64, Tparams=DT_FLOAT, _class=["loc:@w_emb"], validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](w_emb/read, _arg_sent_0_3)]]

happybenbendog commented 9 months ago

image +1

liushulinle commented 9 months ago

可以检查下是不是tf版本的问题, 代码在 tf1.4上应该是没有问题的

happybenbendog commented 9 months ago

老师,您好,我在unbuntu20.04上使用docker安装的tf1.4,还是有上述问题,这是我的报错截图:

b48a43e52b1ae7dd50659bb1a8228cf

异常信息如下:

展开/折叠 ```text root@574a7c5566b6:/ws/edwt# python2 run_model.py evaluation 2023-12-25 08:25:55.959640: 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 2023-12-25 08:25:55.981330: E tensorflow/stream_executor/cuda/cuda_driver.cc:406] failed call to cuInit: CUDA_ERROR_NO_DEVICE 2023-12-25 08:25:55.981359: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:158] retrieving CUDA diagnostic information for host: 574a7c5566b6 2023-12-25 08:25:55.981363: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: 574a7c5566b6 2023-12-25 08:25:55.981385: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: 525.147.5 2023-12-25 08:25:55.981399: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:369] driver version file contents: """NVRM version: NVIDIA UNIX x86_64 Kernel Module 525.147.05 Wed Oct 25 20:27:35 UTC 2023 GCC version: gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2) """ 2023-12-25 08:25:55.981406: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: 525.147.5 2023-12-25 08:25:55.981409: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:300] kernel version seems to match DSO: 525.147.5 Sample 0: [Sen=Rodong called for a `` fair and equal '' footing in talks with the United States , blasting Washington for insisting that there would be `` no security of the system nor provision of rewards '' even if Pyongyang gave] [ans=meet], [pred_events=meet] Traceback (most recent call last): File "run_model.py", line 218, in run_eval() File "run_model.py", line 210, in run_eval eval_model(test_path, model_dir, model_ver) File "run_model.py", line 202, in eval_model test_sent(test_sents, test_ents, test_y) File "run_model.py", line 171, in test_sent pred = predict_sen(sess,test_sents[k], test_ents[k], ydict, cmodel) File "run_model.py", line 58, in predict_sen pred = sess.run(cmodel.pred,feed_dict=feeddict) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 889, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1120, in _run feed_dict_tensor, options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1317, in _do_run options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1336, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[0,26] = -1 is not in [0, 114520) [[Node: embedding_lookup = Gather[Tindices=DT_INT64, Tparams=DT_FLOAT, _class=["loc:@w_emb"], validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](w_emb/read, _arg_sent_0_3)]] Caused by op u'embedding_lookup', defined at: File "run_model.py", line 218, in run_eval() File "run_model.py", line 210, in run_eval eval_model(test_path, model_dir, model_ver) File "run_model.py", line 192, in eval_model cmodel = tbnnam_model.TBNNAM(settings) File "/ws/edwt/model/tbnnam_model.py", line 40, in __init__ self.x_w=tf.nn.embedding_lookup(self.w_embedding,self.sent) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/embedding_ops.py", line 328, in embedding_lookup transform_fn=None) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/embedding_ops.py", line 150, in _embedding_lookup_and_transform result = _clip(_gather(params[0], ids, name=name), ids, max_norm) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/embedding_ops.py", line 54, in _gather return array_ops.gather(params, ids, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 2486, in gather params, indices, validate_indices=validate_indices, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1834, in gather validate_indices=validate_indices, 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 2956, in create_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1470, in __init__ self._traceback = self._graph._extract_stack() # pylint: disable=protected-access InvalidArgumentError (see above for traceback): indices[0,26] = -1 is not in [0, 114520) [[Node: embedding_lookup = Gather[Tindices=DT_INT64, Tparams=DT_FLOAT, _class=["loc:@w_emb"], validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](w_emb/read, _arg_sent_0_3)]] ```
liushulinle commented 9 months ago

抱歉 确认了下 tf版本写的有问题 实验的版本应该是tf1.14 不是1.4

happybenbendog commented 9 months ago

老师,我在tf1.14的环境尝试了也是同样的错误,感谢您的回复:

d52ae4606bfa1522b675a9211b76dfe

日志:

展开/折叠 ```text root@4cb69a2c4094:/ws/edwt# python2 run_model.py evaluation WARNING: Logging before flag parsing goes to stderr. W1225 11:12:54.805263 139836331931456 deprecation_wrapper.py:119] From run_model.py:188: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead. W1225 11:12:55.398235 139836331931456 deprecation_wrapper.py:119] From /ws/edwt/model/tbnnam_model.py:18: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead. W1225 11:12:55.757611 139836331931456 lazy_loader.py:50] The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see: * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md * https://github.com/tensorflow/addons * https://github.com/tensorflow/io (for I/O related ops) If you depend on functionality not listed there, please file an issue. W1225 11:12:55.757704 139836331931456 deprecation.py:323] From /ws/edwt/model/tbnnam_model.py:47: __init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version. Instructions for updating: This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0. W1225 11:12:55.757878 139836331931456 deprecation.py:323] From /ws/edwt/model/tbnnam_model.py:48: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version. Instructions for updating: Please use `keras.layers.RNN(cell)`, which is equivalent to this API W1225 11:12:55.787429 139836331931456 deprecation.py:506] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/init_ops.py:1251: calling __init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor W1225 11:12:55.790563 139836331931456 deprecation.py:506] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn_cell_impl.py:738: calling __init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor W1225 11:12:55.999982 139836331931456 deprecation.py:323] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn.py:244: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.where in 2.0, which has the same broadcast rule as np.where W1225 11:12:56.010317 139836331931456 deprecation.py:506] From /ws/edwt/model/tbnnam_model.py:56: calling reduce_sum_v1 (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead W1225 11:12:56.014056 139836331931456 deprecation_wrapper.py:119] From /ws/edwt/model/tbnnam_model.py:70: The name tf.trainable_variables is deprecated. Please use tf.compat.v1.trainable_variables instead. W1225 11:12:56.015846 139836331931456 deprecation_wrapper.py:119] From /ws/edwt/model/tbnnam_model.py:73: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead. W1225 11:12:56.229701 139836331931456 deprecation_wrapper.py:119] From run_model.py:193: The name tf.global_variables_initializer is deprecated. Please use tf.compat.v1.global_variables_initializer instead. W1225 11:12:56.230113 139836331931456 deprecation_wrapper.py:119] From run_model.py:194: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead. W1225 11:12:56.238226 139836331931456 deprecation_wrapper.py:119] From run_model.py:195: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead. 2023-12-25 11:12:56.238734: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcuda.so.1 2023-12-25 11:12:56.256726: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected 2023-12-25 11:12:56.256746: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: 4cb69a2c4094 2023-12-25 11:12:56.256748: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: 4cb69a2c4094 2023-12-25 11:12:56.256773: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:200] libcuda reported version is: 525.147.5 2023-12-25 11:12:56.256784: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:204] kernel reported version is: 525.147.5 2023-12-25 11:12:56.256786: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:310] kernel version seems to match DSO: 525.147.5 2023-12-25 11:12:56.256912: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2023-12-25 11:12:56.279392: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3609600000 Hz 2023-12-25 11:12:56.280782: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x556c427999d0 executing computations on platform Host. Devices: 2023-12-25 11:12:56.280815: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): , 2023-12-25 11:12:56.544114: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile. W1225 11:12:56.684984 139836331931456 deprecation.py:323] From /usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py:1276: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to check for files with this prefix. Sample 0: [Sen=Rodong called for a `` fair and equal '' footing in talks with the United States , blasting Washington for insisting that there would be `` no security of the system nor provision of rewards '' even if Pyongyang gave] [ans=meet], [pred_events=meet] Traceback (most recent call last): File "run_model.py", line 217, in run_eval() File "run_model.py", line 209, in run_eval eval_model(test_path, model_dir, model_ver) File "run_model.py", line 201, in eval_model test_sent(test_sents, test_ents, test_y) File "run_model.py", line 170, in test_sent pred = predict_sen(sess,test_sents[k], test_ents[k], ydict, cmodel) File "run_model.py", line 57, in predict_sen pred = sess.run(cmodel.pred,feed_dict=feeddict) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1173, in _run feed_dict_tensor, options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1350, in _do_run run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1370, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[15,26] = -1 is not in [0, 114520) [[node embedding_lookup (defined at /ws/edwt/model/tbnnam_model.py:40) ]] Errors may have originated from an input operation. Input Source operations connected to node embedding_lookup: w_emb/read (defined at /ws/edwt/model/tbnnam_model.py:26) sent (defined at /ws/edwt/model/tbnnam_model.py:18) Original stack trace for u'embedding_lookup': File "run_model.py", line 217, in run_eval() File "run_model.py", line 209, in run_eval eval_model(test_path, model_dir, model_ver) File "run_model.py", line 191, in eval_model cmodel = tbnnam_model.TBNNAM(settings) File "/ws/edwt/model/tbnnam_model.py", line 40, in __init__ self.x_w=tf.nn.embedding_lookup(self.w_embedding,self.sent) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/embedding_ops.py", line 315, in embedding_lookup transform_fn=None) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/embedding_ops.py", line 133, in _embedding_lookup_and_transform array_ops.gather(params[0], ids, name=name), ids, max_norm) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/dispatch.py", line 180, in wrapper return target(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 3475, in gather return gen_array_ops.gather_v2(params, indices, axis, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 4097, in gather_v2 batch_dims=batch_dims, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 3616, in create_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2005, in __init__ self._traceback = tf_stack.extract_stack() ```
liushulinle commented 9 months ago

我没遇到过这个问题 实在不行可以试试修改utils /load_data.py里面的第18行,之前是用-1padding的 可以改成0试试 可能会影响一点效果