dd2 dd2 - 1 month ago 24
Python Question

Tensorflow: method to save and restore TensorFlowEstimator()

How to save and load this object (

regressor
)?

from tensorflow.contrib import learn
regressor = learn.TensorFlowEstimator()


I could not use tensorflow's default Saver() to save it.

How to do incremental learning with this model? I am confused about
continue_training
parameter in its constructor. It says you can call fit again and again with new data. And at the same time it provides
partial_fit()
. Please help me understand ?

Answer

According to this TF tutorial, the following should work:

for saving:

regressor.save('/tmp/tf_examples/my_model_1/')

for restoring:

new_regressor = TensorFlowEstimator.restore('/tmp/tf_examples/my_model_2')