<jupyter_start><jupyter_text>model.save(ppo_model_save_path)<jupyter_code>model.save(ppo_model_save_path)
del model
model = PPO.load(ppo_model_save_path, env=env)<jupyter_output><empty_output><jupyter_text>model is to be loaded via ppo<jupyter_code>model
evaluate_policy(model, env, n_eval_episodes=10, render=False)
episoids = 10 
for i in range(1, episoids+1):
    obs = env.reset()
    done = False
    score = 0
    
    while not done:
#         env.render()
        action, _ = model.predict(obs)
        obs, reward, done, info = env.step(action)
        score += reward
    print('Episoides:{} reward:{}'.format(i, reward))
env.close()
# adding a callback to training stage
from stable_baselines3.common.callbacks import EvalCallback, StopTrainingOnRewardThreshold
best_model_path = os.path.join(os.getcwd(), 'models')
stop_callback = StopTrainingOnRewardThreshold(reward_threshold=190, verbose=1)
eval_calback = EvalCallback(env,
                           callback_on_new_best=stop_callback,
                           eval_freq=10000,
                           best_model_save_path=best_model_path,
                           verbose=1)
model_second = PPO('MlpPolicy', env, verbose=1, tensorboard_log=log_path)
model_second.learn(total_timesteps=60000, callback=eval_calback)<jupyter_output>Logging to /home/melodic/main-workspace/src/rl_ros/logs/PPO_2
-----------------------------
| time/              |      |
|    fps             | 857  |
|    iterations      | 1    |
|    time_elapsed    | 2    |
|    total_timesteps | 2048 |
-----------------------------
-----------------------------------------
| time/                   |             |
|    fps                  | 580         |
|    iterations           | 2           |
|    time_elapsed         | 7           |
|    total_timesteps      | 4096        |
| train/                  |             |
|    approx_kl            | 0.008876848 |
|    clip_fraction        | 0.109       |
|    clip_range           | 0.2         |
|    entropy_loss         | -0.686      |
|    explained_variance   | 0.000451    |
|    learning_rate        | 0.0003      |
|    loss                 | 7           |
|    n_updates            | 10          |
|    policy_gradient_loss | -0.0162     |
|    value_loss           | 51.9        |
--------------[...]
{'fraction_non_alphanumeric': 0.14428076256499134, 'fraction_numerical': 0.03726169844020797, 'mean_word_length': 1.5973003374578179, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '536873', 'license': 'MIT', 'n_tokens_mistral': 786, 'n_tokens_neox': 713, 'n_words': 117, 'path': 'cartpole.ipynb', 'repo_name': 'shivam675/deep-rl-exercises', 'size': '2308'}