(0) Invalid argument: In[0] mismatch In[1] shape

i’m facing this problem

tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: In[0] mismatch In[1] shape: 1108 vs. 1120: [42,1108] [1120,256] 0 0
[[node model/dense/MatMul (defined at rnn_flickr_fit.py:273) ]]
(1) Invalid argument: In[0] mismatch In[1] shape: 1108 vs. 1120: [42,1108] [1120,256] 0 0
[[node model/dense/MatMul (defined at rnn_flickr_fit.py:273) ]]
[[Adam/Cast_6/ReadVariableOp/_6]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_7431]

Function call stack:
train_function -> train_function

2021-07-02 14:23:52.766840: 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}}]]

what should i check to solve it ?

Can you add a minimal code snippet that reproduce this issue please?

1 Like

model/dense/MatMul (defined at rnn_flickr_fit.py:273) ]]
(1) Invalid argument: In[0] mismatch In[1] shape: 1108 vs. 1120: [42,1108] [1120,256] 0 0

I’m not sure about the details, but this line is trying to tell you that you have a dense later somewhere that is getting an in put with an unexpected shape.

Since keras layers size their weights based on the first input they see, you’re probably feeding an input with a variable sized axis to that Dense layer. Maybe the first batch was (42, 1120), and this second batch is(42, 1108)

4 Likes

excuse me what should I do in this case ? and are zero paddings become a solution or not ?