首页 > 其他 > 详细

强化学习代码过程中遇到的问题汇总

时间:2021-04-09 16:12:56      阅读:35      评论:0      收藏:0      [点我收藏+]

tensorflow报错,版本问题。高版本到低版本使用:

import tensorflow.compat.v1 as tf

 

tf.placeholder() is not compatible with eager execution. 

2.0版本出现,加一句代码即可

tf.compat.v1.disable_eager_execution()

 

如何读取tensorflow训练好的模型

saver = tf.train.Saver()
with tf.Session() as sess:

print("从指定的路径中加载模型。。。。")            # 将模型加载到sess 中

ckpt = tf.train.get_checkpoint_state(logs_train_dir)

if ckpt and ckpt.model_checkpoint_path:

    global_step = ckpt.model_checkpoint_path.split(/)[-1].split(-)[-1]

    saver.restore(sess, ckpt.model_checkpoint_path)

我们是这样做的

saver = tf.train.Saver()
sess.run(tf.initialize_all_variables())
checkpoint = tf.train.get_checkpoint_state("saved_networks")  

#model_checkpoint_path保存了最新的tensorflow模型文件的文件名
if checkpoint and checkpoint.model_checkpoint_path:
saver.restore(sess, checkpoint.model_checkpoint_path)
print("Successfully loaded:", checkpoint.model_checkpoint_path)
else:
print("Could not find old network weights")

 

强化学习代码过程中遇到的问题汇总

原文:https://www.cnblogs.com/snailbuster/p/14637165.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!