Closed mabedd closed 2 years ago
@mohammed-ab99 You can actually save the entire siamese model and load it and extract the layer with desired trained layers and create a new model with a new input layer and the extracted layer. Please take a look at this explanation here. Thanks!
This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.
I am working on a Siamese Neural Network with custom Triplet Loss function. As far as I learned from the documentations, we will train a complete network but we want to save only the CNN that is used for embeddings extraction to use it later on with a classifier such as KNN or another.
Network Architeture:
CNN Architecture that is used for embeddings extraction:
I trained the whole network and used
base_model.predict()
to extract the embeddings. Now , I want to save only the base_model with its learned config during the training. I came across a code on Kaggle through Github Issues that is used for this purpose, I used it and it worked just fine but it gave me a Warning that made me afraid a little bit: [(https://www.kaggle.com/shanmukh05/embeddindgs-extraction-from-siamesemodel)] [(https://github.com/keras-team/keras/issues/8748)]embed_model.save('/content/gdrive/MyDrive/RIOTU/projects/snn_upper_face_recognition/tensorflow/colab_outputs/riotu-upper-facenet-tiny.h5')
WARNING:tensorflow:Compiled the loaded model, but the compiled metrics have yet to be built. model.compile_metrics will be empty until you train or evaluate the model.
When I load the model again with
load_model
I got this warning also:WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.
Now is this ok or I am missing something while saving the model ? and what is the appropriate way to save a Triplet Loss Network ?