Errata

Deep Learning for Coders with fastai and PyTorch

Errata for Deep Learning for Coders with fastai and PyTorch

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Ch06 Other Computer Vision Problems
Binary Cross Entropy

The formula for binary cross entroy is presented:
def binary_cross_entropy(inputs, targets):
inputs = inputs.sigmoid()
return -torch.where(targets==1, 1-inputs, inputs).log().mean()

I think that the where statement is inverted and it should read:
def binary_cross_entropy(inputs, targets):
inputs = inputs.sigmoid()
return -torch.where(targets==1, inputs, 1-inputs).log().mean()

I think this because when we are predicting for the correct target and sigmoid(x) is close to 1, then -log(sigmoid(x)) will give a loss close to 0. If we take -log(1-sigmoid(x)) then our loss will be very high, even though the model is doing a good job.

Ben Caldwell  Feb 07, 2022 
PDF, Other Digital Version Page Page 14
Last paragraph (2 lines)

It's not so much an erratum as a suggestion (I don't know where else to post it so I apologise if this isn't the right place).

This book is great and I love that it expelled so many myths about deep learning. I'm definitely going to read it all but I'm kind of stuck. The last paragraph says:
"Each option shown on the website includes a tutorial; after completing the tutorial,
you will end up with a screen looking like Figure 1-2."

The book is already great but it could be improved a bit. It should be self-contained. For example, it says "after completing the tutorial" but I can't seem to find any tutorial on the website (maybe I'm new to the website). The book should briefly explain where to find the code and how to set up the development environment.
As a beginner, it took me a while to figure out the github repo for the course but it's still hard to follow. I'm not sure if the book explains all the code afterwards. I'm kind of confused and not sure if I should spend my time following something I don't understand. I mean I love the book and the authors and the way they've structured the book but it's a bit difficult to follow at first.

Riyan  Sep 10, 2022 
PDF Page Page 494
The summation formula immediately below 6th paragraph

yi,j = Σx(i,k)w(k,j)+b(j)
SHOULD be:
yi,j = Σx(i,k)w(j,k)+b(j)

this is a multiplication between a matrix and a transposed matrix.

ZHANG Hongyuan  Mar 28, 2023 
Printed Page 143
3rd paragraph from the bottom of the page

the text goes "a table of tables or cube (dimension of three)". well, dimension of three would be a list of tables. a table of tables has a dimension of four

Adam Böhm   Apr 30, 2022 
Other Digital Version 166
the code after "Now let's see ..."



https://forums.fast.ai/t/weights-0-in-place-operations/89308/5

Chao Pan  Jan 02, 2022 
Printed Page 392
Code for LSTMCell class

In the last line before the return statement is

h = outgate *torch.tanh(c)

This should be:

h = out *torch.tanh(c)

Kaushik Sinha  Jan 08, 2022 
Printed Page 392
forward method in the code for LSTM cell

Should h = torch.stack([h, input], dim=1) be replaced with torch.cat([h, input], dim=1) here since torch.stack introduces a new dimension?

Kaushik Sinha  Jan 20, 2022 
PDF Page 449
in `class ResBlock`

```
class ResBlock(Module):
def __init__(self, ni, nf, stride=1):
self.convs = _conv_block(ni,nf,stride)
self.idconv = noop if ni==nf else ConvLayer(ni, nf, 1, act_cls=None)
self.pool = noop if stride==1 else nn.AvgPool2d(2, ceil_mode=True)

def forward(self, x):
return F.relu(self.convs(x) + self.idconv(self.pool(x)))
```

self.convs and self.pool will result in dimension mismatch if stride is 2 or more. as nn.AvgPool2d is hardcoded to scale down width and height of image by 2, while self.convs' output depends on stride

Victor H  Nov 18, 2023