Attached is the screenshot of complete code

can someone point out me where I am doing mistake. I guess I am getting error due to train/test size error but failing to fit the model properly.

print('train_sequences shape:', train_sequences.shape) print('train_data shape:', train_data['HOSPITAL_EXPIRE_FLAG'].shape) print('Expected input shape for RNN model:', test_sequences.shape)

output: train_sequences shape: (23145, 20) train_data shape: (23145,) Expected input shape for RNN model: (5787, 20)

Error:

Epoch 1/10 --------------------------------------------------------------------------- InvalidArgumentError Traceback (most recent call last) <ipython-input-45-fa4316a098d4> in <module> 1 # Fit model to training data ----> 2 model.fit(train_sequences, train_data['HOSPITAL_EXPIRE_FLAG'], epochs=10, batch_size=128) 3 4 # Evaluate model on testing data 5 loss, accuracy = model.evaluate(test_sequences, test_data['HOSPITAL_EXPIRE_FLAG'], verbose=0) 1 frames /usr/local/lib/python3.9/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name) 50 try: 51 ctx.ensure_initialized() ---> 52 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, 53 inputs, attrs, num_outputs) 54 except core._NotOkStatusException as e: InvalidArgumentError: Graph execution error: Detected at node 'sequential_5/embedding_5/embedding_lookup' defined at (most recent call last): File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.9/dist-packages/ipykernel_launcher.py", line 16, in <module> app.launch_new_instance() File "/usr/local/lib/python3.9/dist-packages/traitlets/config/application.py", line 992, in launch_instance app.start() File "/usr/local/lib/python3.9/dist-packages/ipykernel/kernelapp.py", line 612, in start self.io_loop.start() File "/usr/local/lib/python3.9/dist-packages/tornado/platform/asyncio.py", line 215, in start self.asyncio_loop.run_forever() File "/usr/lib/python3.9/asyncio/base_events.py", line 601, in run_forever self._run_once() File "/usr/lib/python3.9/asyncio/base_events.py", line 1905, in _run_once handle._run() File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.9/dist-packages/tornado/ioloop.py", line 687, in <lambda> lambda f: self._run_callback(functools.partial(callback, future)) File "/usr/local/lib/python3.9/dist-packages/tornado/ioloop.py", line 740, in _run_callback ret = callback() File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 821, in inner self.ctx_run(self.run) File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 782, in run yielded = self.gen.send(value) File "/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py", line 365, in process_one yield gen.maybe_future(dispatch(*args)) File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 234, in wrapper yielded = ctx_run(next, result) File "/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell yield gen.maybe_future(handler(stream, idents, msg)) File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 234, in wrapper yielded = ctx_run(next, result) File "/usr/local/lib/python3.9/dist-packages/ipykernel/kernelbase.py", line 543, in execute_request self.do_execute( File "/usr/local/lib/python3.9/dist-packages/tornado/gen.py", line 234, in wrapper yielded = ctx_run(next, result) File "/usr/local/lib/python3.9/dist-packages/ipykernel/ipkernel.py", line 306, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "/usr/local/lib/python3.9/dist-packages/ipykernel/zmqshell.py", line 536, in run_cell return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py", line 2854, in run_cell result = self._run_cell( File "/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py", line 2881, in _run_cell return runner(coro) File "/usr/local/lib/python3.9/dist-packages/IPython/core/async_helpers.py", line 68, in _pseudo_sync_runner coro.send(None) File "/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py", line 3057, in run_cell_async has_raised = await self.run_ast_nodes(code_ast.body, cell_name, File "/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py", line 3249, in run_ast_nodes if (await self.run_code(code, result, async_=asy)): File "/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py", line 3326, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-43-69e23fc6d133>", line 2, in <module> model.fit(train_sequences, train_data['HOSPITAL_EXPIRE_FLAG'], epochs=10, batch_size=181) File "/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py", line 65, in error_handler return fn(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1650, in fit tmp_logs = self.train_function(iterator) File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1249, in train_function return step_function(self, iterator) File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1233, in step_function outputs = model.distribute_strategy.run(run_step, args=(data,)) File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1222, in run_step outputs = model.train_step(data) File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 1023, in train_step y_pred = self(x, training=True) File "/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py", line 65, in error_handler return fn(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/engine/training.py", line 561, in __call__ return super().__call__(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py", line 65, in error_handler return fn(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/engine/base_layer.py", line 1132, in __call__ outputs = call_fn(inputs, *args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py", line 96, in error_handler return fn(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/engine/sequential.py", line 413, in call return super().call(inputs, training=training, mask=mask) File "/usr/local/lib/python3.9/dist-packages/keras/engine/functional.py", line 511, in call return self._run_internal_graph(inputs, training=training, mask=mask) File "/usr/local/lib/python3.9/dist-packages/keras/engine/functional.py", line 668, in _run_internal_graph outputs = node.layer(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py", line 65, in error_handler return fn(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/engine/base_layer.py", line 1132, in __call__ outputs = call_fn(inputs, *args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/utils/traceback_utils.py", line 96, in error_handler return fn(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/keras/layers/core/embedding.py", line 208, in call out = tf.nn.embedding_lookup(self.embeddings, inputs) Node: 'sequential_5/embedding_5/embedding_lookup' indices[120,0] = -2147483648 is not in [0, 1992) [[{{node sequential_5/embedding_5/embedding_lookup}}]] [Op:__inference_train_function_8280]

I tried to fix but failed.

You are watching: Invalid Argument Error – Graph Execution Error using Keras (MIMIC dataset, SEPSIS prediction). Info created by GBee English Center selection and synthesis along with other related topics.