theislab / cpa

The Compositional Perturbation Autoencoder (CPA) is a deep generative framework to learn effects of perturbations at the single-cell level. CPA performs OOD predictions of unseen combinations of drugs, learns interpretable embeddings, estimates dose-response curves, and provides uncertainty estimates.
BSD 3-Clause "New" or "Revised" License
77 stars 17 forks source link

AttributeError: 'tuple' object has no attribute 'copy' #4

Closed bitcometz closed 1 year ago

bitcometz commented 2 years ago

Hello,

I had download the pretrained model:

146722 Jun 20 04:51 attr.pkl
89559 Jun 20 04:51 history.csv
39920131 Apr 12  2021 model_params.pt
39022 Jun 20 04:51 var_names.csv

And I run

adata = sc.read('/path/GSM_new.h5ad')
cpa.CPA.setup_anndata(adata,
                      drug_key='condition',
                      dose_key='dose_val',
                      categorical_covariate_keys=['cell_type'],
                      control_key='control',
                      combinatorial=True,
                     )

model = cpa.CPA.load('/Path/GSM/test/', adata, use_gpu=True)

But I got errors:

   1551 # copy state_dict so _load_from_state_dict can modify it
   1552 metadata = getattr(state_dict, '_metadata', None)
-> 1553 state_dict = state_dict.copy()
   1554 if metadata is not None:
   1555     # mypy isn't aware that "_metadata" exists in state_dict
   1556     state_dict._metadata = metadata  # type: ignore[attr-defined]

AttributeError: 'tuple' object has no attribute 'copy'

It is ok when I load my own pretrained models.

Could you help with this problem ?

Thanks !!!

Naghipourfar commented 1 year ago

Hi @bitcometz,

Just released a v0.3.0 version. Should be Ok now.

bitcometz commented 1 year ago

Thanks !!!