dvgodoy / PyTorchStepByStep

Official repository of my book: "Deep Learning with PyTorch Step-by-Step: A Beginner's Guide"
https://pytorchstepbystep.com
MIT License
866 stars 332 forks source link

A code mistake in the book #36

Open Neuerliu opened 1 year ago

Neuerliu commented 1 year ago

There is a mistake on page 113 of the book.

# on page 113
predictions = torch.tensor(0.5, 1.0)
labels = torch.tensor(2.0, 1.3)

Probably what you really want to write is

predictions = torch.tensor([0.5, 1.0])
labels = torch.tensor([2.0, 1.3])

Thank you Neuer

newcastlea commented 1 year ago

Page 738 of the book : There is: `x0 = points[0] # 4 data points x1 = points[1][2:] # 2 data points x2 = points[2][1:] # 3 data points

x0.shape, x1.shape, x2.shape`

But correctly, given the following code, it is:

`s0 = points[0] # 4 data points s1 = points[1][2:] # 2 data points s2 = points[2][1:] # 3 data points

s0.shape, s1.shape, s2.shape`

Nice book!

benjwolff commented 1 year ago

I add another code typo to this issue, that I found in the book (and in the notebook as well): Page 606:

batch_hidden = final_hidden.permute(1, 0, 2)
batch.shape

Should actually be:

batch_hidden = final_hidden.permute(1, 0, 2)
batch_hidden.shape

Otherwise an incorrect tensor shape will be printed ([3, 4, 2] instead of [3, 1, 2].