havakv / pycox

Survival analysis with PyTorch
BSD 2-Clause "Simplified" License
803 stars 188 forks source link

ValueError: cannot convert float NaN to integer #168

Open Serendipity-Sylvia opened 1 year ago

Serendipity-Sylvia commented 1 year ago

Hi, I encounter the problem with code in pycox.model.data.py, the function sample_alive_from_dates has bug that when we create samp

samp = np.empty((dates.size, n_control), dtype=int) samp.fill(np.nan)

howerer, this part always givens the valueerror message that cannot convert float NaN to interger. I would appreciate it if you could check this part, thx.

dkatsimpokis commented 1 year ago

Hi there,

I got the same error (ValueError: cannot convert float NaN to integer) when running the example notebook on CoxTime. For me the error lies when running the function lr_finder() in the following code section:

batch_size = 256
lrfinder = model.lr_finder(x_train, y_train, batch_size, tolerance=2)
_ = lrfinder.plot()

(I can provide a more detailed Traceback upon request).

However, even if I set the learning rate to a specific number and try to estimate the NN in later code, I get the same error.

System specifications: Python v. 3.10 Pytorch v. 2.0.1 Torchtuples v. 0.2.2 Pycox v. 0.2.3