-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix print_summary bug and add groups of convolution #9492
Changes from 3 commits
56615e8
34294b1
50f0c4c
ff3a869
95811c1
4d36fea
9bb2573
52624d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,17 +134,23 @@ def print_layer_summary(node, out_shape): | |
pre_filter = pre_filter + int(shape[0]) | ||
cur_param = 0 | ||
if op == 'Convolution': | ||
if ("no_bias" in node["attrs"]) and int(node["attrs"]["no_bias"]): | ||
cur_param = pre_filter * int(node["attrs"]["num_filter"]) | ||
if ("no_bias" in node["attrs"]) and node["attrs"]["no_bias"] == 'True': | ||
num_group = int(node["attrs"]["num_group"]) if \ | ||
("num_group" in node["attrs"]) else 1 | ||
cur_param = (pre_filter * int(node["attrs"]["num_filter"])) \ | ||
// num_group | ||
for k in _str2tuple(node["attrs"]["kernel"]): | ||
cur_param *= int(k) | ||
else: | ||
cur_param = pre_filter * int(node["attrs"]["num_filter"]) | ||
num_group = int(node["attrs"]["num_group"]) if \ | ||
("num_group" in node["attrs"]) else 1 | ||
cur_param = (pre_filter * int(node["attrs"]["num_filter"])) \ | ||
// num_group | ||
for k in _str2tuple(node["attrs"]["kernel"]): | ||
cur_param *= int(k) | ||
cur_param += int(node["attrs"]["num_filter"]) | ||
elif op == 'FullyConnected': | ||
if ("no_bias" in node["attrs"]) and int(node["attrs"]["no_bias"]): | ||
if ("no_bias" in node["attrs"]) and node["attrs"]["no_bias"] == 'True': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure about this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're right. @chinakook sorry for the misleading comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think i can replace bool(bool_str) with built-in function eval(bool_str). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would create an injection point, since the files may not be trusted. (e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Then use node["attrs"]["no_bias"] == 'True' back? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The json dump should have made booleans without the parenthesis so that the json's type is used, i.e.
@piiswrong would it be OK to change json export to properly use json boolean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no. there is compatibility issue |
||
cur_param = pre_filter * (int(node["attrs"]["num_hidden"])) | ||
else: | ||
cur_param = (pre_filter+1) * (int(node["attrs"]["num_hidden"])) | ||
|
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.
the outer parentheses are not necessary and make it hard to read. would you clean it up?