(self, states, len_states)
| 188 | return supervised_output |
| 189 | |
| 190 | def forward_eval(self, states, len_states): |
| 191 | input_emb = self.item_embeddings(states) |
| 192 | mask = torch.ne(states, self.item_num).float().unsqueeze(-1) |
| 193 | input_emb *= mask |
| 194 | input_emb = input_emb.unsqueeze(1) |
| 195 | pooled_outputs = [] |
| 196 | for cnn in self.horizontal_cnn: |
| 197 | h_out = nn.functional.relu(cnn(input_emb)) |
| 198 | h_out = h_out.squeeze() |
| 199 | p_out = nn.functional.max_pool1d(h_out, h_out.shape[2]) |
| 200 | pooled_outputs.append(p_out) |
| 201 | |
| 202 | h_pool = torch.cat(pooled_outputs, 1) |
| 203 | h_pool_flat = h_pool.view(-1, self.num_filters_total) |
| 204 | |
| 205 | v_out = nn.functional.relu(self.vertical_cnn(input_emb)) |
| 206 | v_flat = v_out.view(-1, self.hidden_size) |
| 207 | |
| 208 | out = torch.cat([h_pool_flat, v_flat], 1) |
| 209 | out = self.dropout(out) |
| 210 | supervised_output = self.s_fc(out) |
| 211 | |
| 212 | return supervised_output |
| 213 | |
| 214 | class SASRec(nn.Module): |
| 215 | def __init__(self, hidden_size, item_num, state_size, dropout, device, num_heads=1): |
nothing calls this directly
no outgoing calls
no test coverage detected