epochs = 10
batch_size = 32
steps = len(train) // batch_size
for i in range(epochs):
generator = data_generator(train, mapping, features, tokenizer, max_length, vocab_size, batch_size)
model.fit(generator, epochs=1, steps_per_epoch=steps, verbose=1)
Welcome to the Tensorflow Forum,
Instead of an image, could you please share error stack trace in text format and more details of your code?
Thank you!
@chunduriv
Thanks for the response.
As requested I will share the error in text format.
from keras.preprocessing.image import ImageDataGenerator
# train the model
model = define_model(vocab_size, max_length)
# train the model, run epochs manually and save after each epoch
epochs = 20
steps = len(train_descriptions)
for i in range(epochs):
# create the data generator
generator = data_generator(train_descriptions, train_features, tokenizer, max_length)
# fit for one epoch
#Model.fit(generator, epochs=1, steps_per_epoch=steps, verbose=1)
model.fit(generator, epochs=1, steps_per_epoch=steps, verbose=1)
# save model
model.save('model_' + str(i) + '.h5')
here is the outcome
InvalidArgumentError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_12120\3782113586.py in <module>
10 # fit for one epoch
11 #Model.fit(generator, epochs=1, steps_per_epoch=steps, verbose=1)
---> 12 model.fit(generator, epochs=1, steps_per_epoch=steps, verbose=1)
13 # save model
14 model.save('model_' + str(i) + '.h5')
~\AppData\Roaming\Python\Python39\site-packages\keras\utils\traceback_utils.py in error_handler(*args, **kwargs)
68 # To get the full stack trace, call:
69 # `tf.debugging.disable_traceback_filtering()`
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
~\AppData\Roaming\Python\Python39\site-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 'model_2/dense/Relu' defined at (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 17, in <module>
app.launch_new_instance()
File "C:\ProgramData\Anaconda3\lib\site-packages\traitlets\config\application.py", line 846, in launch_instance
app.start()
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelapp.py", line 712, in start
self.io_loop.start()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\platform\asyncio.py", line 199, in start
self.asyncio_loop.run_forever()
File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 601, in run_forever
self._run_once()
File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 1905, in _run_once
handle._run()
File "C:\ProgramData\Anaconda3\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 510, in dispatch_queue
await self.process_one()
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 499, in process_one
await dispatch(*args)
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 406, in dispatch_shell
await result
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 730, in execute_request
reply_content = await reply_content
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\ipkernel.py", line 390, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\zmqshell.py", line 528, in run_cell
return super().run_cell(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2914, in run_cell
result = self._run_cell(
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2960, in _run_cell
return runner(coro)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\async_helpers.py", line 78, in _pseudo_sync_runner
coro.send(None)
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3185, in run_cell_async
has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3377, in run_ast_nodes
if (await self.run_code(code, result, async_=asy)):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3457, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "C:\Users\Adejimi AA\AppData\Local\Temp\ipykernel_12120\3782113586.py", line 12, in <module>
model.fit(generator, epochs=1, steps_per_epoch=steps, verbose=1)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\utils\traceback_utils.py", line 65, in error_handler
return fn(*args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\training.py", line 1685, in fit
tmp_logs = self.train_function(iterator)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\training.py", line 1284, in train_function
return step_function(self, iterator)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\training.py", line 1268, in step_function
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\training.py", line 1249, in run_step
outputs = model.train_step(data)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\training.py", line 1050, in train_step
y_pred = self(x, training=True)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\utils\traceback_utils.py", line 65, in error_handler
return fn(*args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\training.py", line 558, in __call__
return super().__call__(*args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\utils\traceback_utils.py", line 65, in error_handler
return fn(*args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\base_layer.py", line 1145, in __call__
outputs = call_fn(inputs, *args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\utils\traceback_utils.py", line 96, in error_handler
return fn(*args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\functional.py", line 512, in call
return self._run_internal_graph(inputs, training=training, mask=mask)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\functional.py", line 669, in _run_internal_graph
outputs = node.layer(*args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\utils\traceback_utils.py", line 65, in error_handler
return fn(*args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\engine\base_layer.py", line 1145, in __call__
outputs = call_fn(inputs, *args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\utils\traceback_utils.py", line 96, in error_handler
return fn(*args, **kwargs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\layers\core\dense.py", line 255, in call
outputs = self.activation(outputs)
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\activations.py", line 317, in relu
return backend.relu(
File "C:\Users\Adejimi AA\AppData\Roaming\Python\Python39\site-packages\keras\backend.py", line 5396, in relu
x = tf.nn.relu(x)
Node: 'model_2/dense/Relu'
Matrix size-incompatible: In[0]: [53,1000], In[1]: [4096,256]
[[{{node model_2/dense/Relu}}]] [Op:__inference_train_function_1035897]
I hope this information suffices.
Matrix size-incompatible: In[0]: [53,1000], In[1]: [4096,256]
In model, you can try changing the input layer to 1000
instead of 4096
.
Thank you!
@chunduriv
I am working on it.
I will give you an update on the result.
Thank you.
@chunduriv
Thank yo very much.
It worked.