Does keras save_weights() function overwrite previous weights?

Viewed 1743

I just want to confirm if the save_weights() function in keras defaults to overwriting a previous weights file if the weight file already exists?

For example, if I train my neural net for 10 epochs, save the weights to 'myweights.h5' via save_weights, and then I load those weights and train it for another 10 epochs and then save the weights to 'myweights.h5' again, will the first 10 epoch's weights get erased and now I'll have new weights from after 20 epochs? I looked at the documentation at https://keras.io/getting-started/faq/#savingloading-only-a-models-weights but it didn't specify whether it overwrites the old file or not. Some searching on google seems to say that it doesn't default to overwriting the older weights, but those are older threads and probably for older versions of keras.

1 Answers

Yes absolutely, if you don't want this behaviour you have to use different names each times (composing with steps/epochs for instance).

Related