self.linear1 = nn.Linear(DENSE_HIDDEN_UNITS, DENSE_HIDDEN_UNITS)
self.linear2 = nn.Linear(DENSE_HIDDEN_UNITS, DENSE_HIDDEN_UNITS)
self.linear_out = nn.Linear(DENSE_HIDDEN_UNITS, 1)
self.linear_sub_out = nn.Linear(DENSE_HIDDEN_UNITS, num_sub_targets)
def forward(self, x):
x, _ = self.lstm_1(x)
x, _ = self.lstm_2(x)
avg_pooled_x = torch.mean(x, 1)
max_pooled_x, _ = torch.max(x, 1)
h_conc = torch.cat((max_pooled_x, avg_pooled_x), 1)
h_conc_linear١ = F.relu(self.linear1(h_conc))
h_conc_linear٢ = F.relu(self.linear2(h_conc))
hidden = h_conc + h_conc_linear1 + h_conc_linear2
result = self.linear_out(hidden)
sub_result = self.linear_sub_out(hidden)
out = torch.cat([result, sub_result], 1)
return out