MCPcopy Create free account
hub / github.com/NJUNLP/GTS / __init__

Method __init__

code/NNModel/model.py:10–31  ·  view source on GitHub ↗

double embedding + lstm encoder + dot self attention

(self, gen_emb, domain_emb, args)

Source from the content-addressed store, hash-verified

8
9class MultiInferRNNModel(torch.nn.Module):
10 def __init__(self, gen_emb, domain_emb, args):
11 '''double embedding + lstm encoder + dot self attention'''
12 super(MultiInferRNNModel, self).__init__()
13
14 self.args = args
15 self.gen_embedding = torch.nn.Embedding(gen_emb.shape[0], gen_emb.shape[1])
16 self.gen_embedding.weight.data.copy_(gen_emb)
17 self.gen_embedding.weight.requires_grad = False
18
19 self.domain_embedding = torch.nn.Embedding(domain_emb.shape[0], domain_emb.shape[1])
20 self.domain_embedding.weight.data.copy_(domain_emb)
21 self.domain_embedding.weight.requires_grad = False
22
23 self.dropout1 = torch.nn.Dropout(0.5)
24 self.dropout2 = torch.nn.Dropout(0)
25
26 self.bilstm = torch.nn.LSTM(300+100, args.lstm_dim,
27 num_layers=1, batch_first=True, bidirectional=True)
28 self.attention_layer = SelfAttention(args)
29
30 self.feature_linear = torch.nn.Linear(args.lstm_dim*4 + args.class_num*3, args.lstm_dim*4)
31 self.cls_linear = torch.nn.Linear(args.lstm_dim*4, args.class_num)
32
33 def _get_embedding(self, sentence_tokens, mask):
34 gen_embed = self.gen_embedding(sentence_tokens)

Callers 1

__init__Method · 0.45

Calls 1

SelfAttentionClass · 0.90

Tested by

no test coverage detected