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)

DevRj
  • 448
  • 8
  • 19
Cibgks
  • 125
  • 6
  • Shuffle the data before training and use a dropout layer. This will probably increase the model accuracy – Wilmar van Ommeren Jul 28 '17 at 13:23
  • 3
    the problem is not about the model accuracy, the problem is when I save and then load the weights – Cibgks Jul 28 '17 at 13:32
  • So it is about the model accuracy. as after reloading the weights the accuracy drops. Which probably means that the model is overfitting. – Wilmar van Ommeren Jul 28 '17 at 14:20
  • Why? I mean, on the same test size before saving it works perfectly. After loading the weights seems to be random – Cibgks Jul 29 '17 at 12:54
  • They seem random? Can you test this by checking if `model.get_weights()` returns the same weights before and after loading the model? – Wilmar van Ommeren Jul 29 '17 at 18:32
  • 1
    Still no answer to this?? Having the same problem. Quite accurate before save, absolute garbage after save+load. – sh37211 Jan 21 '21 at 01:06

0 Answers0