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

Matrix size-incompatible #14

Open
hardiknahata opened this issue Nov 27, 2021 · 0 comments
Open

Matrix size-incompatible #14

hardiknahata opened this issue Nov 27, 2021 · 0 comments

Comments

@hardiknahata
Copy link

After model creation, when the first epoch starts, I get this error:

tensorflow.python.framework.errors_impl.InvalidArgumentError: Matrix size-incompatible: In[0]: [47,1000], In[1]: [4096,256]
[[node model/dense/Relu

Can you help me with this please? Seems like some size issue of tensor.

Error Traceback:


Layer (type) Output Shape Param # Connected to

input_1 (InputLayer) [(None, 4096)] 0 []

dropout (Dropout) (None, 4096) 0 ['input_1[0][0]']

dense (Dense) (None, 256) 1048832 ['dropout[0][0]']

input_2 (InputLayer) [(None, 34)] 0 []

repeat_vector (RepeatVector) (None, 34, 256) 0 ['dense[0][0]']

embedding (Embedding) (None, 34, 256) 1940224 ['input_2[0][0]']

concatenate (Concatenate) (None, 34, 512) 0 ['repeat_vector[0][0]',
'embedding[0][0]']

lstm (LSTM) (None, 500) 2026000 ['concatenate[0][0]']

dense_1 (Dense) (None, 7579) 3797079 ['lstm[0][0]']

==================================================================================================
Total params: 8,812,135
Trainable params: 8,812,135
Non-trainable params: 0


None
train_model.py:48: UserWarning: Model.fit_generator is deprecated and will be removed in a future version. Please use Model.fit, which supports generators.
callbacks=[checkpoint], validation_data=val_generator, validation_steps=val_steps)
Epoch 1/20
Traceback (most recent call last):
File "train_model.py", line 58, in
train_model(epochs=20)
File "train_model.py", line 48, in train_model
callbacks=[checkpoint], validation_data=val_generator, validation_steps=val_steps)
File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\training.py", line 2030, in fit_generator
initial_epoch=initial_epoch)
File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\tensorflow\python\eager\execute.py", line 59, in quick_execute
inputs, attrs, num_outputs)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Matrix size-incompatible: In[0]: [47,1000], In[1]: [4096,256]
[[node model/dense/Relu
(defined at C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\backend.py:4867)
]] [Op:__inference_train_function_7367]

Errors may have originated from an input operation.
Input Source operations connected to node model/dense/Relu:
In[0] model/dense/BiasAdd (defined at C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\layers\core\dense.py:210)

Operation defined at: (most recent call last)

File "train_model.py", line 58, in
train_model(epochs=20)

File "train_model.py", line 48, in train_model
callbacks=[checkpoint], validation_data=val_generator, validation_steps=val_steps)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\training.py", line 2030, in fit_generator
initial_epoch=initial_epoch)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\utils\traceback_utils.py", line 64, in error_handler
return fn(*args, **kwargs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\training.py", line 1216, in fit
tmp_logs = self.train_function(iterator)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\training.py", line 878, in train_function
return step_function(self, iterator)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\training.py", line 867, in step_function
outputs = model.distribute_strategy.run(run_step, args=(data,))

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\training.py", line 860, in run_step
outputs = model.train_step(data)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\training.py", line 808, in train_step
y_pred = self(x, training=True)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\utils\traceback_utils.py", line 64, in error_handler
return fn(*args, **kwargs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\base_layer.py", line 1083, in call
outputs = call_fn(inputs, *args, **kwargs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\utils\traceback_utils.py", line 92, in error_handler
return fn(*args, **kwargs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\functional.py", line 452, in call
inputs, training=training, mask=mask)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\functional.py", line 589, in _run_internal_graph
outputs = node.layer(*args, **kwargs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\utils\traceback_utils.py", line 64, in error_handler
return fn(*args, **kwargs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\engine\base_layer.py", line 1083, in call
outputs = call_fn(inputs, *args, **kwargs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\utils\traceback_utils.py", line 92, in error_handler
return fn(*args, **kwargs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\layers\core\dense.py", line 213, in call
outputs = self.activation(outputs)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\activations.py", line 311, in relu
return backend.relu(x, alpha=alpha, max_value=max_value, threshold=threshold)

File "C:\Users\kingo\miniconda3\envs\icg\lib\site-packages\keras\backend.py", line 4867, in relu
x = tf.nn.relu(x)

2021-11-27 03:22:33.545141: W tensorflow/core/kernels/data/generator_dataset_op.cc:107] Error occurred when finalizing GeneratorDataset iterator: FAILED_PRECONDITION: Python interpreter state is not initialized. The process may be terminated.
[[{{node PyFunc}}]]

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