发布于2019-08-07 12:26 阅读(1424) 评论(0) 点赞(2) 收藏(4)
1、原始版本
import tensorflow as tf
print(tf.__version__)
1.13.1
2、安装TensorFlow2.0
pip install tensorflow==2.0.0-beta0
2.1 Cannot uninstall 'wrapt'.
解决:
pip install -U --ignore-installed wrapt enum34 simplejson netaddr
2.2 Consider using the `--user` option or check the permissions.
pip install tensorflow==2.0.0-beta0 --user
3 graphviz加载不上
用:conda install graphviz
tensorflow模型的加载和训练
saver=tf.train.Saver(max_to_keep=1)##保留最新的模型
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
ckpt = tf.train.get_checkpoint_state('E:/201904/tensorflow_base/model/')
# 这两个函数之间最大的区别是当父目录不存在的时候os.mkdir(path)不会创建,#os.makedirs(path)则会创建父目录。
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess,ckpt.model_checkpoint_path)
###
saver.save(sess,os.path.join(path,model_name))
tf.train.Saver(
['var_list=None', 'reshape=False', 'sharded=False', 'max_to_keep=5', 'keep_checkpoint_every_n_hours=10000.0', 'name=None', 'restore_sequentially=False', 'saver_def=None', 'builder=None', 'defer_build=False', 'allow_empty=False', 'write_version=2', 'pad_step_number=False', 'save_relative_paths=False', 'filename=None'],
)
官方例子:
saver = tf.train.Saver(...variables...)
# Launch the graph and train, saving the model every 1,000 steps.
sess = tf.Session()
for step in xrange(1000000):
sess.run(..training_op..)
if step % 1000 == 0:
# Append the step number to the checkpoint name:
saver.save(sess, 'my-model', global_step=step)
作者:没事就吃溜溜梅
链接:https://www.pythonheidong.com/blog/article/10783/fc5837777c23117402b6/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!