Skuldur / Classical-Piano-Composer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Continue training?

opened this issue · comments

I am using linux and my everytime i run the code it starts the training all over from the beginning. How do i continue training?

Use model = load_model('REAL.hdf5') and model.save('REAL.hdf5')

Use model = load_model('REAL.hdf5') and model.save('REAL.hdf5')

Sorry, but I'm new and I'm not really familiar with Keras. My question is, is the REAL.hdf5 the same thing as the weight generated during each checkpoint? Is it any different with files generated by model.save?

Use model = load_model('REAL.hdf5') and model.save('REAL.hdf5')

Sorry, but I'm new and I'm not really familiar with Keras. My question is, is the REAL.hdf5 the same thing as the weight generated during each checkpoint? Is it any different with files generated by model.save?

Real.hdf5 is a name of MODEL, note weight. That's just the name of the model. And the code model.save gives you an opportunity to save it. And the next time you can load it with load.model(*name of your model*)

My code now looks like

`#保存とする調整

model = load_model('Real.hdf5')


history = model.fit(network_input, network_output, epochs=36, batch_size=2048, validation_split=0.2, callbacks=callbacks_list)


model.save('Real.hdf5')`

Thanks to @Utayaki . I was hit wit hthe same problem last night. Following the hint from @Utayaki , this is how I solved it.

  1. Made this change first
    #from keras.models import Sequential
    from keras.models import Sequential, load_model
  2. In "train" function, changed reference to filepath:
    #filepath = "weights-improvement-{epoch:02d}-{loss:.4f}-bigger.hdf5"
    filepath = "Real.hdf5"
  3. Couple of lines below, in the same "train" function, did this
    model = load_model('Real.hdf5')
    model.fit(network_input, network_output, epochs=200, batch_size=64, callbacks=callbacks_list)
    model.save('Real.hdf5')

This enabled me to save the model as "Real.hdf5". When the # of epochs runs completes. Copy "Real.hdf5" as "weights.hdf5" and run "python3 predict.py" to generate the output knowing the cost functions reflecting the error rate. Closer to ZERO provides a better result.

If you want to continue the training, just restart by running "python3 lstm.py".

good luck!

Made a pull request for this: #26