Reputation: 31
I have a custom classification model. I need to change the name of last convolution layer for some reason. Model loads in 7 to 9 seconds before the update but after the name change it takes forever. I couldn't find any reason for that.
I saved the model using tf.keras.callbacks.ModelCheckpoint()
in the first place.
This is how I update:
best_acc_model = tf.keras.models.load_model("path/to/model")
best_acc_model.get_layer("conv_name")._name = "new_conv_name"
best_acc_model.save("save/path")
And this is how I load the updated model:
model = tf.keras.models.load_model("save/path", compile=False)
There is nothing fancy but some how it takes forever to load and does not raise any exception. Do you have any recommendation?
Upvotes: 0
Views: 83
Reputation: 31
The solution is;
best_acc_model = tf.keras.models.load_model("path/to/model")
best_acc_model.get_layer("conv_name")._name = "new_conv_name"
best_acc_model = tf.keras.Model(inputs=best_acc_model.input, outputs=best_acc_model.output)
best_acc_model.save("save/path")
Source: link to solution
Upvotes: 1