0
votes

i got this error while run the code i got some result and suddenly it throw this error

 tensorflow.python.framework.errors_impl.InvalidArgumentError:  Matrix size-incompatible: In[0]: [42,1108], In[1]: [1120,256]
[[node model/dense/Relu 

what should i check to solve it

code is

def define_model(vocab_size, max_length, curr_shape):
inputs1 = Input(shape=curr_shape)
fe1 = Dropout(0.5)(inputs1)
fe2 = Dense(256, activation='relu')(fe1)
inputs2 = Input(shape=(max_length,))
se1 = Embedding(vocab_size, 256, mask_zero=True)(inputs2)
se2 = Dropout(0.5)(se1)
se3 = LSTM(256)(se2)
decoder1 = Concatenate()([fe2, se3])
decoder2 = Dense(256, activation='relu')(decoder1)
outputs = Dense(vocab_size, activation='softmax')(decoder2)
model = Model(inputs=[inputs1, inputs2], outputs=outputs)
model.compile(loss='categorical_crossentropy', optimizer='adam')
return model

the model summary is

Layer (type)            Output Shape       Param #Connected to                     
===================================================================
input_2 (InputLayer)            [(None, 49)]         0                                       
__________________________________________________________________
input_1 (InputLayer)            [(None, 1120)]       0                                         
___________________________________________________________________
embedding (Embedding)    (None, 49, 256)  6235648     input_2[0][0]                    

dropout (Dropout)               (None, 1120)         0           input_1[0][0]                    
___________________________________________________________________
dropout_1 (Dropout)             (None, 49, 256)      0           embedding[0][0]                  
___________________________________________________________________
dense (Dense)                   (None, 256)          286976      dropout[0][0]                    
lstm (LSTM)                     (None, 256)          525312      dropout_1[0][0]                  
concatenate (Concatenate)       (None, 512)          0           dense[0][0]                      
                                                                 lstm[0][0]                       
dense_1 (Dense)                 (None, 256)          131328        concatenate[0][0]                
dense_2 (Dense)                 (None, 24358)        6260006     dense_1[0][0]  
drop the following ,in the bracket in the inputs2 line [line 5 from the top] - nipun
Your inputs are probably variables in size. Pad them to the same length. - Lescurel
i tried to drop , but error still exists - user
@Lescurel how can i do that ? - user
will you please share a google collab link or a GitHub from where I can download the code and generate the error again? - Sohaib Anwaar