diff --git a/docs/docs/howto/index.mdx b/docs/docs/howto/index.mdx index f7a9db71..d1776729 100644 --- a/docs/docs/howto/index.mdx +++ b/docs/docs/howto/index.mdx @@ -1,5 +1,5 @@ --- -title: An minimal example +title: Get started with an example sidebar_position: 1 --- @@ -28,8 +28,10 @@ import os import time from random import random from time import sleep + import numpy as np from PIL import Image + import neetbox from neetbox import logger @@ -134,11 +136,11 @@ def run_test_mention(text: str): @neetbox.watch("train") -def train(epoch): +def train(step): loss, acc = random(), random() - neetbox.add_scalar("sin", epoch, math.sin(epoch * 0.1)) - neetbox.add_scalar("cos", epoch, math.cos(epoch * 0.1)) - return {"loss": loss, "acc": acc} + neetbox.add_scalar("sin", step, math.sin(step * 0.1)) + neetbox.add_scalar("cos", step, math.cos(step * 0.1)) + return {"global_step": step, "loss": loss, "acc": acc} @neetbox.listen("train") # listen to train @@ -155,14 +157,23 @@ def log_with_some_prefix(): logger.err("some error") -train_config = {"epoch": 9999} +train_config = {"epoch": 99, "batch_size": 10} + + +def train_epoch(config): + def train_batch_in_epoch(current_epoch, batch_size): + for i in neetbox.progress(batch_size): + time.sleep(1) + train(current_epoch * batch_size + i) + + with neetbox.progress(config["epoch"]) as epoch: + for e in epoch: + train_batch_in_epoch(current_epoch=e, batch_size=config["batch_size"]) + if __name__ == "__main__": neetbox.add_hyperparams(train_config) - with neetbox.progress(train_config["epoch"]) as epochs: - for i in epochs: - sleep(1) - train(i) + train_epoch(train_config) ``` @@ -180,7 +191,7 @@ visit [http://localhost:5000/](http://localhost:5000/) and see the dashboard. Yo - [x] send images or tensors as images to frontend - [x] send scalars to show a line chart - [x] check hardware usage -- [x] register python functions as buttons and run remote python codes in dashboard +- [x] register python functions as buttons and run remote python codes in dashboard - [x] manage projects and runs, as well as check history runs - [x] more features check the doc diff --git a/frontend/src/utils/condition.ts b/frontend/src/utils/condition.ts index 219c312f..72031268 100644 --- a/frontend/src/utils/condition.ts +++ b/frontend/src/utils/condition.ts @@ -7,13 +7,8 @@ export interface Condition { order?: Record; limit?: number; runId?: string; - runId?: string; } export function createCondition(condition: Condition) { - if (condition.runId) { - condition.runId = condition.runId; - delete condition.runId; - } return new URLSearchParams({ condition: JSON.stringify({ ...condition }) }).toString(); }