Skip to content

module

allennlp.nn.module

[SOURCE]


Module

class Module(torch.nn.Module)

This is just torch.nn.Module with some extra functionality.

_post_load_state_dict

class Module(torch.nn.Module):
 | ...
 | def _post_load_state_dict(
 |     self,
 |     missing_keys: List[str],
 |     unexpected_keys: List[str]
 | ) -> Tuple[List[str], List[str]]

Subclasses can override this and potentially modify missing_keys or unexpected_keys.

load_state_dict

class Module(torch.nn.Module):
 | ...
 | def load_state_dict(
 |     self,
 |     state_dict: StateDictType,
 |     strict: bool = True
 | ) -> _IncompatibleKeys

Same as torch.nn.Module.load_state_dict() except we also run the _post_load_state_dict method before returning, which can be implemented by subclasses to customize the behavior.

load_state_dict_distributed

class Module(torch.nn.Module):
 | ...
 | def load_state_dict_distributed(
 |     self,
 |     state_dict: Optional[StateDictType],
 |     strict: bool = True
 | ) -> _IncompatibleKeys