I trained a neural network, without any checkpoints, and at the end I wrote tf.keras.models.save_model(model, dirpath) to save the whole model, which created the following files:
savedmodel.pb
assets/
variables/variables.index
variables/variables.data-00000-of-00001
I tried loading the model using new_model = tf.keras.models.load_model(dirpath), but it gave a ValueError because I'm using a custom model (it seems, I created a class inheriting from tf.keras.Model). So instead I tried to instantiate a new model, and then just load the weights using
model = myModel(someArgs)
model.load_weights(dirpath/variables)
However, I get the following error message:
OSError: Unable to open file (unable to open file: name = 'dirpath/variables', errno = 13, error message = 'Permission denied', flags = 0, o_flags = 0)
So how can I load the weights onto the model? The files are there I just don't know how to put them back inside my model.
Figured it out, I was using the wrong path. I need to do model.load_weights(dirpath/variables/variables). There ate two files called variables, with different extenstions (.data-00000-of-00001 and .index), and that is the name you want to call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With