From dd66bfccdb7874c11247a5000a03ebee2ed311bd Mon Sep 17 00:00:00 2001 From: Aron <64252048+aronvandepol@users.noreply.github.com> Date: Mon, 25 Jul 2022 18:22:55 +0200 Subject: [PATCH] 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. --- 05_pytorch_going_modular.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/05_pytorch_going_modular.md b/05_pytorch_going_modular.md index b2f3821..706258b 100644 --- a/05_pytorch_going_modular.md +++ b/05_pytorch_going_modular.md @@ -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). \ No newline at end of file +* 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).