Skip to content

Commit a5152e5

Browse files
committed
Add logo
1 parent 74f624d commit a5152e5

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Kronfluence
1+
<p align="center">
2+
<br>
3+
<img src=".assets/kronfluence.png" width="400"/>
4+
<br>
5+
<p>
26

37
[![CI](https://github.com/mlcommons/algorithmic-efficiency/actions/workflows/CI.yml/badge.svg)](https://github.com/mlcommons/algorithmic-efficiency/actions/workflows/CI.yml)
48
[![Lint](https://github.com/mlcommons/algorithmic-efficiency/actions/workflows/linting.yml/badge.svg)](https://github.com/mlcommons/algorithmic-efficiency/actions/workflows/linting.yml)
@@ -37,6 +41,42 @@ pip install -e .
3741

3842
## Getting Started
3943

44+
45+
```diff
46+
import torch
47+
import torch.nn.functional as F
48+
from datasets import load_dataset
49+
+ from accelerate import Accelerator
50+
51+
+ accelerator = Accelerator()
52+
- device = 'cpu'
53+
+ device = accelerator.device
54+
55+
model = torch.nn.Transformer().to(device)
56+
optimizer = torch.optim.Adam(model.parameters())
57+
58+
dataset = load_dataset('my_dataset')
59+
data = torch.utils.data.DataLoader(dataset, shuffle=True)
60+
61+
+ model, optimizer, data = accelerator.prepare(model, optimizer, data)
62+
63+
model.train()
64+
for epoch in range(10):
65+
for source, targets in data:
66+
source = source.to(device)
67+
targets = targets.to(device)
68+
69+
optimizer.zero_grad()
70+
71+
output = model(source)
72+
loss = F.cross_entropy(output, targets)
73+
74+
- loss.backward()
75+
+ accelerator.backward(loss)
76+
77+
optimizer.step()
78+
```
79+
4080
(Placeholder for getting started content)
4181

4282
## Examples

0 commit comments

Comments
 (0)