더북(TheBook)
        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
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.