| 146 | class LinearStack(torch.nn.Module): |
| 147 | |
| 148 | def __init__(self, input_dim=128, hidden_dim=128, output_dim=128, num_layers=4): |
| 149 | super().__init__() |
| 150 | self.input_dim = input_dim |
| 151 | self.output_dim = output_dim |
| 152 | self.hidden_dim = hidden_dim |
| 153 | |
| 154 | self.input_layer = torch.nn.Linear(in_features=self.input_dim, out_features=self.hidden_dim) |
| 155 | self.layers = torch.nn.ModuleList([ |
| 156 | torch.nn.Linear(in_features=self.hidden_dim, out_features=self.hidden_dim, bias=False) |
| 157 | for x in range(num_layers) |
| 158 | ]) |
| 159 | self.output_layer = torch.nn.Linear(in_features=self.hidden_dim, out_features=self.output_dim) |
| 160 | |
| 161 | self.cross_entropy_loss = torch.nn.CrossEntropyLoss() |
| 162 | |
| 163 | def forward(self, x, y): |
| 164 | x = self.input_layer(x) |