Giter Club home page Giter Club logo

Comments (10)

louisabraham avatar louisabraham commented on July 29, 2024

Hello, can you produce a minimal reproducible example?

Also, if I understand correctly, the Cox likelihood would be zero in that case so that the log likelihood is not defined.

wouldn't it be one? Can you test with the Breslow approximation?

from lassonet.

louisabraham avatar louisabraham commented on July 29, 2024
image

I think that if the sets are empty, the log-likelihood is just zero.

from lassonet.

lenbrocki avatar lenbrocki commented on July 29, 2024

Sorry for the late response. A minimal example would be:

import torch
from lassonet.cox import CoxPHLoss

loss = CoxPHLoss("breslow")
labels = torch.tensor([[5.0, 0], [2.0, 0]])
hazards = torch.tensor([5.0, 2.0])
print(loss(hazards, labels)) 
#prints nan 

loss = CoxPHLoss("efron")
labels = torch.tensor([[5.0, 0], [2.0, 0]])
hazards = torch.tensor([5.0, 2.0])
print(loss(hazards, labels)) 
#fails with RuntimeError: max(): Expected reduction dim to be specified for input.numel() == 0. Specify the reduction dim with the 'dim' argument.

The error for the Efron method happens because of what I've described above. I think the nan in the breslow case happens because the likelihood is zero. This can for example be seen from your paper https://arxiv.org/pdf/2208.09793.pdf in equation 1: if all $\delta_i$ are zero, the product is zero and then the log of this is not defined.

from lassonet.

louisabraham avatar louisabraham commented on July 29, 2024

from lassonet.

lenbrocki avatar lenbrocki commented on July 29, 2024

Oh I wasn't aware of that, but yes you're right of course. Then the problem becomes why nan is returned and not 0.

from lassonet.

louisabraham avatar louisabraham commented on July 29, 2024

from lassonet.

lenbrocki avatar lenbrocki commented on July 29, 2024

The CoxPHLoss now correctly returns 0. But when I'm trying to use the fixed loss in training I'm getting for batches where all samples have $\delta_i = 0$ this error:

RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

from lassonet.

louisabraham avatar louisabraham commented on July 29, 2024

I think I managed to find a better fix :) Can you test again?

from lassonet.

lenbrocki avatar lenbrocki commented on July 29, 2024

Sorry again for the delay. Yes, it's working now!

from lassonet.

louisabraham avatar louisabraham commented on July 29, 2024

Great!

from lassonet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.