SwanLab is a Python library for streamlined tracking and management of AI training processes. It offers experiment tracking, visualization, automatic logging, hyperparameter recording, experiment comparison, and multi-user collaboration. SwanLab supports both cloud and offline usage, integrating with over 30 mainstream AI training frameworks. The current version is 0.7.15, with frequent patch and minor releases.
pip install swanlabVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes a SwanLab experiment, logs hyperparameters using `config`, and then simulates a training loop to log scalar metrics (`loss` and `accuracy`) using `swanlab.log()`. It concludes by explicitly calling `swanlab.finish()`.
Always include `swanlab.finish()` at the end of your script or experiment execution block when not relying on automatic termination.
Carefully choose the `resume` mode and provide the correct `id` for the experiment to be resumed. For example, `resume='allow'` will create a new run if the `id` is not found, while `resume='must'` will raise an error.
To run locally without cloud synchronization, initialize SwanLab with `swanlab.init(mode='local')` or `swanlab.init(mode='offline')`. For debugging, `mode='disabled'` can prevent logging entirely.
Migrate your API interactions to use the `swanlab.Api` module for improved functionality and future compatibility.
Ensure `swanlab.finish()` is called at the end of your experiment script. For network issues, check your connection. For long-running idle periods without logs, consider setting a `mode` other than `cloud` or ensuring periodic logging.
Use the command-line arguments: `swanlab login --api-key <YOUR_API_KEY>` or programmatically: `import swanlab; swanlab.login(api_key='Your API Key')`. If self-hosting, also include `--host <YOUR_HOST_ADDRESS>`.
Add `swanlab.finish()` between each `swanlab.init()` call to properly terminate the previous experiment before starting a new one in the same script.
Ensure the experiment `id` is a string between 1 and 64 characters long and does not contain special characters such as `/ \ # ? % :`.
No dependency data recorded yet.