MCPcopy Create free account
hub / github.com/SooLab/CGFormer / num_parameters

Method num_parameters

bert/modeling_utils.py:78–83  ·  view source on GitHub ↗

Get number of (optionally, trainable) parameters in the module.

(self, only_trainable: bool = False)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected