How can I use a weight matrix created by a trained neural network to make predictions in another file?

Save your model or the weights of your model:

model.save(filename)
np.save(filename, model.get_weights())

For loading, in the first case:

from keras.models import load_model
model = load_model(filename)

In the second case:

#recreate the model then:
model.set_weights(np.load(filename))

Then:

results = model.predict(batch_of_data)

Browse More Popular Posts

Leave a Comment