-
Notifications
You must be signed in to change notification settings - Fork 21
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
Implement torch_tensor_backward
#286
Open
jwallwork23
wants to merge
34
commits into
main
Choose a base branch
from
152_tensor-backward
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c4f8d78
to
7e3fe43
Compare
I'll break this PR down into more manageable ones as it's got rather unwieldy. |
This was referenced Feb 18, 2025
Merged
5835d3a
to
8e03e81
Compare
Ah, just noticed that I haven't updated
Will do that. |
Done in 883654a. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
autograd
Tasks towards the online training / automatic differentiation feature
enhancement
New feature or request
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #152.
This PR:
Sets the(Done in Hook uprequires_grad
argument to tensor constructors up properly.requires_grad
#288.)tensor->backward
method astorch_tensor_backward
.torch_tensor_backward
):torch_tensor_get_gradient
.torch_tensor%grad()
(c.f.tensor.grad
).Revises the scalar multiplication/division approach as described below.(Done in Rework scalar multiplication and division #289.)I spent far too much time trying to get the gradients to be computed correctly for scalar multiplication and division as it is currently implemented. However, I discovered that everything works nicely if we just define scalars as rank-1 tensors with a single value. The revised approach to scalar multiplication/division adds a bit of boilerplate, but perhaps this could be reduced by introducing atorch_scalar
class (see #285 for discussion).