jaredleekatzman / DeepSurv

DeepSurv is a deep learning approach to survival analysis.
MIT License
584 stars 173 forks source link

AttributeError: DeepSurv instance has no attribute 'restored_update_params' #9

Closed dareneiri closed 7 years ago

dareneiri commented 7 years ago

I wanted to use the latest version of DeepSurv based on this repository (primarily to save and load my model), and not on pypi (which was updated June 2016). Can you confirm if the below error is a known issue? While I was able to run my model fine previously, I am no longer able to.

I run: network = deepsurv.DeepSurv(15,0.0001) Then: log = network.train(dataset_TRAIN, dataset_VALID, n_epochs = 300)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-aa424000404e> in <module>()

----> 3 log =  network.train(dataset_TRAIN, dataset_VALID, n_epochs = 300)

/usr/local/bin/anaconda2/envs/virtual_env/lib/python2.7/site-packages/deepsurv/deep_surv.pyc in train(self, train_data, valid_data, n_epochs, validation_frequency, patience, improvement_threshold, patience_increase, logger, update_fn, **kwargs)
    394             learning_rate=lr,
    395             momentum = momentum,
--> 396             update_fn = update_fn, **kwargs
    397         )
    398 

/usr/local/bin/anaconda2/envs/virtual_env/lib/python2.7/site-packages/deepsurv/deep_surv.pyc in _get_train_valid_fn(self, L1_reg, L2_reg, learning_rate, **kwargs)
    240         loss, updates = self._get_loss_updates(
    241             L1_reg, L2_reg, deterministic = False,
--> 242             learning_rate=learning_rate, **kwargs
    243         )
    244         train_fn = theano.function(

/usr/local/bin/anaconda2/envs/virtual_env/lib/python2.7/site-packages/deepsurv/deep_surv.pyc in _get_loss_updates(self, L1_reg, L2_reg, update_fn, max_norm, deterministic, **kwargs)
    206 
    207         # If the model was loaded from file, reload params
--> 208         if self.restored_update_params:
    209             for p, value in zip(updates.keys(), self.restored_update_params):
    210                 p.set_value(value)

AttributeError: DeepSurv instance has no attribute 'restored_update_params'
dareneiri commented 7 years ago

I figured it out. I'm able to use TensorboardLogger. Good work!

caicai2526 commented 7 years ago

Recently I want to use deepsurv,but i meet some problems.Your problem i also meet it ,Can you tell me how to deal with? Thank you @ dareneiri

dareneiri commented 7 years ago

@caicai2526 If you want to just run deepsurv, then the version found on pypi (updated last year) will work just fine. If you want to save and load a saved model (which are features only found in this master branch) then you'll need to make a few adjustments to the code, which I mention: https://github.com/jaredleekatzman/DeepSurv/issues/7

Let me know if that helps

caicai2526 commented 7 years ago

@dareneiri Thank you dareneiri.I change version of lasagne,it can work.

caicai2526 commented 7 years ago

Hello dareneiri: Can you tell me how to build dataset and what data format used for deepsurv network train?Can you share your dataset with me or send me a more detail tutorial?Thank you dareniri @dareneiri

dareneiri commented 7 years ago

@caicai2526 I recommend looking for survival data sets, which many sites offer freely as .csv files. There are breast cancer and unemployment examples, just to name a few.