Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with running Ensamble models: InvalidArgumentError (see above for traceback): indices[0,1363] = 9 is not in [0, 2) #14

Open
zendra123 opened this issue Jan 5, 2023 · 0 comments

Comments

@zendra123
Copy link

zendra123 commented Jan 5, 2023

Hello everybody,

I have installed: Python 3.5.2, numpy==1.14.1, tensorflow==1.3.0, scikit-learn==0.19.0, keras==2.1.5 and h5py.

The following scripts run fine:
python train.py --v LSTM
python train.py --v biLSTM
python train.py --v CascadeLSTM

Nevertheless, when I run ensembles i.e.:
python train.py --v Ensemble2LSTM or
python train.py --v CascadeEnsembleLSTM

I get the following error message:
Traceback (most recent call last):
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\client\session.py", line 1327, in _do_call
return fn(*args)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\client\session.py", line 1306, in _run_fn
status, run_metadata)
File "C:\Users\u24t06\AppData\Local\Programs\Python\Python35\lib\contextlib.py", line 66, in exit
next(self.gen)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[0,1363] = 9 is not in [0, 2)
[[Node: embedding_2/Gather = Gather[Tindices=DT_INT32, Tparams=DT_FLOAT, validate_indices=true, _device="/job:localhost/replica:0/task:0/cpu:0"](embedding_2/embeddings/read, embedd
ing_2/Cast)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "train.py", line 93, in
callbacks=[csv_logger, model_checkpoint])
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\keras\models.py", line 963, in fit
validation_steps=validation_steps)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\keras\engine\training.py", line 1705, in fit
validation_steps=validation_steps)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\keras\engine\training.py", line 1235, in _fit_loop
outs = f(ins_batch)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 2478, in call
**self.session_kwargs)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\client\session.py", line 895, in run
run_metadata_ptr)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\client\session.py", line 1124, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\client\session.py", line 1321, in _do_run
options, run_metadata)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\client\session.py", line 1340, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[0,1363] = 9 is not in [0, 2)
[[Node: embedding_2/Gather = Gather[Tindices=DT_INT32, Tparams=DT_FLOAT, validate_indices=true, _device="/job:localhost/replica:0/task:0/cpu:0"](embedding_2/embeddings/read, embedd
ing_2/Cast)]]

Caused by op 'embedding_2/Gather', defined at:
File "train.py", line 66, in
model = models.get_Ensemble2LSTM(input_dim, units, data.max_lenght, no_activities)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\models.py", line 38, in get_Ensemble2LSTM
model2.add(Embedding(input_dim, output_dim, input_length=max_lenght, mask_zero=True))
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\keras\models.py", line 467, in add
layer(x)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\keras\engine\topology.py", line 619, in call
output = self.call(inputs, **kwargs)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\keras\layers\embeddings.py", line 138, in call
out = K.gather(self.embeddings, inputs)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 1211, in gather
return tf.gather(reference, indices)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\ops\array_ops.py", line 2409, in gather
validate_indices=validate_indices, name=name)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 1219, in gather
validate_indices=validate_indices, name=name)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\framework\ops.py", line 2630, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:\Users\u24t06\Desktop\Experiments\Experiment_5_1\venv\lib\site-packages\tensorflow\python\framework\ops.py", line 1204, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): indices[0,1363] = 9 is not in [0, 2)
[[Node: embedding_2/Gather = Gather[Tindices=DT_INT32, Tparams=DT_FLOAT, validate_indices=true, _device="/job:localhost/replica:0/task:0/cpu:0"](embedding_2/embeddings/read, embedd
ing_2/Cast)]]

Does anyone know how to fix this error?

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant