MCPcopy Create free account
hub / github.com/HIT-SCIR/plm-nlp-code / forward

Method forward

chp4/mlp.py:17–22  ·  view source on GitHub ↗
(self, inputs)

Source from the content-addressed store, hash-verified

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
24mlp = MLP(input_dim=4, hidden_dim=5, num_class=2)
25inputs = torch.rand(3, 4) # 输入形状为(3, 4)的张量,其中3表示有3个输入,4表示每个输入的维度

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected