| 119 | |
| 120 | |
| 121 | def _module_list(module, flatten_sequential=False): |
| 122 | # a yield/iter would be better for this but wouldn't be compatible with torchscript |
| 123 | ml = [] |
| 124 | for name, module in module.named_children(): |
| 125 | if flatten_sequential and isinstance(module, nn.Sequential): |
| 126 | # first level of Sequential containers is flattened into containing model |
| 127 | for child_name, child_module in module.named_children(): |
| 128 | combined = [name, child_name] |
| 129 | ml.append(('_'.join(combined), '.'.join(combined), child_module)) |
| 130 | else: |
| 131 | ml.append((name, name, module)) |
| 132 | return ml |
| 133 | |
| 134 | |
| 135 | def _get_feature_info(net, out_indices): |