-1

How to save the weights of VGG-16 model after training it? How to load the saved weights in to the model?

I tried this:

fname = "weights-Test-CNN.hdf5"

custom_vgg_model.save_weights(fname,overwrite=True)
custom_vgg_model.load_weights(weights-Test-CNN.hdf5, by_name=False)

I got following error:

NameError Traceback (most recent call last) in () ----> 1 custom_vgg_model.load_weights(weights-Test-CNN.hdf5, by_name=False)

NameError: name 'weights' is not defined

stop-cran
  • 4,229
  • 2
  • 30
  • 47
A Santosh
  • 839
  • 1
  • 9
  • 11
  • 2
    Possible duplicate of [Save and load weights in keras](https://stackoverflow.com/questions/47266383/save-and-load-weights-in-keras) – S.Mohsen sh Feb 23 '18 at 17:25
  • You just forgot the quotes around weights-Test-CNN.hdf5... `custom_vgg_model.load_weights("weights-Test-CNN.hdf5", by_name=False)` – spadarian Feb 24 '18 at 10:24

1 Answers1

0

Surround the second weights-Test-CNN.hdf5 with quotes or you use fname as you have defined...

custom_vgg_model.load_weights("weights-Test-CNN.hdf5", by_name=False)
deramos
  • 48
  • 6