Spaces:
Sleeping
Sleeping
Update HFSummaryWriter snippet for a diff
#1
by
Wauplin
HF staff
- opened
- src/index.md +14 -6
src/index.md
CHANGED
@@ -152,13 +152,21 @@ Plot.plot({
|
|
152 |
|
153 |
The Tensorboard traces can also easily be uploaded to the Hub using the [huggingface_hub](https://huggingface.co/docs/huggingface_hub/package_reference/tensorboard) library, if you don't rely on Transformers. All it takes is to use the `HFSummaryWriter` class and its methods to append data:
|
154 |
|
155 |
-
```
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
162 |
```
|
163 |
|
164 |
This logger was added in June 2023 in the [v0.16.2](https://github.com/huggingface/huggingface_hub/releases/tag/v0.16.2) version of the library and is a good alternative for those who don't use Transformers. Its usage is still confidential. Feel free to try it and report if it helps you generate training metrics!
|
|
|
152 |
|
153 |
The Tensorboard traces can also easily be uploaded to the Hub using the [huggingface_hub](https://huggingface.co/docs/huggingface_hub/package_reference/tensorboard) library, if you don't rely on Transformers. All it takes is to use the `HFSummaryWriter` class and its methods to append data:
|
154 |
|
155 |
+
```diff
|
156 |
+
# Taken from https://pytorch.org/docs/stable/tensorboard.html
|
157 |
+
- from torch.utils.tensorboard import SummaryWriter
|
158 |
+
+ from huggingface_hub import HFSummaryWriter
|
159 |
+
|
160 |
+
import numpy as np
|
161 |
+
|
162 |
+
- writer = SummaryWriter()
|
163 |
+
+ writer = HFSummaryWriter(repo_id="username/my-trained-model")
|
164 |
|
165 |
+
for n_iter in range(100):
|
166 |
+
writer.add_scalar('Loss/train', np.random.random(), n_iter)
|
167 |
+
writer.add_scalar('Loss/test', np.random.random(), n_iter)
|
168 |
+
writer.add_scalar('Accuracy/train', np.random.random(), n_iter)
|
169 |
+
writer.add_scalar('Accuracy/test', np.random.random(), n_iter)
|
170 |
```
|
171 |
|
172 |
This logger was added in June 2023 in the [v0.16.2](https://github.com/huggingface/huggingface_hub/releases/tag/v0.16.2) version of the library and is a good alternative for those who don't use Transformers. Its usage is still confidential. Feel free to try it and report if it helps you generate training metrics!
|