PyTorchStepByStep icon indicating copy to clipboard operation
PyTorchStepByStep copied to clipboard

A code mistake in the book

Open Neuerliu opened this issue 2 years ago • 2 comments

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

Neuerliu avatar Mar 04 '23 07:03 Neuerliu

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!

newcastlea avatar Mar 09 '23 13:03 newcastlea

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].

benjwolff avatar Jul 27 '23 08:07 benjwolff