-
Notifications
You must be signed in to change notification settings - Fork 74
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
Detect multiple Lambda layers #61
Conversation
modelscan/models/h5/scan.py
Outdated
] | ||
if layer["class_name"] == "Lambda" | ||
] | ||
model_config = json.loads(model_hdf5.attrs["model_config"]) |
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.
It might be a good idea here to handle JSONDecoderError in case parsing JSON fails for model_config
.
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, thank you, I have added try-except
block to handle potential errors during JSON loading.
modelscan/models/h5/scan.py
Outdated
layers = model_config["config"]["layers"] | ||
lambda_layers = [] | ||
for layer in layers: | ||
if layer["class_name"] == "Lambda": |
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.
Should we also user layer.get(..)
here as it is being used in the next line?
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.
Thank you for the review, I have updated it to layer.get(..)
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
At the moment, ModelScan can detect a Lambda layer in a Keras model. Though, ModelScan does not report if more than one Lambda layers are found in a given Keras model, i.e. one or more Lambda layers get reported as a single issue.
This PR adds functionality in ModelScan to report multiple Lambda layers if they exist in a Keras model.