(self, inputs)
| 15 | self.linear2 = nn.Linear(hidden_dim, num_class) |
| 16 | |
| 17 | def forward(self, inputs): |
| 18 | hidden = self.linear1(inputs) |
| 19 | activation = self.activate(hidden) |
| 20 | outputs = self.linear2(activation) |
| 21 | probs = F.softmax(outputs, dim=1) # 获得每个输入属于某一类别的概率 |
| 22 | return probs |
| 23 | |
| 24 | mlp = MLP(input_dim=4, hidden_dim=5, num_class=2) |
| 25 | inputs = torch.rand(3, 4) # 输入形状为(3, 4)的张量,其中3表示有3个输入,4表示每个输入的维度 |
nothing calls this directly
no outgoing calls
no test coverage detected