(self, config)
| 41 | |
| 42 | class 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.conv_region = nn.Conv2d(1, config.num_filters, (3, config.embed), stride=1) |
| 50 | self.conv = nn.Conv2d(config.num_filters, config.num_filters, (3, 1), stride=1) |
| 51 | self.max_pool = nn.MaxPool2d(kernel_size=(3, 1), stride=2) |
| 52 | self.padding1 = nn.ZeroPad2d((0, 0, 1, 1)) # top bottom |
| 53 | self.padding2 = nn.ZeroPad2d((0, 0, 0, 1)) # bottom |
| 54 | self.relu = nn.ReLU() |
| 55 | self.fc = nn.Linear(config.num_filters, config.num_classes) |
| 56 | |
| 57 | def forward(self, x): |
| 58 | x = x[0] |
nothing calls this directly
no outgoing calls
no test coverage detected