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

Method __init__

chp4/mlp_embedding.py:6–15  ·  view source on GitHub ↗
(self, vocab_size, embedding_dim, hidden_dim, num_class)

Source from the content-addressed store, hash-verified

4
5class MLP(nn.Module):
6 def __init__(self, vocab_size, embedding_dim, hidden_dim, num_class):
7 super(MLP, self).__init__()
8 # 词嵌入层
9 self.embedding = nn.Embedding(vocab_size, embedding_dim)
10 # 线性变换:词嵌入层->隐含层
11 self.linear1 = nn.Linear(embedding_dim, hidden_dim)
12 # 使用ReLU激活函数
13 self.activate = F.relu
14 # 线性变换:激活层->输出层
15 self.linear2 = nn.Linear(hidden_dim, num_class)
16
17 def forward(self, inputs):
18 embeddings = self.embedding(inputs)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected