Skip to content

🐛 [BUG] An error occurred when using the notation "train/loss" in swan.log #79

@Zeyi-Lin

Description

@Zeyi-Lin

🐛 Bug description [Please make everyone to understand it]

When the key with "/" is passed into swan.log, an error will occur, such as:

swanlab.log({"train/loss": loss.item()})

My running path is /Users/zeyilin/Desktop/Coding/examples/examples/resnet50-cats_vs_dogs
Error:

Error in sys.excepthook:
Traceback (most recent call last):
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/__init__.py", line 40, in except_handler
    raise tp(val)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/zeyilin/Desktop/Coding/examples/examples/resnet50-cats_vs_dogs/swanlog/vibrant-hemlock-7/logs/train/loss'

Original exception was:
Traceback (most recent call last):
  File "/Users/zeyilin/Desktop/Coding/examples/examples/resnet50-cats_vs_dogs/load_datasets.py", line 102, in <module>
    swanlab.log({"train/loss": loss.item()})
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/__init__.py", line 105, in log
    sd.add(key, data[key])
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/main.py", line 105, in add
    self.__project.experiment.add(tag, data)
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/expriment.py", line 105, in add
    self.save_tag(tag, data, self.experiment_id, tag_index, step=step)
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/table.py", line 163, in save_tag
    os.mkdir(save_folder)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/zeyilin/Desktop/Coding/examples/examples/resnet50-cats_vs_dogs/swanlog/vibrant-hemlock-7/logs/train/loss'

👾 Expected result

I hope to support this writing style, and the title in the chart is “train/loss”

🚑 Any additional [like screenshots]

  • SwanLab Version: v0.1.0

  • Platform: macOS-14.1.2-arm64-arm-64bit

Metadata

Metadata

Assignees

Labels

🐛 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions