(self, batch)
| 68 | param_group["lr"] = 0 |
| 69 | |
| 70 | def forward(self, batch): |
| 71 | if self.config.feature.feature_names[0] == "token": |
| 72 | embedding = self.token_embedding( |
| 73 | batch[cDataset.DOC_TOKEN].to(self.config.device)) |
| 74 | seq_length = batch[cDataset.DOC_TOKEN_LEN].to(self.config.device) |
| 75 | else: |
| 76 | embedding = self.char_embedding( |
| 77 | batch[cDataset.DOC_CHAR].to(self.config.device)) |
| 78 | seq_length = batch[cDataset.DOC_CHAR_LEN].to(self.config.device) |
| 79 | output, _ = self.rnn(embedding, seq_length) |
| 80 | |
| 81 | doc_embedding = output.transpose(1, 2) |
| 82 | pooled_outputs = [] |
| 83 | for _, conv in enumerate(self.convs): |
| 84 | convolution = F.relu(conv(doc_embedding)) |
| 85 | pooled = torch.topk(convolution, self.top_k)[0].view( |
| 86 | convolution.size(0), -1) |
| 87 | pooled_outputs.append(pooled) |
| 88 | |
| 89 | doc_embedding = torch.cat(pooled_outputs, 1) |
| 90 | |
| 91 | return self.dropout(self.linear(doc_embedding)) |
nothing calls this directly
no outgoing calls
no test coverage detected