Get number of (optionally, trainable) parameters in the module.
(self, only_trainable: bool = False)
| 76 | """ |
| 77 | |
| 78 | def num_parameters(self, only_trainable: bool = False) -> int: |
| 79 | """ |
| 80 | Get number of (optionally, trainable) parameters in the module. |
| 81 | """ |
| 82 | params = filter(lambda x: x.requires_grad, self.parameters()) if only_trainable else self.parameters() |
| 83 | return sum(p.numel() for p in params) |
| 84 | |
| 85 | @staticmethod |
| 86 | def _hook_rss_memory_pre_forward(module, *args, **kwargs): |
nothing calls this directly
no outgoing calls
no test coverage detected