-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Ensures that the layer is marked as built when the build
is not overriden
#20880
base: master
Are you sure you want to change the base?
Ensures that the layer is marked as built when the build
is not overriden
#20880
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20880 +/- ##
==========================================
- Coverage 82.25% 82.25% -0.01%
==========================================
Files 561 561
Lines 52680 52665 -15
Branches 8144 8146 +2
==========================================
- Hits 43334 43318 -16
- Misses 7342 7343 +1
Partials 2004 2004
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
keras/src/layers/activations/elu.py
Outdated
@@ -23,7 +24,13 @@ def __init__(self, alpha=1.0, **kwargs): | |||
super().__init__(**kwargs) | |||
self.alpha = alpha | |||
self.supports_masking = True | |||
self.built = True | |||
|
|||
# We can only safely mark the layer as built when build is not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code snippet seems to be recurring a lot -- could it be added to the base class instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have moved the logic to Layer._build_at_init()
and applied it everywhere.
Note: We cannot directly apply it at the end of Layer.__init__()
because it would break some corner cases in the codebase.
be82d8c
to
b7b4372
Compare
b7b4372
to
1e65b51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Fix #20871
This PR ensures that the layer is marked as built when the
build
is not overriden.Additionally, this PR cleans up the redundant
self.built = True
.