I have the following code of my model:
model = keras.Sequential()
model.add(L.InputLayer(batch_input_shape= (None, 768)))
model.add(L.Dense(input_shape = (None,768), activation='relu', units = 256))
model.add(L.Dense(input_shape = (None,256), activation='relu', units = 128))
model.add(L.Dense(input_shape=(None,128), activation='relu', units = 301))
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy', precision, recall, f1])
With such resalt of model.summury():
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_1 (Dense) (None, 256) 196864
_________________________________________________________________
dense_2 (Dense) (None, 128) 32896
_________________________________________________________________
dense_3 (Dense) (None, 301) 38829
=================================================================
Total params: 268,589
Trainable params: 268,589
Non-trainable params: 0
_______________________________________
I've saved pretrained model with this code:
model.save('./tag_prediction_model.h5')
And loaded with this:
dependincies = {
'precision': precision,
'recall': recall,
'f1': f1
}
model1 = load_model('./tag_prediction_model.h5', custom_objects=dependincies)
But when I loaded it from the file, I this error occured with dimensoins. I checked loaded model summary and saw this:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_1 (Dense) (None, None, 256) 196864
_________________________________________________________________
dense_2 (Dense) (None, None, 128) 32896
_________________________________________________________________
dense_3 (Dense) (None, None, 301) 38829
=================================================================
Total params: 268,589
Trainable params: 268,589
Non-trainable params: 0
_________________________________________________________________
How can I fix this? I'm using tensorflow 1.15 and keras 2.3.1