[英]Python Keras ValueError NeuralNetwork FlappyBird Game
I cloned the following Flappy-Bird
project ( https://github.com/yanpanlau/Keras-FlappyBird ) involving reinforcement learning
locally in my pc. 我克隆了以下
Flappy-Bird
项目( https://github.com/yanpanlau/Keras-FlappyBird ),涉及在我的电脑本地reinforcement learning
。 I installed the dependencies, but when I run it ( python qlearn.py -m "Run"
), I received the following error: 我安装了依赖项,但是当我运行它时(
python qlearn.py -m "Run"
),我收到以下错误:
/usr/local/lib/python2.7/dist-packages/skimage/viewer/__init__.py:6: UserWarning: Viewer requires Qt
warn('Viewer requires Qt')
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Using TensorFlow backend.
Now we build the model
We finish building the model
Now we load weight
Traceback (most recent call last):
File "qlearn.py", line 198, in <module>
main()
File "qlearn.py", line 195, in main
playGame(args)
File "qlearn.py", line 189, in playGame
trainNetwork(model,args)
File "qlearn.py", line 85, in trainNetwork
model.load_weights("model.h5")
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2701, in load_weights
self.load_weights_from_hdf5_group(f)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2787, in load_weights_from_hdf5_group
K.batch_set_value(weight_value_tuples)
File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 1544, in batch_set_value
assign_op = x.assign(assign_placeholder)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.py", line 575, in assign
return state_ops.assign(self._variable, value, use_locking=use_locking)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_state_ops.py", line 47, in assign
use_locking=use_locking, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2242, in create_op
set_shapes_for_outputs(ret)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1617, in set_shapes_for_outputs
shapes = shape_func(op)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1568, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
debug_python_shape_fn, require_shape_fn)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 675, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Dimension 0 in both shapes must be equal, but are 8 and 32 for 'Assign' (op: 'Assign') with input shapes: [8,8,80,32], [32,4,8,8].
By default, Keras uses tensorflow
as backend, so maybe the order of paramters can imply this error, but I couldn't figure it out. 默认情况下,
tensorflow
使用tensorflow
作为后端,因此参数的顺序可能意味着这个错误,但我无法弄明白。
The saved model is trained with "image_dim_ordering": "th"
. 保存的模型使用
"image_dim_ordering": "th"
训练。 I am pretty sure on your system currently its configured to tf
. 我很确定你的系统目前配置为
tf
。 Just open ~/.keras/keras.json
and change it to th
and the model should load properly. 只需打开
~/.keras/keras.json
并将其更改为th
,模型应正确加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.