extorch.nn.modules.mlp
- class extorch.nn.modules.mlp.MLP(dim_in: int, dim_out: int, hiddens: Union[Tuple[int], List[int]], dropout: float = 0.0)[source]
Bases:
torch.nn.modules.module.Module
Basic muti-layer perception with relu as the activation function.
- Parameters
dim_in (int) – Input dimension.
dim_out (int) – Output dimension.
hiddens (Union[Tuple[int], List[int]]) – Hidden dimensions.
dropout (float) – Applied dropout rate.
- Examples::
>>> m = MLP(32, 20, (10, 10, 10), 0.1) >>> input = torch.randn(2, 32) # shape [2, 32] >>> output = m(input) # shape [2, 20]
- forward(input: torch.Tensor) torch.Tensor [source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool