强化学习的学习路线规划,尤其是代码练习指引

感觉没什么好的学习材料和网站,网上资料本就很少,有代码的更少,而且呢,这些代码还基本上都是TensorFlow1.x版本的,和2.x不兼容,需要修改
我想了想既然我一直在debug,那不如把这一篇文章写成一个debug集锦,也方便以后解决问题

error No1

Using TensorFlow backend.
Traceback (most recent call last):
  File "E:/Code/pythoprogram/Reinforcement-learning-with-tensorflow-master/contents/5_Deep_Q_Network/run_this.py", line 2, in <module>
    from RL_brain import DeepQNetwork
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 18, in <module>
    tf.set_random_seed(1)
AttributeError: module 'tensorflow' has no attribute 'set_random_seed'

solution No1

tf.random.set_seed(1)

error No2

Using TensorFlow backend.
Traceback (most recent call last):
  File "E:/Code/pythoprogram/Reinforcement-learning-with-tensorflow-master/contents/5_Deep_Q_Network/run_this.py", line 47, in <module>
    memory_size=2000,
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 54, in __init__
    self._build_net()
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 71, in _build_net
    self.s = tf.placeholder(tf.float32, [None, self.n_features], name='s')  # input
AttributeError: module 'tensorflow' has no attribute 'placeholder'

solution No2

self.s = tf.Variable(tf.zeros([None, self.n_features]), dtype=tf.float32, name='s')

error No3

Traceback (most recent call last):
  File "E:/Code/pythoprogram/Reinforcement-learning-with-tensorflow-master/contents/5_Deep_Q_Network/run_this.py", line 47, in <module>
    memory_size=2000,
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 54, in __init__
    self._build_net()
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 74, in _build_net
    with tf.variable_scope('eval_net'):
AttributeError: module 'tensorflow' has no attribute 'variable_scope'

solution No3

tf.compat.v1.variable_scope

error No4

Traceback (most recent call last):
  File "E:/Code/pythoprogram/Reinforcement-learning-with-tensorflow-master/contents/5_Deep_Q_Network/run_this.py", line 47, in <module>
    memory_size=2000,
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 54, in __init__
    self._build_net()
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 77, in _build_net
    ['eval_net_params', tf.GraphKeys.GLOBAL_VARIABLES], 10, \
AttributeError: module 'tensorflow' has no attribute 'GraphKeys'

solution No4

['eval_net_params', 'variables']

'variables’替换tf.GraphKeys.GLOBAL_VARIABLES

error No5

Traceback (most recent call last):
  File "E:/Code/pythoprogram/Reinforcement-learning-with-tensorflow-master/contents/5_Deep_Q_Network/run_this.py", line 47, in <module>
    memory_size=2000,
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 54, in __init__
    self._build_net()
  File "E:\Code\pythoprogram\Reinforcement-learning-with-tensorflow-master\contents\5_Deep_Q_Network\RL_brain.py", line 82, in _build_net
    w1 = tf.get_variable('w1', [self.n_features, n_l1], initializer=w_initializer, collections=c_names)
AttributeError: module 'tensorflow' has no attribute 'get_variable'

solution No5

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

问题成环了,这就是死循环啊
回到了error No1

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值