MCPcopy Create free account
hub / github.com/pytorch/executorch / __init__

Method __init__

exir/tests/models.py:72–86  ·  view source on GitHub ↗
(self, n_layer: int = 1, output_size: int = 1)

Source from the content-addressed store, hash-verified

70
71class MLP(nn.Module):
72 def __init__(self, n_layer: int = 1, output_size: int = 1) -> None:
73 super().__init__()
74 self.n_layer = n_layer
75 self.output_size = output_size
76 # input shape [batch_size, n_layer+output_size]
77 # each linear layer reduce the activation dim 1 size by 1.
78 self.mlp = torch.nn.Sequential(
79 *itertools.chain(
80 *(
81 [nn.Linear(i + output_size, i - 1 + output_size)]
82 + ([nn.ReLU()] if i != 1 else [])
83 for i in range(n_layer, 0, -1)
84 )
85 )
86 )
87
88 def forward(self, inputs: torch.Tensor) -> torch.Tensor:
89 return self.mlp(inputs)

Callers 15

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected