(self, gen_emb, domain_emb, args)
| 102 | |
| 103 | class MultiInferCNNModel(torch.nn.Module): |
| 104 | def __init__(self, gen_emb, domain_emb, args): |
| 105 | super(MultiInferCNNModel, self).__init__() |
| 106 | self.args = args |
| 107 | self.gen_embedding = torch.nn.Embedding(gen_emb.shape[0], gen_emb.shape[1]) |
| 108 | self.gen_embedding.weight.data.copy_(gen_emb) |
| 109 | self.gen_embedding.weight.requires_grad = False |
| 110 | |
| 111 | self.domain_embedding = torch.nn.Embedding(domain_emb.shape[0], domain_emb.shape[1]) |
| 112 | self.domain_embedding.weight.data.copy_(domain_emb) |
| 113 | self.domain_embedding.weight.requires_grad = False |
| 114 | |
| 115 | self.attention_layer = SelfAttention(args) |
| 116 | |
| 117 | self.conv1 = torch.nn.Conv1d(gen_emb.shape[1] + domain_emb.shape[1], 128, 5, padding=2) |
| 118 | self.conv2 = torch.nn.Conv1d(gen_emb.shape[1] + domain_emb.shape[1], 128, 3, padding=1) |
| 119 | self.dropout = torch.nn.Dropout(0.5) |
| 120 | |
| 121 | self.conv3 = torch.nn.Conv1d(256, 256, 5, padding=2) |
| 122 | self.conv4 = torch.nn.Conv1d(256, 256, 5, padding=2) |
| 123 | self.conv5 = torch.nn.Conv1d(256, 256, 5, padding=2) |
| 124 | |
| 125 | self.feature_linear = torch.nn.Linear(args.cnn_dim*2 + args.class_num*3, args.cnn_dim*2) |
| 126 | self.cls_linear = torch.nn.Linear(256*2, args.class_num) |
| 127 | |
| 128 | def multi_hops(self, features, lengths, mask, k): |
| 129 | '''generate mtraix mask''' |
nothing calls this directly
no test coverage detected