cambrian.ml.callbacks¶
Callbacks used during training and/or evaluation.
Classes¶
Should be used with an EvalCallback to plot the evaluation results. |
|
Overwrites the default EvalCallback to support saving visualizations at the same |
|
This callback will log the GPU usage at the end of each evaluation. |
|
Should be used with an EvalCallback to save the policy. |
|
Overwrite the default progress bar callback to flush the pbar on deconstruct. |
|
Class for chaining callbacks. |
|
This callback will save the resolved hydra config to the logdir. |
Module Contents¶
- class MjCambrianPlotMonitorCallback(logdir, filename, n_episodes=1)[source]¶
Bases:
stable_baselines3.common.callbacks.BaseCallback
Should be used with an EvalCallback to plot the evaluation results.
This callback will take the monitor.csv file produced by the VecMonitor and plot the results and save it as an image. Should be passed as the callback_after_eval for the EvalCallback.
- Parameters:
logdir (Path | str) – The directory where the evaluation results are stored. The evaluations.npz file is expected to be at <logdir>/<filename>.csv. The resulting plot is going to be stored at <logdir>/evaluations/<filename>.png.
filename (Path | str) – The filename of the monitor file. The saved file will be <logdir>/<filename>.csv. And the resulting plot will be saved as <logdir>/evaluations/<filename>.png.
- class MjCambrianEvalCallback(eval_env, callback_on_new_best=None, callback_after_eval=None, n_eval_episodes=5, eval_freq=10000, log_path=None, best_model_save_path=None, deterministic=True, render=False, verbose=1, warn=True)[source]¶
Bases:
stable_baselines3.common.callbacks.EvalCallback
Overwrites the default EvalCallback to support saving visualizations at the same time as the evaluation.
Note
Only the first environment is visualized
- class MjCambrianGPUUsageCallback(logdir, logfile='gpu_usage.csv', *, verbose=0)[source]¶
Bases:
stable_baselines3.common.callbacks.BaseCallback
This callback will log the GPU usage at the end of each evaluation. We’ll log to a csv.
- class MjCambrianSavePolicyCallback(logdir, *, verbose=0)[source]¶
Bases:
stable_baselines3.common.callbacks.BaseCallback
Should be used with an EvalCallback to save the policy.
This callback will save the policy at the end of each evaluation. Should be passed as the callback_after_eval for the EvalCallback.
- Parameters:
logdir (Path | str) – The directory to store the generated visualizations. The resulting visualizations are going to be stored at <logdir>/evaluations/visualization.gif.
- class MjCambrianProgressBarCallback[source]¶
Bases:
stable_baselines3.common.callbacks.ProgressBarCallback
Overwrite the default progress bar callback to flush the pbar on deconstruct.
Bases:
stable_baselines3.common.callbacks.CallbackList
Class for chaining callbacks.
- Parameters:
callbacks – A list of callbacks that will be called sequentially.
- class MjCambrianSaveConfigCallback[source]¶
Bases:
hydra.experimental.callbacks.Callback
This callback will save the resolved hydra config to the logdir.