HUJI-Deep / simnets-tf

SimNets implementation in TensorFlow
MIT License
7 stars 3 forks source link

Issue with save/load model in Keras #16

Closed orsharir closed 7 years ago

orsharir commented 7 years ago

I've stumble upon a usability bug with using our layers with Keras. The save/load model functions don't play well with our layers, even when I'm using the custom_objects optional argument. To reproduce simply build a model composed of our layers, followed by saving the model, and then loading it, e.g.:

import keras
import simnets as sk

model = # Create some model built with our layers
model.save_model('test.hdf5')

custom_objects= {
    'Similarity': sk.Similarity,
    'Mex': sk.Mex
}
loaded_model = keras.models.load_model('test.hdf5', custom_objects=custom_objects)

Despite the above, saving and loading just the weights does work well, so there is a temporary workaround.

elhanan7 commented 7 years ago

I think I fixed this. Hopefully if you import simnets.keras before loading you don't even need to specify the custom objects. I still fail to load the model, the Lambda layers fail to load. Maybe it is a keras bug?