Skip to content

Error - possibly due to "Variable()" ? #22

@joleeson

Description

@joleeson

Hi, many thanks for sharing the code.

I have experienced an error running 1.dqn straight out of the box. The error message shown after I run the 12th cell of code is as shown below.

My computer is running with PyTorch 0.4.1, and I suspect that the error is due to a change in the "Variable" API (as used in cells 8 and 10 for example)? If so, has anyone updated the code for the latest PyTorch 0.4.1?

Any ideas would be appreciated! Thanks in advance!


Error message after cell 12:


/home/USER/anaconda3/envs/RL/lib/python3.7/site-packages/ipykernel_launcher.py:2: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.


AssertionError Traceback (most recent call last)
in ()
12 action = model.act(state, epsilon)
13
---> 14 next_state, reward, done, _ = env.step(action)
15 replay_buffer.push(state, action, reward, next_state, done)
16

~/anaconda3/envs/RL/lib/python3.7/site-packages/gym/wrappers/time_limit.py in step(self, action)
29 def step(self, action):
30 assert self._episode_started_at is not None, "Cannot call env.step() before calling reset()"
---> 31 observation, reward, done, info = self.env.step(action)
32 self._elapsed_steps += 1
33

~/anaconda3/envs/RL/lib/python3.7/site-packages/gym/envs/classic_control/cartpole.py in step(self, action)
52
53 def step(self, action):
---> 54 assert self.action_space.contains(action), "%r (%s) invalid"%(action, type(action))
55 state = self.state
56 x, x_dot, theta, theta_dot = state

AssertionError: tensor(0) (<class 'torch.Tensor'>) invalid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions