I taught the model via
if __name__ == "__main__":
env = CustomEnv(possible_action_clicks)
check_env(env)
policy_kwargs = dict(
net_arch=dict(pi=[2048, 1024, 512], vf=[2048, 1024, 512]),
activation_fn=torch.nn.GELU,
optimizer_class=optim.RAdam,
)
model = PPO('MlpPolicy', env, verbose=0, tensorboard_log=logdir, device='cuda', batch_size=2000,
policy_kwargs=policy_kwargs, ent_coef=0.1, learning_rate=0.00001, gamma=0.9,
use_sde=True)
TIMESTEPS = 100000
vec_env = model.get_env()
observation = vec_env.reset()
done = False
while not done:
model.learn(total_timesteps=TIMESTEPS, reset_num_timesteps=False, tb_log_name=f"PPO")
model.save(f"{models_dir}/model_{int(time.time())}")
action, _ = model.predict(observation)
observation, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
vec_env = model.get_env()
observation = vec_env.reset()
but when I try to load, it always retruns 1 in every prediction
model_path = "D:/modelsPPO/1722422450/model_1722458138.zip"
model = PPO('MlpPolicy', env, verbose=0, tensorboard_log=logdir, device='cuda', batch_size=2000,
policy_kwargs=policy_kwargs, ent_coef=0.1, learning_rate=0.00001, gamma=0.9,
use_sde=True)
# Load the model with the environment
env = CustomEnv(possible_action_clicks)
model = model.load(model_path, env=env, verbose=1) c
Could you help me with that?
I have tried different load methods, but all failed
New contributor
Xardas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.