Index out of bound error while creating model

Hi,
Can anyone help me in resolving the issue?
Below link shows my notebook. While creating model i am getting the error. Error is as shown below.

Errorr: Epoch 1/30

InvalidArgumentError Traceback (most recent call last)
in
3 model = create_model(NUM_WORDS, EMBEDDING_DIM, MAXLEN)
4
----> 5 history = model.fit(train_padded_seq, train_label_seq, epochs=30, validation_data=(val_padded_seq, val_label_seq))

/opt/conda/lib/python3.8/site-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
—> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb

/opt/conda/lib/python3.8/site-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
56 try:
57 ctx.ensure_initialized()
—> 58 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
59 inputs, attrs, num_outputs)
60 except core._NotOkStatusException as e:

InvalidArgumentError: indices[28,74] = 754 is not in [0, 16)
[[node sequential_4/embedding_4/embedding_lookup
(defined at /opt/conda/lib/python3.8/site-packages/keras/layers/embeddings.py:191)
]] [Op:__inference_train_function_2846]

Errors may have originated from an input operation.
Input Source operations connected to node sequential_4/embedding_4/embedding_lookup:
In[0] sequential_4/embedding_4/embedding_lookup/2617:
In[1] sequential_4/embedding_4/Cast (defined at /opt/conda/lib/python3.8/site-packages/keras/layers/embeddings.py:190)

Operation defined at: (most recent call last)

File “/opt/conda/lib/python3.8/runpy.py”, line 194, in _run_module_as_main
return _run_code(code, main_globals, None,

File “/opt/conda/lib/python3.8/runpy.py”, line 87, in _run_code
exec(code, run_globals)

File “/opt/conda/lib/python3.8/site-packages/ipykernel_launcher.py”, line 16, in
app.launch_new_instance()

File “/opt/conda/lib/python3.8/site-packages/traitlets/config/application.py”, line 845, in launch_instance
app.start()

File “/opt/conda/lib/python3.8/site-packages/ipykernel/kernelapp.py”, line 612, in start
self.io_loop.start()

File “/opt/conda/lib/python3.8/site-packages/tornado/platform/asyncio.py”, line 199, in start
self.asyncio_loop.run_forever()

File “/opt/conda/lib/python3.8/asyncio/base_events.py”, line 570, in run_forever
self._run_once()

File “/opt/conda/lib/python3.8/asyncio/base_events.py”, line 1859, in _run_once
handle._run()

File “/opt/conda/lib/python3.8/asyncio/events.py”, line 81, in _run
self._context.run(self._callback, *self._args)

File “/opt/conda/lib/python3.8/site-packages/tornado/ioloop.py”, line 688, in
lambda f: self._run_callback(functools.partial(callback, future))

File “/opt/conda/lib/python3.8/site-packages/tornado/ioloop.py”, line 741, in _run_callback
ret = callback()

File “/opt/conda/lib/python3.8/site-packages/tornado/gen.py”, line 814, in inner
self.ctx_run(self.run)

File “/opt/conda/lib/python3.8/site-packages/tornado/gen.py”, line 775, in run
yielded = self.gen.send(value)

File “/opt/conda/lib/python3.8/site-packages/ipykernel/kernelbase.py”, line 358, in process_one
yield gen.maybe_future(dispatch(*args))

File “/opt/conda/lib/python3.8/site-packages/tornado/gen.py”, line 234, in wrapper
yielded = ctx_run(next, result)

File “/opt/conda/lib/python3.8/site-packages/ipykernel/kernelbase.py”, line 261, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))

File “/opt/conda/lib/python3.8/site-packages/tornado/gen.py”, line 234, in wrapper
yielded = ctx_run(next, result)

File “/opt/conda/lib/python3.8/site-packages/ipykernel/kernelbase.py”, line 536, in execute_request
self.do_execute(

File “/opt/conda/lib/python3.8/site-packages/tornado/gen.py”, line 234, in wrapper
yielded = ctx_run(next, result)

File “/opt/conda/lib/python3.8/site-packages/ipykernel/ipkernel.py”, line 302, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)

File “/opt/conda/lib/python3.8/site-packages/ipykernel/zmqshell.py”, line 539, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/IPython/core/interactiveshell.py”, line 2894, in run_cell
result = self._run_cell(

File “/opt/conda/lib/python3.8/site-packages/IPython/core/interactiveshell.py”, line 2940, in _run_cell
return runner(coro)

File “/opt/conda/lib/python3.8/site-packages/IPython/core/async_helpers.py”, line 68, in _pseudo_sync_runner
coro.send(None)

File “/opt/conda/lib/python3.8/site-packages/IPython/core/interactiveshell.py”, line 3165, in run_cell_async
has_raised = await self.run_ast_nodes(code_ast.body, cell_name,

File “/opt/conda/lib/python3.8/site-packages/IPython/core/interactiveshell.py”, line 3357, in run_ast_nodes
if (await self.run_code(code, result, async_=asy)):

File “/opt/conda/lib/python3.8/site-packages/IPython/core/interactiveshell.py”, line 3437, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File “”, line 5, in
history = model.fit(train_padded_seq, train_label_seq, epochs=30, validation_data=(val_padded_seq, val_label_seq))

File “/opt/conda/lib/python3.8/site-packages/keras/utils/traceback_utils.py”, line 64, in error_handler
return fn(*args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 1216, in fit
tmp_logs = self.train_function(iterator)

File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 878, in train_function
return step_function(self, iterator)

File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 867, in step_function
outputs = model.distribute_strategy.run(run_step, args=(data,))

File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 860, in run_step
outputs = model.train_step(data)

File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 808, in train_step
y_pred = self(x, training=True)

File “/opt/conda/lib/python3.8/site-packages/keras/utils/traceback_utils.py”, line 64, in error_handler
return fn(*args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/keras/engine/base_layer.py”, line 1083, in call
outputs = call_fn(inputs, *args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/keras/utils/traceback_utils.py”, line 92, in error_handler
return fn(*args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/keras/engine/sequential.py”, line 373, in call
return super(Sequential, self).call(inputs, training=training, mask=mask)

File “/opt/conda/lib/python3.8/site-packages/keras/engine/functional.py”, line 451, in call
return self._run_internal_graph(

File “/opt/conda/lib/python3.8/site-packages/keras/engine/functional.py”, line 589, in _run_internal_graph
outputs = node.layer(*args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/keras/utils/traceback_utils.py”, line 64, in error_handler
return fn(*args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/keras/engine/base_layer.py”, line 1083, in call
outputs = call_fn(inputs, *args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/keras/utils/traceback_utils.py”, line 92, in error_handler
return fn(*args, **kwargs)

File “/opt/conda/lib/python3.8/site-packages/keras/layers/embeddings.py”, line 191, in call
out = tf.nn.embedding_lookup(self.embeddings, inputs)

If:

  1. input_dim value of Embedding layer is properly set
  2. Datasets are properly shaped
    Please click my name and message your notebook as an attachment.

Still blocked. Any lead from anyone would really be appreciated. Thank you.

Nevermind i resolved this issue

hey I had the same issue, can I know how did you resolve?

Please click my name and message your notebook as an attachment.

I have sent the notebook to your inbox

Your concerns are addressed in this topic. Please don’t reply here.

You replied here so I only responded to that message.