huggingface/deep-rl-class

[UPDATE] untit1 hands on - add " render_mode='rgb_array' " to gym.make when initiating eval_env

mohamedsaeed8223 opened this issue · 4 comments

What do you want to improve?

unit1 hands on

  • Explain the typo/error or the part of the course you want to improve
    I encountered the error "AssertionError: The render_mode must be 'rgb_array', not None" when I tried pushing my agent to the hf hub.
    to avoid this, we should add " render_mode='rgb_array' " in gym.make when initiating the eval_env
    so the entire code cell should be :
# Create a new environment for evaluation
eval_env = Monitor(gym.make("LunarLander-v2", render_mode='rgb_array'))

# Evaluate the model with 10 evaluation episodes and deterministic=True
mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes=10, deterministic=True)

# Print the results
print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")

Hi, I just tested and it works without adding it. Did you used the colab 🤔 ?

I was mainly trying to type the code myself.
also when I tried opening up a pull request the code here on github already had the "render_mode='rgb_array' " part but not on the huggingface website

I see, we may have updated the colab but forgot the website version. If you want you can open a PR with the update on the website version?

I just did, also in the cell where we push to the hub, I just saw this line for the first time eval_env = DummyVecEnv([lambda: Monitor(gym.make(env_id, render_mode="rgb_array"))]) which probably was what was missing in my code.
does specifying a render mode in the first initialization of eval_env hurt? maybe does use a little more compute for the RGB rendering.