mknbv / derl

derl is a DEep Reinforcement Learning package
MIT License
8 stars 3 forks source link

ValueError: if of type tf.Variable, value must be scalar and have dtype tf.int64, got shape () and dtype <dtype: 'int64_ref'> instead #1

Closed Meleshkova closed 3 years ago

Meleshkova commented 3 years ago

Hi, I experience following error while trying to setup the project

Traceback (most recent call last):
  File "run-mujoco.py", line 55, in <module>
    main()
  File "run-mujoco.py", line 50, in main
    learner = derl.PPOLearner.from_env_args(env, args, model=model)
  File "/Users/macbook/projects/zzz/nod/neuralode-rl/derl/derl/base.py", line 99, in from_env_args
    runner = cls.make_runner(env, args, model=model)
  File "/Users/macbook/projects/zzz/nod/neuralode-rl/derl/derl/scripts/ppo.py", line 60, in make_runner
    **runner_kwargs)
  File "/Users/macbook/projects/zzz/nod/neuralode-rl/derl/derl/runners.py", line 135, in make_ppo_runner
    runner = EnvRunner(env, policy, num_runner_steps, transforms=transforms)
  File "/Users/macbook/projects/zzz/nod/neuralode-rl/derl/derl/runners.py", line 15, in init
    super().__init__(env, policy, step_var)
  File "/Users/macbook/projects/zzz/nod/neuralode-rl/derl/derl/base.py", line 20, in init
    tf.train.create_global_step())
  File "/Users/macbook/projects/zzz/nod/neuralode-rl/derl/derl/train.py", line 13, in init
    raise ValueError("if of type tf.Variable, value must be scalar "

ValueError: if of type tf.Variable, value must be scalar and have dtype tf.int64, got shape () and dtype <dtype: 'int64_ref'> instead

If you could help me to find out what I do wrong? Thanks for your time and attention. Any help is greatly appreciated

mknbv commented 3 years ago

Thank you for trying out the project and raising the issue!

Unfortunately, I was not able to reproduce this error but I am only able to run it with roboschool environments at the moment. Could you please check if eager execution is enabled when you run the code? To me it seems that tf.train.create_global_step() returns tf.Variable with dtype int64_ref when eager execution is not enabled and this is what is happening here based on the log you have posted. At the same time I would also check if the version of tensorflow you are running is correct: python -c "import tensorflow as tf; print(tf.__version__)" should give 1.13.1.

Meleshkova commented 3 years ago

Sorry for taking so long to get back to you. It looks like tensorflow version problem indeed. Thank you for your help.