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

Method __init__

code/NNModel/attention_module.py:61–71  ·  view source on GitHub ↗
(self, args)

Source from the content-addressed store, hash-verified

59
60class SelfAttention(torch.nn.Module):
61 def __init__(self, args):
62 super(SelfAttention,self).__init__()
63 self.args = args
64 self.linear_q = torch.nn.Linear(args.lstm_dim * 2, args.lstm_dim * 2)
65 # self.linear_k = torch.nn.Linear(configs.BILSTM_DIM * 2, configs.BILSTM_DIM * 2)
66 # self.linear_v = torch.nn.Linear(configs.BILSTM_DIM * 2, configs.BILSTM_DIM * 2)
67 # self.w_query = torch.nn.Linear(configs.BILSTM_DIM * 2, 50)
68 # self.w_value = torch.nn.Linear(configs.BILSTM_DIM * 2, 50)
69 self.w_query = torch.nn.Linear(args.cnn_dim, 50)
70 self.w_value = torch.nn.Linear(args.cnn_dim, 50)
71 self.v = torch.nn.Linear(50, 1, bias=False)
72
73 def forward(self, query, value, mask):
74 # attention_states = self.linear_q(query)

Callers 1

__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected