| 1 |
<!--Copyright 2022 The HuggingFace Team. All rights reserved. |
| 2 |
|
| 3 |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 4 |
the License. You may obtain a copy of the License at |
| 5 |
|
| 6 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
|
| 8 |
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 9 |
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 10 |
specific language governing permissions and limitations under the License. |
| 11 |
|
| 12 |
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be |
| 13 |
rendered properly in your Markdown viewer. |
| 14 |
--> |
| 15 |
|
| 16 |
# Start Here! |
| 17 |
|
| 18 |
Please use the interactive tool below to help you get started with learning about a particular |
| 19 |
feature of Accelerate and how to utilize it! It will provide you with a code diff, an explanation |
| 20 |
towards what is going on, as well as provide you with some useful links to explore more within |
| 21 |
the documentation! |
| 22 |
|
| 23 |
Most code examples start from the following python code before integrating Accelerate in some way: |
| 24 |
|
| 25 |
```python |
| 26 |
for batch in dataloader: |
| 27 |
optimizer.zero_grad() |
| 28 |
inputs, targets = batch |
| 29 |
inputs = inputs.to(device) |
| 30 |
targets = targets.to(device) |
| 31 |
outputs = model(inputs) |
| 32 |
loss = loss_function(outputs, targets) |
| 33 |
loss.backward() |
| 34 |
optimizer.step() |
| 35 |
scheduler.step() |
| 36 |
``` |
| 37 |
|
| 38 |
<div class="block dark:hidden"> |
| 39 |
<iframe |
| 40 |
src="https://hf-accelerate-accelerate-examples.hf.space?__theme=light" |
| 41 |
width="850" |
| 42 |
height="1600" |
| 43 |
></iframe> |
| 44 |
</div> |
| 45 |
<div class="hidden dark:block"> |
| 46 |
<iframe |
| 47 |
src="https://hf-accelerate-accelerate-examples.hf.space?__theme=dark" |
| 48 |
width="850" |
| 49 |
height="1600" |
| 50 |
></iframe> |
| 51 |
</div> |