Skip to content

minor: model.to(device) #648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
d-kleine opened this issue May 19, 2025 · 0 comments
Open

minor: model.to(device) #648

d-kleine opened this issue May 19, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@d-kleine
Copy link
Contributor

Bug description

I have noticed a small thing in the code in the "Introduction to PyTorch" section:

"model = model.to(device) # NEW\n",

Code reference in the print/ebook on p. 281

The assignment is actually not needed as for models (different for tensors), the assignment will be performed in-place and should be slightly faster:

model.to(device)

Idk if this was done here on purpose because at some other code sections of the book this is correctly pointed out, for instance:

"model.to(device); # no assignment model = model.to(device) necessary for nn.Module classes"

What operating system are you using?

None

Where do you run your code?

None

Environment




@d-kleine d-kleine added the bug Something isn't working label May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants