Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving and Restoring a trained LSTM in Tensor Flow

I trained a LSTM classifier, using a BasicLSTMCell. How can I save my model and restore it for use in later classifications?

like image 482
Marcello S Avatar asked Nov 05 '16 19:11

Marcello S


People also ask

How do I save a Lstm model in Tensorflow?

In order to save the model and the weights use the model's save() function.

How do you save a Tensorflow trained model?

Call tf. keras. Model. save to save a model's architecture, weights, and training configuration in a single file/folder .

How do I save and restore model in Tensorflow?

To save and restore your variables, all you need to do is to call the tf. train. Saver() at the end of you graph. This will create 3 files ( data , index , meta ) with a suffix of the step you saved your model.

How do you save a trained neural network model?

Save Your Neural Network Model to JSON This can be saved to a file and later loaded via the model_from_json() function that will create a new model from the JSON specification. The weights are saved directly from the model using the save_weights() function and later loaded using the symmetrical load_weights() function.


1 Answers

We found the same issue. We weren't sure if the internal variables were saved. We found out that you must create the saver after the BasicLSTMCell is created /defined. Otherewise it is not saved.

like image 161
Jeronimo Garcia-Loygorri Avatar answered Sep 28 '22 17:09

Jeronimo Garcia-Loygorri