-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: exit by esc * feat: turn page by keyboard * fix: delete experiment * restore create_experiment.py * Update create_experiment.py * Update create_experiment.py * feat: click to switch images * fix: same file name * feat: turn page by arrow in audio chart modal --------- Co-authored-by: KAAANG <[email protected]>
- Loading branch information
1 parent
f0f52d8
commit 26ce19c
Showing
11 changed files
with
235 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,67 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
r""" | ||
@DATE: 2024-03-04 13:26:59 | ||
@File: test/create_experiment.py | ||
@IDE: vscode | ||
@Description: | ||
创建一个文件,作为测试用例 | ||
WARNING 请勿随意修改此文件,以免影响测试效果 | ||
""" | ||
import swanlab | ||
import time | ||
import random | ||
import numpy as np | ||
|
||
epochs = 50 | ||
lr = 0.01 | ||
offset = random.random() / 5 | ||
|
||
run = swanlab.init( | ||
experiment_name="Example", | ||
description="这是一个机器学习模拟实验", | ||
# 初始化 | ||
swanlab.init( | ||
log_level="debug", | ||
config={ | ||
"learning_rate": 0.01, | ||
"epochs": 20, | ||
"epochs": epochs, | ||
"learning_rate": lr, | ||
"test": 1, | ||
"debug": "这是一串" + "很长" * 100 + "的字符串", | ||
"verbose": 1, | ||
}, | ||
logggings=True, | ||
) | ||
|
||
# 模拟机器学习训练过程 | ||
for epoch in range(2, run.config.epochs): | ||
# 模拟训练 | ||
for epoch in range(2, epochs): | ||
acc = 1 - 2**-epoch - random.random() / epoch - offset | ||
loss = 2**-epoch + random.random() / epoch + offset | ||
swanlab.log({"loss": loss, "accuracy": acc}) | ||
loss2 = 3**-epoch + random.random() / epoch + offset * 3 | ||
print(f"epoch={epoch}, accuracy={acc}, loss={loss}") | ||
if epoch % 10 == 0: | ||
# 测试audio | ||
sample_rate = 44100 | ||
test_audio_arr = np.random.randn(2, 100000) | ||
swanlab.log( | ||
{ | ||
"test/audio": [swanlab.Audio(test_audio_arr, sample_rate, caption="test")] * (epoch // 10), | ||
}, | ||
step=epoch, | ||
) | ||
# 测试image | ||
test_image = np.random.randint(0, 255, (100, 100, 3)) | ||
swanlab.log( | ||
{ | ||
"test/image": [swanlab.Image(test_image, caption="test")] * (epoch // 10), | ||
}, | ||
step=epoch, | ||
) | ||
# 测试text | ||
swanlab.log( | ||
{ | ||
"text": swanlab.Text("这是一段测试文本", caption="test"), | ||
}, | ||
step=epoch, | ||
) | ||
# 测试折线图 | ||
swanlab.log({"t/accuracy": acc, "loss": loss, "loss2": loss2}) | ||
else: | ||
# 测试折线图 | ||
swanlab.log({"t/accuracy": acc, "loss": loss, "loss2": loss2}) | ||
time.sleep(0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.