#Use other trained model's weights?

4 messages · Page 1 of 1 (latest)

severe oak
#

hello, i didnt use the save_weights function to save weights. I just saved the whole model. I want to use the weights from that model and use it on my new model, I looked it up on stackoverflow but when I check the model.summary() it gives me the structure of the previous model.

model = Sequential()

model.compile(optimizer=Adam(learning_rate=0.001),loss='categorical_crossentropy',metrics=['accuracy'])
model = tf.keras.models.load_model("/kaggle/input/bestmodel/CNN_Model-(64, 64, 1)-1670238819", compile=False)

model.summary()```
dense geode
#

model.summary() shows you an overview of the architecture, and only gives you an indication on the number of parameters in a model. Let's say you define your model as trainer which has been trained on your general dataset. When you saved the model, you most likely saved it as a SavedModel object in Tensorflow. You can define a second, untrained model called student and then use the tf.saved_model.load() and pass in the save path to where you saved trainer . Now you can finetune this model and save it as well (be sure to use a different save path, or you will override your original saved model file). You can find more information on Saved Models as well as saving and loading custom tensorflow/keras models here:
https://www.tensorflow.org/tutorials/keras/save_and_load
https://www.tensorflow.org/guide/saved_model
https://www.tensorflow.org/guide/keras/save_and_serialize

nocturne ridge