Closed amogh3892 closed 2 years ago
Hi, I'm not sure which file you're running. It looks like the name is _coxPHTrial.py
, which I don't recognize. Is this one of the notebooks in the example folder that you have converted to a python file? Or is it something else?
_coxPHTrial.py is just a file that I created by copying the exact same code/content from CoxPH and Deepsurv notebook example. (https://nbviewer.org/github/havakv/pycox/blob/master/examples/cox-ph.ipynb)
Hmm, so I tried just setting up a new environment with the following commands (on a linux machine)
conda create -n pycox python=3.6.10 ipython jupyter
conda activate pycox
conda install pytorch cpuonly -c pytorch
pip install pycox
pip install sklearn-pandas
and the notebook worked fine. Is there anything here that deviates from the process you were doing? Could you try to repeat these steps and see if it works for you?
Thank you so for the checking on your side.
I sincerely apologize for the confusion
I was passing x_val instead of val in the following line (i.e val_data=x_val)
log = model.fit(x_train, y_train, batch_size, epochs, callbacks, verbose, val_data=val, val_batch_size=batch_size)
It is working now. Apologies again.
No worries. I'm happy you found the bug
Hello,
I am getting the following error while running the demo of CoxPH (DeepSurv). Please help.
I am using the following python version Python 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 23:06:31)
and following pycox version Version: 0.2.2
Traceback (most recent call last): File "_coxPHTrial.py", line 63, in
model.fit(x_train, y_train, batch_size, epochs, callbacks, verbose, val_data=x_val, val_batch_size=batch_size)
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/pycox/models/cox.py", line 53, in fit
**kwargs)
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/torchtuples/base.py", line 294, in fit
log = self.fit_dataloader(dataloader, epochs, callbacks, verbose, metrics, val_dataloader)
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/torchtuples/base.py", line 247, in fit_dataloader
stop = self.callbacks.on_epoch_end()
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/torchtuples/callbacks.py", line 128, in on_epoch_end
stop_signal = self.apply_callbacks(lambda x: x.on_epoch_end())
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/torchtuples/callbacks.py", line 97, in apply_callbacks
stop = func(c)
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/torchtuples/callbacks.py", line 128, in
stop_signal = self.apply_callbacks(lambda x: x.on_epoch_end())
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/torchtuples/callbacks.py", line 289, in on_epoch_end
scores = self.model.score_in_batches_dataloader(self.dataloader)
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/torchtuples/base.py", line 436, in score_in_batches_dataloader
score = self.compute_metrics(data, self.metrics)
File "/Users/amogh3892/anaconda3/lib/python3.6/site-packages/torchtuples/base.py", line 177, in compute_metrics
input, target = data
ValueError: not enough values to unpack (expected 2, got 1)
I was trying to debug it and at some point the data loader tuples contain only one element instead of two. I am not able to fix this. Please help.