| 258 | return A_raw, A |
| 259 | |
| 260 | def forward_fusion(self, h1, h2, h3): |
| 261 | |
| 262 | if self.fusion_type=='bilinear': |
| 263 | # Append 1 to retain unimodal embeddings in the fusion |
| 264 | h1 = torch.cat((h1, torch.ones(1, 1, dtype=torch.float, device=h1.device)), -1) |
| 265 | h2 = torch.cat((h2, torch.ones(1, 1, dtype=torch.float, device=h2.device)), -1) |
| 266 | h3 = torch.cat((h3, torch.ones(1, 1, dtype=torch.float, device=h3.device)), -1) |
| 267 | |
| 268 | return torch.kron(torch.kron(h1, h2), h3) |
| 269 | |
| 270 | elif self.fusion_type=='kron': |
| 271 | return torch.kron(torch.kron(h1, h2), h3) |
| 272 | |
| 273 | elif self.fusion_type=='concat': |
| 274 | return torch.cat([h1, h2, h3], dim=-1) |
| 275 | else: |
| 276 | print('Not implemeted') |
| 277 | #raise Exception ... |
| 278 | |
| 279 | def forward_survival(self, logits): |
| 280 | Y_hat = torch.topk(logits, 1, dim=1)[1] |