My keras model is saved in google storage with model.save(model_name)
I cannot load the model on pydatalab. When I save the model on my local machine, I can just ope
The following function works for retraining an already trained keras model (with new data) on gcloud machine learning platform (Thanks to Tíarnán McGrath).
def load_models(model_file):
model = conv2d_model() #the architecture of my model, not compiled yet
file_stream = file_io.FileIO(model_file, mode='r')
temp_model_location = './temp_model.h5'
temp_model_file = open(temp_model_location, 'wb')
temp_model_file.write(file_stream.read())
temp_model_file.close()
file_stream.close()
model.load_weights(temp_model_location)
return model
For some reason, load_model
from keras.models
does not work for me anymore, so I have to build the model each time.