tensorflow - 'Model' object has no attribute 'load_model' keras -
i'm trying load model saved with: model.save('mymodel.h5')
the model defined this:
self.model = vggface(input_tensor=input_tensor, include_top=true) layer in self.model.layers: layer.trainable = false self.model.get_layer('fc7').trainable = true last_layer = self.model.get_layer('fc7').output out = batchnormalization()(last_layer) out = dense(self.n_outputs, activation='softmax', name='fc8')(out) self.model = model(input=self.model.input, output=out) when try load mymodel.h5 model.load_model('mymodel.h5') throws me following error:
attributeerror: 'model' object has no attribute 'load_model' i supose it's because i'm not working sequential models.
how can load model then? since model.save('mymodel.h5') seems work.
thanks!!!!
load_model() isn't attribute of model obejct indeed. load_model() function imported keras.models takes file name , returns model obejct.
you should use :
from keras.models import load_model model = load_model(path_to_model) you can use keras.models.load_model(filepath) reinstantiate model. load_model take care of compiling model using saved training configuration (unless model never compiled in first place). from source
Comments
Post a Comment