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

Method forward

chp4/mlp_train.py:12–19  ·  view source on GitHub ↗
(self, inputs)

Source from the content-addressed store, hash-verified

10 self.linear2 = nn.Linear(hidden_dim, num_class)
11
12 def forward(self, inputs):
13 hidden = self.linear1(inputs)
14 activation = self.activate(hidden)
15 outputs = self.linear2(activation)
16 # 获得每个输入属于某一类别的概率(Softmax),然后再取对数
17 # 取对数的目的是避免计算Softmax时可能产生的数值溢出问题
18 log_probs = F.log_softmax(outputs, dim=1)
19 return log_probs
20
21# 异或问题的4个输入
22x_train = torch.tensor([[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected