wrong results when saving and loading weights/model in Keras
Asked Answered
G

0

6

I can't post the code I am using, but i will try to explain it. First I have defined a few functions to preprocess the raw data. Then, using keras I have the following arquitecture:

model = Sequential()

model.add(Dense(10, input_dim=230, init='uniform',activation='sigmoid'))  

model.add(Dense(5, init='uniform', activation='sigmoid'))

model.add(Dense(2, init='uniform', activation='sigmoid'))

model.compile(loss='mse', optimizer='RMSprop', metrics=['binary_accuracy'])

model.fit(trainX, trainY, nb_epoch=1000, batch_size=1, callbacks=[history], verbose=2)

Now about the problem. When I run the code I get >98% accuracy, but when I save the weights/model (following keras doc) and then I load them, I get garbage results.

I have tried loading after and before compile line, saving/loading weights/model, nothing works (I keep getting wrong results after loading them in a different python session)

Glossography answered 28/7, 2017 at 13:18 Comment(6)
Shuffle the data before training and use a dropout layer. This will probably increase the model accuracyConstrained
the problem is not about the model accuracy, the problem is when I save and then load the weightsGlossography
So it is about the model accuracy. as after reloading the weights the accuracy drops. Which probably means that the model is overfitting.Constrained
Why? I mean, on the same test size before saving it works perfectly. After loading the weights seems to be randomGlossography
They seem random? Can you test this by checking if model.get_weights() returns the same weights before and after loading the model?Constrained
Still no answer to this?? Having the same problem. Quite accurate before save, absolute garbage after save+load.Rameau

© 2022 - 2024 — McMap. All rights reserved.