Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using the ppo with Cartpole #4

Closed
EliottEccidio opened this issue Jul 11, 2023 · 1 comment
Closed

Issue when using the ppo with Cartpole #4

EliottEccidio opened this issue Jul 11, 2023 · 1 comment

Comments

@EliottEccidio
Copy link

Hi sorry to bother you,

I was trying to run the the code from your wideo with Weights & Biases but I have errors when I want to run it. First of all there isn't a seed attribute for the env. To replace env.seed(seed) I have used :

env.reset(seed=seed)

Now I have an issue with:

next_obs = torch.Tensor(envs.reset()).to(device)
# Returns the error:
ValueError: expected sequence of length 4 at dim 1 (got 0)

To try and resolve it I print the tupple and converted it into an array before converting it into a Tensor :

env_reset_ar = np.asarray(envs.reset(), dtype=tuple)
next_obs = torch.Tensor(env_reset_ar).to(device) # store the initial obs 
#With env.reset() : 

#[[-0.01702683  0.02884287 -0.01968052 -0.00465021]
# [-0.00673692  0.01692973 -0.00772153  0.01331844]
# [-0.0069372   0.00867986  0.02378378  0.04562673]
# [-0.00695037  0.02889467  0.0484153  -0.01302742]]
#{} 

# But Now I have the  Error :
next_obs = torch.Tensor(env_reset_ar).to(device) # store the initial obs 
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

Do you know what do I need to change to make it work ? I am still a beginner at RL so I don't know what have I done wrong.
Thank you in advance.

Kind regards,
Eliott.

@thivyanth
Copy link

next_obs = torch.Tensor(envs.reset()[0]).to(device)
has worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants