| 171 | class LinearStackPipe(PipelineModule): |
| 172 | |
| 173 | def __init__(self, input_dim=128, hidden_dim=128, output_dim=128, num_layers=4, **kwargs): |
| 174 | self.input_dim = input_dim |
| 175 | self.output_dim = output_dim |
| 176 | self.hidden_dim = hidden_dim |
| 177 | self.num_layers = num_layers |
| 178 | |
| 179 | layers = [] |
| 180 | layers.append(LayerSpec(torch.nn.Linear, self.input_dim, self.hidden_dim)) |
| 181 | for x in range(self.num_layers): |
| 182 | layers.append(LayerSpec(torch.nn.Linear, self.hidden_dim, self.hidden_dim, bias=False)) |
| 183 | layers.append(lambda x: x) |
| 184 | layers.append(LayerSpec(torch.nn.Linear, self.hidden_dim, self.output_dim)) |
| 185 | |
| 186 | super().__init__(layers=layers, loss_fn=torch.nn.CrossEntropyLoss(), **kwargs) |
| 187 | |
| 188 | |
| 189 | class SimpleOptimizer(torch.optim.Optimizer): |