Update 05_pytorch_going_modular.md

at the `return self.classifier(self.block_2(self.block_1(x)))`

You called the blocks `conv_block_1` and `conv_block_2`. Hence the return function leveraging the benefits of operator fusion errors when running a forward pass.  I fixed this by changing the two block names to the correct ones in return. 

It is also possible to rename both blocks to the shorter version of `block_1` and `block_2` respectively.
This commit is contained in:
Aron authored and GitHub committed 2022-07-25 18:22:55 +02:00
1 parent e020132277
commit dd66bfccdb
1 file changed
+2 -2
+2 -2
View File
@@ -392,7 +392,7 @@ class TinyVGG(nn.Module):
x = self.conv_block_2(x)
x = self.classifier(x)
return x
# return self.classifier(self.block_2(self.block_1(x))) # <- leverage the benefits of operator fusion
# return self.classifier(self.conv_block_2(self.conv_block_1(x))) # <- leverage the benefits of operator fusion
```
Now instead of coding the TinyVGG model from scratch every time, we can import it using:
@@ -831,4 +831,4 @@ python train.py --model MODEL_NAME --batch_size BATCH_SIZE --lr LEARNING_RATE --
* To learn more about structuring a Python project, check out Real Python's guide on [Python Application Layouts](https://realpython.com/python-application-layouts/).
* For ideas on styling your PyTorch code, check out the [PyTorch style guide by Igor Susmelj](https://github.com/IgorSusmelj/pytorch-styleguide#recommended-code-structure-for-training-your-model) (much of styling in this chapter is based off this guide + various similar PyTorch repositories).
* For an example `train.py` script and various other PyTorch scripts written by the PyTorch team to train state-of-the-art image classification models, check out their [`classification` repository on GitHub](https://github.com/pytorch/vision/tree/main/references/classification).
* For an example `train.py` script and various other PyTorch scripts written by the PyTorch team to train state-of-the-art image classification models, check out their [`classification` repository on GitHub](https://github.com/pytorch/vision/tree/main/references/classification).