Skip to content

clarify default value of requires_grad for tensors #61038

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

Closed
wants to merge 6 commits into from

Conversation

dagitses
Copy link
Collaborator

@dagitses dagitses commented Jun 30, 2021

dagitses pushed a commit that referenced this pull request Jun 30, 2021
ghstack-source-id: 2d24bc7
Pull Request resolved: #61038
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jun 30, 2021

💊 CI failures summary and remediations

As of commit d8c670e (more details on the Dr. CI page and at hud.pytorch.org/pr/61038):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


Preview docs built from this PR

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@dagitses dagitses closed this Jun 30, 2021
@dagitses dagitses deleted the gh/dagitses/2/head branch June 30, 2021 13:13
@dagitses dagitses restored the gh/dagitses/2/head branch June 30, 2021 13:27
@dagitses dagitses reopened this Jun 30, 2021
@dagitses
Copy link
Collaborator Author

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@dagitses
Copy link
Collaborator Author

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@dagitses dagitses requested a review from albanD June 30, 2021 17:32
@@ -91,6 +91,8 @@ the module level with :meth:`nn.Module.requires_grad_()`.
When applied to a module, ``.requires_grad_()`` takes effect on all
of the module's parameters (which have ``requires_grad=True`` by default).

Tensors that are not module parameters have ``requires_grad=False` by default.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be just after the paragraph line 61 mentioning that all the Tensor factory Functions set it to False by default and it can be changed via the requires_grad keyword argument.
Also mention that when a Tensor is wrapped inside a nn.Parameter, then its requires_grad field is automatically set to True.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i like that location better too. This is so far down I worry that no one would ever see it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think of this?

@@ -91,6 +91,8 @@ the module level with :meth:`nn.Module.requires_grad_()`.
When applied to a module, ``.requires_grad_()`` takes effect on all
of the module's parameters (which have ``requires_grad=True`` by default).

Tensors that are not module parameters have ``requires_grad=False` by default.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the formatting above is missing the second backquote after the requires_grad

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but now moot.

BTW, I see some lines like :meth:nn.Module.requires_grad_(). Do you know why those are able to get away with single backquotes?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ones with a marker before like :meth: or :attr: need only single backquotes.
The inline code is marked by the double backquotes.

dagitses pushed a commit that referenced this pull request Jul 8, 2021
ghstack-source-id: bd19819
Pull Request resolved: #61038
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dagitses dagitses linked an issue Jul 12, 2021 that may be closed by this pull request
@dagitses
Copy link
Collaborator Author

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@dagitses
Copy link
Collaborator Author

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@dagitses
Copy link
Collaborator Author

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

dagitses pushed a commit that referenced this pull request Jul 12, 2021
ghstack-source-id: 738b996
Pull Request resolved: #61038
@dagitses
Copy link
Collaborator Author

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@dagitses merged this pull request in 58df01c.

@facebook-github-bot facebook-github-bot deleted the gh/dagitses/2/head branch July 16, 2021 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarity of default values of requires_grad in autograd note
3 participants