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

Method __init__

models/TextRCNN.py:44–53  ·  view source on GitHub ↗
(self, config)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected