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

Setting up seed properly in Custom env #1061

Closed
Chainesh opened this issue May 22, 2024 · 1 comment
Closed

Setting up seed properly in Custom env #1061

Chainesh opened this issue May 22, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Chainesh
Copy link

Question

`# Create the training environment
train_env = gym.make("BabyAI-GoToLocal-v0",max_episode_steps= 512)#, render_mode = "human")
train_env = RGBImgPartialObsWrapper(train_env)
train_env = CustomEnv(train_env, mission)
train_env = ImgObsWrapper(train_env)
train_env = Monitor(train_env)
train_env = DummyVecEnv([lambda: train_env])
train_env = VecTransposeImage(train_env)

Create the evaluation environment

eval_env = gym.make("BabyAI-GoToLocal-v0", max_episode_steps= 512)#, render_mode = "human")
eval_env = RGBImgPartialObsWrapper(eval_env)
eval_env = CustomEnv(eval_env,mission)
eval_env = ImgObsWrapper(eval_env)
eval_env = Monitor(eval_env)
eval_env = DummyVecEnv([lambda: eval_env])
eval_env = VecTransposeImage(eval_env)

save_path = f"main_code/New_model/PPO/{mission.replace(' ', '_')}_model"
eval_callback = EvalCallback(eval_env, callback_on_new_best=stop_callback, eval_freq=8192,
best_model_save_path=save_path, verbose=1, n_eval_episodes= 30)

model = PPO("CnnPolicy", train_env, policy_kwargs=policy_kwargs, verbose=1,
learning_rate=0.0005, tensorboard_log="./logs/PPO2/",
batch_size= 2048,
n_epochs= 100, seed = 42)

model.learn(2.5e6, callback=eval_callback)

Close the environments

train_env.close()
eval_env.close()`

I'm trying to train babyai env on specific instructions, but while setting up the seed it gets stuck on first frame and doesn't do anything. The issue seems to be with Custom env because when I run the code without it, the seed works fine. Help from the community would be much appreciated :)

@Chainesh Chainesh added the question Further information is requested label May 22, 2024
@pseudo-rnd-thoughts
Copy link
Member

This appears like a sb3 issue rather than Gymnasium, could you clarify what the Gymnasium issue is?

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

No branches or pull requests

3 participants