Method
__init__
(
self,
in_features: int,
hidden_features: int,
activation: Optional[Callable] = None,
dropout: float = 0.0,
bias: bool = True,
)
Source from the content-addressed store, hash-verified
| 77 | bias: bool |
| 78 | |
| 79 | def __init__( |
| 80 | self, |
| 81 | in_features: int, |
| 82 | hidden_features: int, |
| 83 | activation: Optional[Callable] = None, |
| 84 | dropout: float = 0.0, |
| 85 | bias: bool = True, |
| 86 | ): |
| 87 | super().__init__() |
| 88 | |
| 89 | self.in_features = in_features |
| 90 | self.hidden_features = hidden_features |
| 91 | self.activation = activation if activation is not None else nn.GELU() |
| 92 | self.dropout = dropout |
| 93 | self.bias = bias |
| 94 | |
| 95 | self.encoder = nn.Linear(in_features, hidden_features, bias=bias) |
| 96 | self.decoder = nn.Linear(hidden_features, in_features, bias=bias) |
| 97 | self.dropout_layer = nn.Dropout(dropout) if dropout > 0 else None |
| 98 | |
| 99 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 100 | x = self.encoder(x) |
Tested by
no test coverage detected