wandb.log
Last updated
Last updated
Log a dict to the global run's history.
Use wandb.log
to log data from runs, such as scalars, images, video, histograms, and matplotlib plots.
The most basic usage is wandb.log({'train-loss': 0.5, 'accuracy': 0.9})
. This will save a history row associated with the run with train-loss=0.5
and accuracy=0.9
. Visualize logged data in the workspace at wandb.ai, or locally on a self-hosted instance of the W&B app: https://docs.wandb.ai/self-hosted
Export data to explore in a Jupyter notebook, for example, with the API: https://docs.wandb.ai/ref/public-api
Each time you call wandb.log(), this adds a new row to history and updates the summary values for each key logged. In the UI, summary values show up in the run table to compare single values across runs. You might want to update summary manually to set the best value instead of the last value for a given metric. After you finish logging, you can set summary: wandb.run.summary["accuracy"] = 0.9
.
Logged values don't have to be scalars. Logging any wandb object is supported. For example wandb.log({"example": wandb.Image("myimage.jpg")})
will log an example image which will be displayed nicely in the wandb UI. See https://docs.wandb.com/library/reference/data_types for all of the different supported types.
Logging nested metrics is encouraged and is supported in the wandb API, so you could log multiple accuracy values with wandb.log({'dataset-1': {'acc': 0.9, 'loss': 0.3} ,'dataset-2': {'acc': 0.8, 'loss': 0.2}})
and the metrics will be organized in the wandb UI.
W&B keeps track of a global step so logging related metrics together is encouraged, so by default each time wandb.log is called a global step is incremented. If it's inconvenient to log related metrics together calling wandb.log({'train-loss': 0.5, commit=False})
and then wandb.log({'accuracy': 0.9})
is equivalent to calling wandb.log({'train-loss': 0.5, 'accuracy': 0.9})
wandb.log is not intended to be called more than a few times per second. If you want to log more frequently than that it's better to aggregate the data on the client side or you may get degraded performance.
Arguments | |
| (dict, optional) A dict of serializable python objects i.e |
| (boolean, optional) Save the metrics dict to the wandb server and increment the step. If false |
| (integer, optional) The global step in processing. This persists any non-committed earlier steps but defaults to not committing the specified step. |
| (boolean, True) This argument is deprecated and currently doesn't change the behaviour of |
Basic usage
Incremental logging
Histogram
Image
Video
Matplotlib Plot
PR Curve
3D Object
For more examples, see https://docs.wandb.com/library/log
Raises | |
| if called before |
| if invalid data is passed |