jind11 / TextFooler

A Model for Natural Language Attack on Text Classification and Inference
MIT License
485 stars 79 forks source link

Invalid argument when calculating sim_predictor.senmantic_sim() #14

Open tyz98 opened 4 years ago

tyz98 commented 4 years ago

I'm able to load the USE model, but when running sim_predictor.senmantic_sim(), there is an error as below. How can I fix this? 2020-03-23 05:50:07.614773: W tensorflow/core/framework/op_kernel.cc:1622] OP_REQUIRES failed at sparse_to_dense_op.cc:128: Invalid argument: indices[16] = [0,16] is out of bounds: need 0 <= index < [49,16] 2020-03-23 05:50:07.614887: W tensorflow/core/common_runtime/base_collective_executor.cc:216] BaseCollectiveExecutor::StartAbort Invalid argument: indices[16] = [0,16] is out of bounds: need 0 <= index < [49,16] [[{{node text_preprocessor/SparseToDense}}]] [[Encoder_en/Transformer/PrepareForTransformer/embedding_lookup/DynamicPartition/_58]] 2020-03-23 05:50:07.615180: W tensorflow/core/common_runtime/base_collective_executor.cc:216] BaseCollectiveExecutor::StartAbort Invalid argument: indices[16] = [0,16] is out of bounds: need 0 <= index < [49,16] [[{{node text_preprocessor/SparseToDense}}]] Traceback (most recent call last): File "attack_classification.py", line 622, in main() File "attack_classification.py", line 590, in main batch_size=args.batch_size) File "attack_classification.py", line 281, in attack embeddings1 = sim_predictor(sent1) File "/usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line891, in call outputs = self.call(cast_inputs, *args, **kwargs) File "/usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_hub/keras_layer.py", line 209, in call result = f() File "/usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py", line 1081, incall return self._call_impl(args, kwargs) File "/usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py", line 1121, in_call_impl return self._call_flat(args, self.captured_inputs, cancellation_manager) File "/usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py", line 1224, in_call_flat ctx, args, cancellation_manager=cancellation_manager) File "/usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py", line 511, in call ctx=ctx) File "/usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_core/python/eager/execute.py", line 67, in quick_execute six.raise_from(core._status_to_exception(e.code, message), None) File "", line 3, in raise_from tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found. (0) Invalid argument: indices[16] = [0,16] is out of bounds: need 0 <= index < [49,16] [[node text_preprocessor/SparseToDense (defined at /usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py:1751) ]] [[Encoder_en/Transformer/PrepareForTransformer/embedding_lookup/DynamicPartition/_58]] (1) Invalid argument: indices[16] = [0,16] is out of bounds: need 0 <= index < [49,16] [[node text_preprocessor/SparseToDense (defined at /usr/local/miniconda3/envs/dl/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py:1751) ]] 0 successful operations. 0 derived errors ignored. [Op:__inference_pruned_6865]

Function call stack: pruned -> pruned

jind11 commented 4 years ago

hi, have you successfully installed USE at your environment?