Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,11 @@ def trainable(self, value):

@property
def trainable_weights(self):
return self.layer.trainable_weights + self._trainable_weights
Copy link

@alanchiao alanchiao Sep 28, 2020

Choose a reason for hiding this comment

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

Maybe I've misunderstood but self._trainable_weights and self._non_trainable_weights should be updated automatically during calls to self.add_weight().

By removing "self._trainable_weights" here, someone calling layer.trainable_weights will no longer see all the weights that your wrapper is adding, which breaks the interface.

You can try creating a unit test that checks what layer.trainable_weights outputs and see if it makes sense and look at the base tf.keras.layers.Layer implementation to see what it does.

return self.layer.trainable_weights

@property
def non_trainable_weights(self):
return self.layer.non_trainable_weights + self._non_trainable_weights
return self.layer.non_trainable_weights

@property
def updates(self):
Expand Down