biomedia-mira / deepscm

Repository for Deep Structural Causal Models for Tractable Counterfactual Inference
MIT License
270 stars 53 forks source link

KeyError: 'hparams' when running tester #11

Open rudolfwilliam opened 1 year ago

rudolfwilliam commented 1 year ago

I trained the full model on Morpho-MNIST using the command

python -m deepscm.experiments.morphomnist.trainer -e SVIExperiment -m ConditionalVISEM --data_dir /path/to/data --default_root_dir /path/to/checkpoints --decoder_type fixed_var.

This worked without issues. However, for running python -m deepscm.experiments.morphomnist.tester -c /path/to/checkpoint/version_0, I get KeyError: 'hparams' in torch.load(checkpoint_path, map_location=torch.device('cpu'))['hparams'].

Indeed, I saw in the debugger that 'hparams' does not exist as dictionary key. However, there exists a key called 'hyper_parameters'. Upon changing that (which already seems wrong), I get an error further down in the line exp_class.load_from_checkpoint(checkpoint_path, pyro_model=model), saying TypeError: __init__() missing 1 required positional argument: 'hparams'.

I checked the code and to me the errors do seem plausible. I would be more surprised if this code would work for anyone. I did use the correct python & package versions.

ktncktnc commented 9 months ago

Do you still want to fix it, I can help.

rudolfwilliam commented 9 months ago

I fixed it myself in the meantime by rewriting the code. Thanks.