tokb23 / dqn

DQN implementation in Keras + TensorFlow + OpenAI Gym
158 stars 58 forks source link

error in running dqn and ddqn #5

Open Exception4U opened 6 years ago

Exception4U commented 6 years ago

 python ddqn.py I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally Using TensorFlow backend. [2017-09-21 01:21:23,391] Making new env: Breakout-v0 ddqn.py:90: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(32, (8, 8), strides=(4, 4), activation="relu", input_shape=(4, 84, 84...) model.add(Convolution2D(32, 8, 8, subsample=(4, 4), activation='relu', input_shape=(STATE_LENGTH, FRAME_WIDTH, FRAME_HEIGHT))) Traceback (most recent call last): File "ddqn.py", line 314, in main() File "ddqn.py", line 277, in main agent = Agent(num_actions=env.action_space.n) File "ddqn.py", line 58, in init self.s, self.q_values, q_network = self.build_network() File "ddqn.py", line 90, in build_network model.add(Convolution2D(32, 8, 8, subsample=(4, 4), activation='relu', input_shape=(STATE_LENGTH, FRAME_WIDTH, FRAME_HEIGHT))) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/keras/models.py", line 442, in add layer(x) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/keras/engine/topology.py", line 602, in call output = self.call(inputs, **kwargs) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/keras/layers/convolutional.py", line 164, in call dilation_rate=self.dilation_rate) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 3164, in conv2d data_format='NHWC') File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 640, in convolution op=op) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 309, in with_space_to_batch return op(input, num_spatial_dims, padding) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 632, in op name=name) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 130, in _non_atrous_convolution name=name) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 396, in conv2d data_format=data_format, name=name) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op op_def=op_def) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2242, in create_op set_shapes_for_outputs(ret) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1617, in set_shapes_for_outputs shapes = shape_func(op) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1568, in call_with_requiring return call_cpp_shape_fn(op, require_shape_fn=True) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn debug_python_shape_fn, require_shape_fn) File "/home/tushar/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 675, in _call_cpp_shape_fn_impl raise ValueError(err.message) ValueError: Negative dimension size caused by subtracting 8 from 4 for 'conv2d_1/convolution' (op: 'Conv2D') with input shapes: [?,4,84,84], [8,8,84,32].

huiofficial commented 6 years ago

run into the same error with dqn.py, any idea? @Exception4U @tokb23

Exception4U commented 6 years ago

I think updating ur keras API should solve problem pip install --upgrade keras

huiofficial commented 6 years ago

As I upgraded, I still have the same error: raise ValueError(err.message) ValueError: Negative dimension size caused by subtracting 8 from 4 for 'conv2d_1/convolution' (op: 'Conv2D') with input shapes: [?,4,84,84], [8,8,84,32]. @Exception4U

Exception4U commented 6 years ago

Ohhh !!! in that can you post your ~/.kerasrc file?

On Mon, Oct 23, 2017 at 12:11 PM, 仲耀晖 notifications@github.com wrote:

As I upgraded, I still have the same error: raise ValueError(err.message) ValueError: Negative dimension size caused by subtracting 8 from 4 for 'conv2d_1/convolution' (op: 'Conv2D') with input shapes: [?,4,84,84], [8,8,84,32]. @Exception4U https://mailtrack.io/trace/link/b03e27a1cba86998563934167fbc8a3357cff2b8?url=https%3A%2F%2Fgithub.com%2Fexception4u&userId=612199&signature=928106dbadcf321a

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://mailtrack.io/trace/link/0626a02ef0e2d92cc1e2fc686a4aa8b2eb6e6c40?url=https%3A%2F%2Fgithub.com%2Ftokb23%2Fdqn%2Fissues%2F5%23issuecomment-338561892&userId=612199&signature=e300aa1a7bbfe863, or mute the thread https://mailtrack.io/trace/link/6df9af4a75c4ebb02542627b28e57251229949d1?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFQLVZosgLU19OlMD66g-P8itYpWbQrkks5svDU1gaJpZM4PeYu9&userId=612199&signature=ca7dc8d287ebdbf6 .

Exception4U commented 6 years ago

sorry actually ~/.keras/keras.json this file

On Mon, Oct 23, 2017 at 5:13 PM, tushar vaidya tushar5610@gmail.com wrote:

Ohhh !!! in that can you post your ~/.kerasrc file?

On Mon, Oct 23, 2017 at 12:11 PM, 仲耀晖 notifications@github.com wrote:

As I upgraded, I still have the same error: raise ValueError(err.message) ValueError: Negative dimension size caused by subtracting 8 from 4 for 'conv2d_1/convolution' (op: 'Conv2D') with input shapes: [?,4,84,84], [8,8,84,32]. @Exception4U https://mailtrack.io/trace/link/cfc7f728d027a5bf244c7c7802283b6b2e66cf59?url=https%3A%2F%2Fgithub.com%2Fexception4u&userId=612199&signature=e480171361c7d38a

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://mailtrack.io/trace/link/582a538bcca7ee569fd31bd7c31a675ac5a6e5c4?url=https%3A%2F%2Fgithub.com%2Ftokb23%2Fdqn%2Fissues%2F5%23issuecomment-338561892&userId=612199&signature=155e57a478490483, or mute the thread https://mailtrack.io/trace/link/64e596bd62075ef98ea4190f40e76371432712c6?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFQLVZosgLU19OlMD66g-P8itYpWbQrkks5svDU1gaJpZM4PeYu9&userId=612199&signature=29630f5386b498dc .

impulsecorp commented 6 years ago

I get that same error, even after I change my keras.json file to { "image_dim_ordering": "th", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"

Exception4U commented 6 years ago

May be you refer here https://stackoverflow.com/questions/41651628/negative-dimension-size-caused-by-subtracting-3-from-1-for-conv2d and change function call

On Thu, Jan 18, 2018 at 12:41 AM, impulsecorp notifications@github.com wrote:

I get that same error, even after I change my keras.json file to { "image_dim_ordering": "th", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tokb23/dqn/issues/5#issuecomment-358410269, or mute the thread https://github.com/notifications/unsubscribe-auth/AFQLVZHYXyVxFoGjh221oexDNeamOqk6ks5tLkXQgaJpZM4PeYu9 .

Exception4U commented 6 years ago

parallelly I would encourage to use this fork as original author did not merge pull request.

https://github.com/Exception4U/dqn-1

ShanHaoYu commented 6 years ago

just did the above mentioned :

from keras import backend as K K.set_image_dim_ordering('th')

and it works for me :)