Utility function for network_to_half(). Retained for legacy purposes.
(module)
| 40 | |
| 41 | |
| 42 | def BN_convert_float(module): |
| 43 | """ |
| 44 | Utility function for network_to_half(). |
| 45 | |
| 46 | Retained for legacy purposes. |
| 47 | """ |
| 48 | if isinstance(module, torch.nn.modules.batchnorm._BatchNorm) and module.affine is True: |
| 49 | module.float() |
| 50 | for child in module.children(): |
| 51 | BN_convert_float(child) |
| 52 | return module |
| 53 | |
| 54 | |
| 55 | def network_to_half(network): |