MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / summarize_net

Function summarize_net

rtpose_wrapper/tools/extra/summarize.py:63–126  ·  view source on GitHub ↗
(net)

Source from the content-addressed store, hash-verified

61 print row_str
62
63def summarize_net(net):
64 disconnected_tops = set()
65 for lr in net.layer:
66 disconnected_tops |= set(lr.top)
67 disconnected_tops -= set(lr.bottom)
68
69 table = []
70 colors = {}
71 for lr in net.layer:
72 tops = []
73 for ind, top in enumerate(lr.top):
74 color = colors.setdefault(top, COLORS[len(colors) % len(COLORS)])
75 if top in disconnected_tops:
76 top = '\033[1;4m' + top
77 if len(lr.loss_weight) > 0:
78 top = '{} * {}'.format(lr.loss_weight[ind], top)
79 tops.append('\033[{}m{}\033[0m'.format(color, top))
80 top_str = ', '.join(tops)
81
82 bottoms = []
83 for bottom in lr.bottom:
84 color = colors.get(bottom, DISCONNECTED_COLOR)
85 bottoms.append('\033[{}m{}\033[0m'.format(color, bottom))
86 bottom_str = ', '.join(bottoms)
87
88 if lr.type == 'Python':
89 type_str = lr.python_param.module + '.' + lr.python_param.layer
90 else:
91 type_str = lr.type
92
93 # Summarize conv/pool parameters.
94 # TODO support rectangular/ND parameters
95 conv_param = lr.convolution_param
96 if (lr.type in ['Convolution', 'Deconvolution']
97 and len(conv_param.kernel_size) == 1):
98 arg_str = str(conv_param.kernel_size[0])
99 if len(conv_param.stride) > 0 and conv_param.stride[0] != 1:
100 arg_str += '/' + str(conv_param.stride[0])
101 if len(conv_param.pad) > 0 and conv_param.pad[0] != 0:
102 arg_str += '+' + str(conv_param.pad[0])
103 arg_str += ' ' + str(conv_param.num_output)
104 if conv_param.group != 1:
105 arg_str += '/' + str(conv_param.group)
106 elif lr.type == 'Pooling':
107 arg_str = str(lr.pooling_param.kernel_size)
108 if lr.pooling_param.stride != 1:
109 arg_str += '/' + str(lr.pooling_param.stride)
110 if lr.pooling_param.pad != 0:
111 arg_str += '+' + str(lr.pooling_param.pad)
112 else:
113 arg_str = ''
114
115 if len(lr.param) > 0:
116 param_strs = map(format_param, lr.param)
117 if max(map(len, param_strs)) > 0:
118 param_str = '({})'.format(', '.join(param_strs))
119 else:
120 param_str = ''

Callers 1

mainFunction · 0.85

Calls 2

joinMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected