MCPcopy Create free account
hub / github.com/649453932/Chinese-Text-Classification-Pytorch / __init__

Method __init__

models/TextRNN.py:43–51  ·  view source on GitHub ↗
(self, config)

Source from the content-addressed store, hash-verified

41
42class Model(nn.Module):
43 def __init__(self, config):
44 super(Model, self).__init__()
45 if config.embedding_pretrained is not None:
46 self.embedding = nn.Embedding.from_pretrained(config.embedding_pretrained, freeze=False)
47 else:
48 self.embedding = nn.Embedding(config.n_vocab, config.embed, padding_idx=config.n_vocab - 1)
49 self.lstm = nn.LSTM(config.embed, config.hidden_size, config.num_layers,
50 bidirectional=True, batch_first=True, dropout=config.dropout)
51 self.fc = nn.Linear(config.hidden_size * 2, config.num_classes)
52
53 def forward(self, x):
54 x, _ = x

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected