关于Flappy Bird代码遇到的一些问题
(第一次写有点小紧张啊)
运行环境:win10+Python3.8
tensorflow版本为2.0,也是因为版本问题,出现了以下各种各样的问题,报错没保存,将就记录一下过程。
1、tf.truncated_normal()改为tf.compat.v1.random.truncated_normal()
2、tf.placeholder()改为tf.compat.v1.placeholder()
3、reduce_sum()函数中的参数reduction_indicesaxis已经废弃,改为axis
4、tf.AdamOptimizer()改为tf.compat.v1.train.AdamOptimizer()
5、tf.train.Saver()改为tf.compat.v1.train.Saver()
6、tf.initialize_all_variables()改为tf.compat.v1.global_variables_initializer()
7、eval()里添加session=sess
readout_t = readout.eval(feed_dict={s : [s_t]})[0]
a_t = np.zeros([ACTIONS])
改为readout_t = readout.eval(session=sess,feed_dict={s : [s_t]})[0] a_t = np.zeros([ACTIONS])
8、tf.InteractiveSession()改为tf.compat.v1.Session()
修改上面几个问题后,能成功运行。