question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to display training results with stable-baselines3

See original GitHub issue

Hi all,

I have defined an agent and I would like to see the training results. For that I use the following code (with a custom environment):

from stable_baselines3 import A2C
import os

env = DSM_BT1_Env()
models_dir = "models/A2C"
logdir = "logs"

timesteps = 1000
if not os.path.exists(models_dir):
    os.makedirs(models_dir)
    
if not os.path.exists(logdir):
    os.makedirs(logdir)
    

model = A2C('MlpPolicy', env, verbose=1, tensorboard_log=logdir)

timesteps = 1000
for i in range (1, 5):
    model.learn(total_timesteps=timesteps, reset_num_timesteps=False,  tb_log_name = "A2C")
    model.save(f"{models_dir}/{timesteps*i} ")

So I log the data in a folder called log which is created during training and in that folder a subfolder with the name A2C_0 is created that contains a lot of files. Now I tried to visualize it the same way as it is done in a tutorial (https://www.youtube.com/watch?v=dLP-2Y6yu70) . For that I tried to open Tensorboard with the following command line: #tensorboard --logdir=logdir --host localhost --port 8088 Altough I can open Tensorboard, no related training results are displayed. I also tried other commands like: tensorboard --logdir="C:/Users/Desktop/Python/Stable_Baselines3/logs" --host localhost --port 8088 but that led to the same result.

Now my question is, how can I display the training results of stable-baselines3 agents? It does not necessarily have to be with Tensorboard. I just want to display the logged data for the training (this could be for example also done with matplotlib). Do you have any idea how I can do that?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
PBeritcommented, Feb 15, 2022

Okay. Thanks Miffyli for your advice.

0reactions
Miffylicommented, Feb 14, 2022

Hmm right. I’d recommend trying to copy projects that use tensorboard and see how they work (e.g. see how stable-baselines3 zoo uses tensorboard, and try running some codes to verify it still works).

I am closing this as resolved. If you find a bug which prevents tensorboard working, please open up a new issue 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Examples — Stable Baselines3 1.7.0a8 documentation
This could be useful when you want to monitor training, for instance display live learning curves in Tensorboard (or in Visdom) or save...
Read more >
Training RL agents in stable-baselines3 is easy
Then I will show you, how you can train an agent in the cartpole environment and display some runs of the trained agent...
Read more >
Reinforcement Learning in Python with Stable Baselines 3
Reinforcement Learning in Python with Stable Baselines 3 ... we've got a trained model, we probably are keen to see it, so let's...
Read more >
Stable-Baselines3: Reliable Reinforcement ... - Antonin Raffin
import gym from stable_baselines3 import SAC # Train an agent using Soft ... To help with this problem, we present Stable-Baselines3 (SB3), ...
Read more >
Stable Baselines3 - Monitor Training and Plotting
RL Baselines3 Zoo is a collection of pre-trained Reinforcement Learning agents using Stable-Baselines3. It also provides basic scripts for training, evaluating ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found