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

Fix: Return Attention Scores when return_attention_scores=True #20684

Merged
merged 4 commits into from
Dec 24, 2024

Conversation

Furkan-rgb
Copy link
Contributor

This pull request addresses an issue in the Attention layer where the return_attention_scores parameter wasn't correctly handled in the compute_output_shape method. This fix ensures that attention scores are returned when return_attention_scores=True.

Changes Made

Modified compute_output_shape method to return the shape of both the attention output and the attention scores when return_attention_scores=True.

…ention_scores=True`

This pull request addresses an issue in the Attention layer where the return_attention_scores parameter wasn't correctly handled in the compute_output_shape method. This fix ensures that attention scores are returned when return_attention_scores=True.

## Changes Made
Modified compute_output_shape method to return the shape of both the attention output and the attention scores when return_attention_scores=True.
Copy link

google-cla bot commented Dec 23, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 9 lines in your changes missing coverage. Please review.

Project coverage is 81.96%. Comparing base (3dd958b) to head (8a66542).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
keras/src/layers/attention/attention.py 66.66% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20684      +/-   ##
==========================================
- Coverage   81.97%   81.96%   -0.01%     
==========================================
  Files         544      544              
  Lines       50751    50773      +22     
  Branches     7851     7854       +3     
==========================================
+ Hits        41604    41617      +13     
- Misses       7252     7258       +6     
- Partials     1895     1898       +3     
Flag Coverage Δ
keras 81.80% <66.66%> (-0.01%) ⬇️
keras-jax 63.94% <66.66%> (-0.01%) ⬇️
keras-numpy 58.87% <66.66%> (+<0.01%) ⬆️
keras-openvino 29.93% <7.40%> (-0.01%) ⬇️
keras-tensorflow 64.69% <66.66%> (-0.01%) ⬇️
keras-torch 63.79% <66.66%> (-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.

@fchollet
Copy link
Collaborator

Thanks for the PR! Can you add a unit test, so we avoid breaking this in the future?

Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Dec 24, 2024
@fchollet fchollet merged commit df002a9 into keras-team:master Dec 24, 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 Dec 24, 2024
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