pseudo_teetotaler
pseudo_teetotaler

Reputation: 1575

keras model load error

I saved my model post training successfully using

model.save("my_model.h5")

Now, when I try to load model using load_model, it gives the following error

model = load_model("my_model.h5") 
ValueError: You are trying to load a weight file containing 8 layers into a model with 0 layers. 

My code :

model = create_model(layer_sizes1, layer_sizes2, input_shape1, input_shape2,learning_rate, reg_par, outdim_size, use_all_singular_values)
model.summary()
model = train_model(model, data1, data2, epoch_num, batch_size)
model.save("my_model.h5")

This saves the model, but when I try to load_model it gives above mentioned error .

Model is neural network with three hidden layers. Model definition u can find here : https://github.com/adakum/DeepCCA

Upvotes: 3

Views: 2356

Answers (1)

Referor
Referor

Reputation: 21

To solve this problem you need to directly add input_shape=(X.shape[1],) in your first layer. For example, shape of your X is 10 rows and 100 columns. You need to add input_shape=(100,) to your first layer

Upvotes: 2

Related Questions