openai / baselines

OpenAI Baselines: high-quality implementations of reinforcement learning algorithms
MIT License
15.82k stars 4.88k forks source link

InvalidArgumentError occured when visualizing the trained model #98

Open ZhuoranYang opened 7 years ago

ZhuoranYang commented 7 years ago

I was wondering why there is an InvalidArgumentError every time I try to visualize the trained model. I downloaded model-atari-breakout-1 and evaluate by

python -m baselines.deepq.experiments.atari.enjoy --model-dir /tmp/models/model-atari-breakout-1/ --env Breakout

and got the following error

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [4] rhs shape= [6]
     [[Node: save/Assign_3 = Assign[T=DT_FLOAT, _class=["loc:@deepq/q_func/action_value/fully_connected_1/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](deepq/q_func/action_value/fully_connected_1/biases, save/RestoreV2_3)]]

The full error message is as follows.

[2017-08-13 22:37:55,313] Making new env: BreakoutNoFrameskip-v4
Traceback (most recent call last):
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1139, in _do_call
    return fn(*args)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1121, in _run_fn
    status, run_metadata)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/contextlib.py", line 88, in __exit__
    next(self.gen)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [4] rhs shape= [6]
     [[Node: save/Assign_3 = Assign[T=DT_FLOAT, _class=["loc:@deepq/q_func/action_value/fully_connected_1/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](deepq/q_func/action_value/fully_connected_1/biases, save/RestoreV2_3)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/baselines/deepq/experiments/atari/enjoy.py", line 69, in <module>
    U.load_state(os.path.join(args.model_dir, "saved"))
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/baselines/common/tf_util.py", line 273, in load_state
    saver.restore(get_session(), fname)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1548, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 789, in run
    run_metadata_ptr)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 997, in _run
    feed_dict_string, options, run_metadata)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1132, in _do_run
    target_list, options, run_metadata)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [4] rhs shape= [6]
     [[Node: save/Assign_3 = Assign[T=DT_FLOAT, _class=["loc:@deepq/q_func/action_value/fully_connected_1/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](deepq/q_func/action_value/fully_connected_1/biases, save/RestoreV2_3)]]

Caused by op 'save/Assign_3', defined at:
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/baselines/deepq/experiments/atari/enjoy.py", line 69, in <module>
    U.load_state(os.path.join(args.model_dir, "saved"))
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/baselines/common/tf_util.py", line 272, in load_state
    saver = tf.train.Saver()
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1139, in __init__
    self.build()
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1170, in build
    restore_sequentially=self._restore_sequentially)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 691, in build
    restore_sequentially, reshape)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 419, in _AddRestoreOps
    assign_ops.append(saveable.restore(tensors, shapes))
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 155, in restore
    self.op.get_shape().is_fully_defined())
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 271, in assign
    validate_shape=validate_shape)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 45, in assign
    use_locking=use_locking, name=name)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2506, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/Users/zhuoranyang/miniconda3/envs/env_ts_py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1269, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [4] rhs shape= [6]
     [[Node: save/Assign_3 = Assign[T=DT_FLOAT, _class=["loc:@deepq/q_func/action_value/fully_connected_1/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](deepq/q_func/action_value/fully_connected_1/biases, save/RestoreV2_3)]]

Anyone has the same error? Any comment would be appreciated!

zeyu42 commented 7 years ago

Exactly the same problem here!

zeyu42 commented 7 years ago

I'm on Anaconda 3 with Python 3.5. I installed the opencv package through pip install opencv-python. Tensorflow version 1.3.0.

xoffey commented 6 years ago

It seems that this issue has now been raised 3 times on this issueboard and has been closed twice without the defect being fixed.

kdu4108 commented 6 years ago

Same issue here--has anyone figured out a solution?