Skip to content
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

update docs to recommend __call__ for forward passes #1209

Closed
jeremyjordan opened this issue Mar 22, 2020 · 3 comments · Fixed by #1211
Closed

update docs to recommend __call__ for forward passes #1209

jeremyjordan opened this issue Mar 22, 2020 · 3 comments · Fixed by #1211
Labels
docs Documentation related

Comments

@jeremyjordan
Copy link
Contributor

jeremyjordan commented Mar 22, 2020

📚 Documentation

We should update the docs to recommend usage of self(x) for calculating the forward pass rather than self.forward(x). Calling forward() directly can cause issues when you're using PyTorch model hooks (eg. see the additional logic in nn.Module.__call__).

Although most people don't play around with hooks and using self.forward() will work fine for them, we should probably follow the best practice (as I understand) of using __call__ for calculating forward passes.

Related issues: #632

@jeremyjordan jeremyjordan added the docs Documentation related label Mar 22, 2020
@awaelchli
Copy link
Member

Very good idea! Then the examples should also be updated I guess?

@jeremyjordan
Copy link
Contributor Author

jeremyjordan commented Mar 22, 2020

yes! we should update:

  • docs pages
  • lightning examples
  • colab notebooks

i'm happy to tackle the first two, i think @williamFalcon is planning to do the third. will link to a WIP PR soon.

@williamFalcon
Copy link
Contributor

@jeremyjordan i'll do colabs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants