| 277 | #raise Exception ... |
| 278 | |
| 279 | def forward_survival(self, logits): |
| 280 | Y_hat = torch.topk(logits, 1, dim=1)[1] |
| 281 | # Model outputs the hazards with sigmoid activation function. |
| 282 | hazards = torch.sigmoid(logits) #size [1, n_classes] h(t|X) := P(T=t|T>=t,X) |
| 283 | #S(t|X) := P(T>=t|X) = TT (1-h(s|X)) for s=1,t. This is computed for each discrete time point t. So for s=1 there is no cum prod. |
| 284 | survival = torch.cumprod(1 - hazards, dim=1) #size [1, n_classes] |
| 285 | |
| 286 | return hazards, survival, Y_hat |
| 287 | |
| 288 | def forward(self, h, stage, h_mol): |
| 289 | |