-
Notifications
You must be signed in to change notification settings - Fork 324
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 _weight_name() for layers with multiple '/' #544
base: master
Are you sure you want to change the base?
Conversation
The _weight_name() method fails to recognise models with weights that have multiple weights with parts, such as 'quantize_annotate_3/conv1d_26/kernel:0' and 'quantize_annotate_3/conv1d_27/kernel:0'. In such case, since the names are inserted into a dict, the kernel:0 part for conv1d_26 will clash with kernel:0 for conv1d_27 and instead of having 2 weight sets, we will have only one. By doing the partitioning on '/' and taking the part after the first '/', such situations can be avoided while still removing the layer name from TF variable name.
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.
Thanks for making this fix Andrzej. Left some comments.
...model_optimization/python/core/quantization/keras/graph_transformations/model_transformer.py
Show resolved
Hide resolved
@@ -424,7 +424,7 @@ def _weight_name(name): | |||
Returns: | |||
Extracted weight name. | |||
""" | |||
return name.split('/')[-1] |
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.
Could you add a unit test for this change so we don't make the same mistake going forward?
Changed the comment, however I am not sure how to build the repo in a way that the unit tests execute and I'm not familiar with tf.test, so @alanchiao, would you mind adding the unit test for this change? |
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.
Thanks.
Small ping :) |
Removing myself and adding @Xhark for visibility giving that I've moved on. |
The _weight_name() method fails to recognise models with weights that have multiple weights with parts, such as 'quantize_annotate_3/conv1d_26/kernel:0' and 'quantize_annotate_3/conv1d_27/kernel:0'. In such case, since the names are inserted into a dict, the kernel:0 part for conv1d_26 will clash with kernel:0 for conv1d_27 and instead of having 2 weight sets, we will have only one. By doing the partitioning on '/' and taking the part after the first '/', such situations can be avoided while still removing the layer name from TF variable name.