Tensorflow: How to restore a previously saved model (python)
2017-02-21 17:12
477 查看
In( and After) TensorFlow version 0.11.0RC1, you can save and restore your model directly by calling
https://www.tensorflow.org/programmers_guide/meta_graph
save model:
restore model:
tf.train.export_meta_graphand
tf.train.import_meta_graphaccording to
https://www.tensorflow.org/programmers_guide/meta_graph
save model:
w1 = tf.Variable(tf.truncated_normal(shape=[10]), name='w1') w2 = tf.Variable(tf.truncated_normal(shape=[20]), name='w2') tf.add_to_collection('vars', w1) tf.add_to_collection('vars', w2) saver = tf.train.Saver() sess = tf.Session() sess.run(tf.global_variables_initializer()) saver.save(sess, 'my-model') # `save` method will call `export_meta_graph` implicitly. # you will get saved graph files:my-model.meta
restore model:
sess = tf.Session() new_saver = tf.train.import_meta_graph('my-model.meta') new_saver.restore(sess, tf.train.latest_checkpoint('./')) all_vars = tf.get_collection('vars') for v in all_vars: v_ = sess.run(v) print(v_)
相关文章推荐
- TensorFlow: How to freeze a model and serve it with a python API
- [翻译]斯坦福CS 20SI:基于Tensorflow的深度学习研究课程笔记,Lecture note 4: How to structure your model in TensorFlow
- How to Save an ARIMA Time Series Forecasting Model in Python (如何在Python中保存ARIMA时间序列预测模型)
- [转]How to copy Microsoft.ReportViewer.ProcessingObjectModel.dll to bin folder of your project
- How to install python before insalling mpich2
- mojoportal学习笔记之How to Write a Provider Model
- How to Use UTF-8 with Python python中使用utf-8
- How to restore deleted user accounts and their group memberships in Active Directory
- HowTo Restore RMAN Disk backups of RAC Database to Single Instance On Another Node
- How to Build an Economic Model in Your Spare Time (如何利用业余时间建立经济模型)
- centos howto yum install mysql-python
- how to debug python script
- Applications Programming in Smalltalk-80(TM):How to use Model-View-Controller (MVC)
- How to backup and restore data and e-mail account settings in Outlook 2007
- How to setup django, python environment in ubuntu
- (转)How to use the ASP.NET MVC ModelBinder
- How to migrate from code-centric to model-centric development using Rational Software Architect
- How to make business domain model
- How to Write a Provider Model
- How to design your model