Skip to content

Commit 3ac906e

Browse files
committed
formatting in logging
1 parent 944153e commit 3ac906e

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

s4_debugging_and_logging/logging.md

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,46 +32,46 @@ collaboration and sharing of results.
3232
## ❔ Exercises
3333

3434
1. Start by creating an account at [wandb](https://wandb.ai/site). I recommend using your github account but feel
35-
free to choose what you want. When you are logged in you should get an API key of length 40. Copy this for later
36-
use (HINT: if you forgot to copy the API key, you can find it under settings).
35+
free to choose what you want. When you are logged in you should get an API key of length 40. Copy this for later
36+
use (HINT: if you forgot to copy the API key, you can find it under settings).
3737

3838
2. Next install wandb on your laptop
3939

40-
```bash
41-
pip install wandb
42-
```
40+
```bash
41+
pip install wandb
42+
```
4343

4444
3. Now connect to your wandb account
4545

46-
```bash
47-
wandb login
48-
```
46+
```bash
47+
wandb login
48+
```
4949

50-
you will be asked to provide the 40 length API key. The connection should be remain open to the wandb server
51-
even when you close the terminal, such that you do not have to login each time. If using `wandb` in a notebook
52-
you need to manually close the connection using `wandb.finish()`.
50+
you will be asked to provide the 40 length API key. The connection should be remain open to the wandb server
51+
even when you close the terminal, such that you do not have to login each time. If using `wandb` in a notebook
52+
you need to manually close the connection using `wandb.finish()`.
5353
5454
4. With it all setup we are now ready to incorporate `wandb` into our code. The interface is fairly simple, and
55-
this [guide](https://docs.wandb.ai/guides/integrations/pytorch) should give enough hints to get you through
56-
the exercise. (HINT: the two methods you need to call are `wandb.init` and `wandb.log`). To start with, logging
57-
the training loss of your model will be enough.
55+
this [guide](https://docs.wandb.ai/guides/integrations/pytorch) should give enough hints to get you through
56+
the exercise. (HINT: the two methods you need to call are `wandb.init` and `wandb.log`). To start with, logging
57+
the training loss of your model will be enough.
5858
5959
5. After running your model, checkout the webpage. Hopefully you should be able to see at least one run with something
60-
logged.
60+
logged.
6161
6262
6. Now log something else than scalar values. This could be a image, a histogram or a matplotlib figure. In all
63-
cases the logging is still going to use `wandb.log` but you need extra calls to `wandb.Image` etc. depending
64-
on what you choose to log.
63+
cases the logging is still going to use `wandb.log` but you need extra calls to `wandb.Image` etc. depending
64+
on what you choose to log.
6565
6666
7. Finally, lets create a report that you can share. Click the **Create report** button and include some of the
67-
graphs/plots/images that you have generated in the report.
67+
graphs/plots/images that you have generated in the report.
6868
6969
8. To make sure that you have completed todays exercises, make the report shareable by clicking the *Share* button
70-
and create *view-only-link*. Send the link to my email `nsde@dtu.dk`, so I can checkout your awesome work 😃
70+
and create *view-only-link*. Send the link to my email `nsde@dtu.dk`, so I can checkout your awesome work 😃
7171
7272
9. When calling `wandb.init` you have two arguments called `project` and `entity`. Make sure that you understand these
73-
and try them out. It will come in handy for your group work as they essentially allows multiple users to upload their
74-
own runs to the same project in `wandb`.
73+
and try them out. It will come in handy for your group work as they essentially allows multiple users to upload their
74+
own runs to the same project in `wandb`.
7575
7676
10. Wandb also comes with build in feature for doing [hyperparameter sweeping](https://docs.wandb.ai/guides/sweeps)
7777
which can be beneficial to get a better working model. Look through the documentation on how to do a hyperparameter
@@ -85,32 +85,32 @@ collaboration and sharing of results.
8585
previous exercise, it needs to happen automatically. Lets therefore look into how we can do that.
8686
8787
1. First we need to generate an authentication key, or more precise an API key. This is in general the way any
88-
service (like a docker container) can authenticate. Start by going <https://wandb.ai/home>, click your profile
89-
icon in the upper right corner and then go to settings. Scroll down to the danger zone and generate a new API
90-
key and finally copy it.
88+
service (like a docker container) can authenticate. Start by going <https://wandb.ai/home>, click your profile
89+
icon in the upper right corner and then go to settings. Scroll down to the danger zone and generate a new API
90+
key and finally copy it.
9191
9292
2. Next create a new docker file called `wandb.docker` and add the following code
9393
94-
```dockerfile
95-
FROM python:3.9
96-
RUN apt update && \
97-
apt install --no-install-recommends -y build-essential gcc && \
98-
apt clean && rm -rf /var/lib/apt/lists/*
99-
RUN pip install wandb
100-
COPY s4_debugging_and_logging/exercise_files/wandb_tester.py wandb_tester.py
101-
ENTRYPOINT ["python", "-u", "wandb_tester.py"]
102-
```
94+
```dockerfile
95+
FROM python:3.9
96+
RUN apt update && \
97+
apt install --no-install-recommends -y build-essential gcc && \
98+
apt clean && rm -rf /var/lib/apt/lists/*
99+
RUN pip install wandb
100+
COPY s4_debugging_and_logging/exercise_files/wandb_tester.py wandb_tester.py
101+
ENTRYPOINT ["python", "-u", "wandb_tester.py"]
102+
```
103103
104-
please take a look at the script being copied into the image and afterwards build the docker image.
104+
please take a look at the script being copied into the image and afterwards build the docker image.
105105
106106
3. When we want to run the image, what we need to do is including a environment variables that contains the API key
107-
we generated. This will then authenticate the docker container with the wandb server:
107+
we generated. This will then authenticate the docker container with the wandb server:
108108
109-
```bash
110-
docker run -e WANDB_API_KEY=<your-api-key> wandb:latest
111-
```
109+
```bash
110+
docker run -e WANDB_API_KEY=<your-api-key> wandb:latest
111+
```
112112
113-
Try running it an confirm that the results are uploaded to the wandb server.
113+
Try running it an confirm that the results are uploaded to the wandb server.
114114
115115
12. Feel free to experiment more with `wandb` as it is a great tool for logging, organizing and sharing experiments.
116116
@@ -122,7 +122,6 @@ We want to stress that the combination of tools presented in this course may not
122122
projects, and we recommend finding a setup that fits you. That said, each framework provide specific features
123123
that the others does not.
124124
125-
\
126125
Finally, we want to note that we during the course really try to showcase a lot of open source frameworks, Wandb is not
127126
one. It is free to use for personal usage (with a few restrictions) but for enterprise it does require a license. If you
128127
are eager to only work with open-source tools we highly recommend trying out [MLFlow](https://mlflow.org/) which offers

0 commit comments

Comments
 (0)