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