(self)
| 544 | return x, p |
| 545 | |
| 546 | def fuse(self): |
| 547 | # Fuse Conv2d + BatchNorm2d layers throughout model |
| 548 | print('Fusing layers...') |
| 549 | fused_list = nn.ModuleList() |
| 550 | for a in list(self.children())[0]: |
| 551 | if isinstance(a, nn.Sequential): |
| 552 | for i, b in enumerate(a): |
| 553 | if isinstance(b, nn.modules.batchnorm.BatchNorm2d): |
| 554 | # fuse this bn layer with the previous conv2d layer |
| 555 | conv = a[i - 1] |
| 556 | fused = torch_utils.fuse_conv_and_bn(conv, b) |
| 557 | a = nn.Sequential(fused, *list(a.children())[i + 1:]) |
| 558 | break |
| 559 | fused_list.append(a) |
| 560 | self.module_list = fused_list |
| 561 | self.info() if not ONNX_EXPORT else None # yolov3-spp reduced from 225 to 152 layers |
| 562 | |
| 563 | def info(self, verbose=False): |
| 564 | torch_utils.model_info(self, verbose) |
no test coverage detected