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

Allow ops.stop_gradient() to take a variable. #20302

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

hertschuh
Copy link
Collaborator

Passing a tensor to ops.stop_gradient() always works. However, passing a variable directly would work with the Tensorflow backend but fail with an obscure error message with the JAX backend and the Torch backend, requiring users to write ops.stop_gradient(variable.value).

This makes it work directly with variables, which is a common use-case.

Passing a tensor to `ops.stop_gradient()` always works. However, passing a variable directly would work with the Tensorflow backend but fail with an obscure error message with the JAX backend and the Torch backend, requiring users to write `ops.stop_gradient(variable.value)`.

This makes it work directly with variables, which is a common use-case.
@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.83%. Comparing base (09c133c) to head (213a0f7).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #20302   +/-   ##
=======================================
  Coverage   78.83%   78.83%           
=======================================
  Files         511      511           
  Lines       48985    48989    +4     
  Branches     9020     9022    +2     
=======================================
+ Hits        38617    38621    +4     
  Misses       8505     8505           
  Partials     1863     1863           
Flag Coverage Δ
keras 78.69% <100.00%> (+<0.01%) ⬆️
keras-jax 62.29% <50.00%> (-0.01%) ⬇️
keras-numpy 57.43% <0.00%> (-0.01%) ⬇️
keras-tensorflow 63.56% <0.00%> (-0.01%) ⬇️
keras-torch 62.28% <50.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Sep 28, 2024
@fchollet fchollet merged commit 4f7f852 into keras-team:master Sep 28, 2024
7 checks passed
@google-ml-butler google-ml-butler bot removed ready to pull Ready to be merged into the codebase kokoro:force-run labels Sep 28, 2024
@hertschuh hertschuh deleted the stop_gradient_var branch September 28, 2024 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants