You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know that I can use the setattr method to set the keras.Model attribute. But here I wanted to check whether this is a supposed workflow.
Any help on this would be grately appreciated.
My opinion: We should warn the user if they want to set the attribute of a model (mainly layers). I feel adding a layer to the model (which is not intuitive at all) introduces a silent bug.
The text was updated successfully, but these errors were encountered:
Keras won't allow to adding new layers once model.build() is called. Before model build call it is accepting the duplicate layers though. This behaviour is different wrt pytorch which swaps the duplicate layers instead of adding as new.Attached gist for reference.
Keras won't allow to adding new layers once model.build() is called. Before model build call it is accepting the duplicate layers though. This behaviour is different wrt pytorch which swaps the duplicate layers instead of adding as new.Attached gist for reference.
Hey @SuryanarayanaY I did look into the GIST. I did not really understand the reason of the following code with the torch backend
I have created a CustomModel using the subclass API
I wanted to replace (read swap) a layer from the custom model with a new layer.
Now when I hit
model.summary
I see both the layers added to the Model.When I take a similar approach with
torch.nn.Module
, the layers get swapped out.I know that I can use the
setattr
method to set thekeras.Model
attribute. But here I wanted to check whether this is a supposed workflow.Any help on this would be grately appreciated.
My opinion: We should warn the user if they want to set the attribute of a model (mainly layers). I feel adding a layer to the model (which is not intuitive at all) introduces a silent bug.
The text was updated successfully, but these errors were encountered: