Giter Site home page Giter Site logo

feudalman / swanlab-c Goto Github PK

View Code? Open in Web Editor NEW

This project forked from swanhubx/swanlab

0.0 0.0 0.0 7.45 MB

🧐SwanLab: a tool for your machine learning log tracking and experiment management.

Home Page: https://geektechstudio.feishu.cn/wiki/space/7310593325374013444?ccm_open_type=lark_wiki_spaceLink&open_tab_from=wiki_home

License: Apache License 2.0

Shell 0.05% JavaScript 11.12% Python 46.50% TypeScript 0.05% HTML 0.15% Vue 40.34% SCSS 1.80%

swanlab-c's Introduction

SwanLab Library

SwanLab is a robust open-source machine-learning training management tool for researchers. By using SwanLab, researchers can accumulate training experience and discover new ideas.

English | 简体中文

/ pypi Download Github Discussion Website license

hello_world_main2


✨ Features

  1. Real-time Indicator Record: A few lines of code can record your training metrics in real time.
  2. 🧪 Multiple Experimental Comparisons: Support multiple experimental metric comparisons.
  3. 🤖 ML Support:: Support mainstream training frameworks such as PyTorch, TensorFlow, Transformers, mmdetection.
  4. 📝 Environmental Record: Support automatic logging, error reporting, system hardware, Python environment and other environmental information.
  5. 🖥 Local and Public Cloud Support: Supports both local and public cloud (coming soon).

🔥 Examples

We've got some example code and articles to help you get a better grip on SwanLab:


⚡️ Quick Start

Hey, whether you're a developer or an everyday user, this quick-start guide will get you started and show you how to use SwanLab:

  • Record training settings
  • Keep track of key metrics
  • Visualize experiments

🎯 Step1:Installation

$ pip install -U swanlab

👋 Step2:Hello World

If we break down the training process in machine learning, it's basically all about tweaking settings, looping, and keeping an eye on the metrics we care about.

The following Python code simulates this:

import swanlab

# Initialization
swanlab.init()

for epoch in range(1, 20):
    print("epoch", epoch)
    # Tracking index: `epoch`
    swanlab.log({"epoch": epoch})

Among them, swanlab.init is necessary, which is used to initialize the instance and configure parameters; The function of swanlab.log is responsible for recording data, and the received data type is a dictionary (dict).

When running the above code, you will see the following output result:

[SwanLab-INFO]:        Run data will be saved locally in path/swanlog/majestic-hemlock-1
[SwanLab-INFO]:        Experiment_name: majestic-hemlock-1
[SwanLab-INFO]:        Run `swanlab watch` to view SwanLab Experiment Dashboard
epoch 1
epoch 2
epoch 3
epoch 4
epoch 5
epoch 6
epoch 7
epoch 8
epoch 9
[SwanLab-INFO]:        train successfully

And there will be swanlog folder in the root directory, which contains files automatically generated by SwanLab, recording a series of experimental data.


🧪 Step3:Run Dashboard

Now let's check the status of the instructions recorded by SwanLab in each loop step.

Run the command swanlab watch:

$ swanlab watch

[SwanLab-INFO]:        SwanLab Experiment Dashboard ready in 375ms
                       ➜  Local:   http://127.0.0.1:5092

Visit http://127.0.0.1:5092, open the experiment dashboard, and access the experiment that was just run.


🚀 Level up a bit

In this section, let's write an advanced training script to simulate real machine learning training.

First, initialize swanlab and set the experiment name, description, and configuration:

swanlab.init(
    # Set experiment name
    experiment_name="sample_experiment",
    # Set description
    description="This is a sample experiment for machine learning training.",
    # Record tracked hyperparameters and run metadata.
    config={
        "learning_rate": lr,
        "epochs": epochs,
    },
)

Combine into 1 complete training script, use swanlab.log API to track the loss value loss and accuracy accuracy:

import swanlab
import time
import random

lr = 0.01
epochs = 20
offset = random.random() / 5

swanlab.init(
    # Set experiment name
    experiment_name="sample_experiment",
    # Set description
    description="This is a sample experiment for machine learning training.",
    # Record tracked hyperparameters and run metadata.
    config={
        "learning_rate": lr,
        "epochs": epochs,
    },
)

# Simulated machine learning training process
for epoch in range(2, epochs):
    acc = 1 - 2**-epoch - random.random() / epoch - offset
    loss = 2**-epoch + random.random() / epoch + offset
    print(f"epoch={epoch}, accuracy={acc}, loss={loss}")
    # Tracking index: 'loss' and 'accuracy'
    swanlab.log({"loss": loss, "accuracy": acc})
    time.sleep(1)

Similarly, run swanlab watch to start the experiment dashboard:

hello_world_main2


🌱 Learn More


💬 Community

Join SwanLab Community to share your ideas, suggestions, or questions and connect with other users and contributors.

WeChat or Github Discussions:

PyPI - DownloadsDiscuss on GitHub


LICENSE

This project is currently licensed under Apache 2.0 License

swanlab-c's People

Contributors

sakura-cat avatar feudalman avatar zeyi-lin avatar swpfy avatar clairdelunejs avatar indevn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.