MrtnMndt / OpenVAE_ContinualLearning

Open-source code for our paper: Unified Probabilistic Deep Continual Learning through Generative Replay and Open Set Recognition
https://doi.org/10.3390/jimaging8040093
MIT License
59 stars 12 forks source link

TypeError: expected Tensor as element 9 in argument 0, but got list #6

Closed limzh123 closed 2 years ago

limzh123 commented 2 years ago

Hi,

I am encountered this issue when I run this command. !python3 eval_openset.py --resume /content/OpenVAE_ContinualLearning/runs/2022-06-27_12-51-44_FashionMNIST_WRN_variational_samples_1_latent_dim_60/model_best.pth.tar --openset-datasets 'SVHN' --var-samples 100 --calc-reconstruction True --epochs 1

The error is:

Traceback (most recent call last): File "eval_openset.py", line 315, in main() File "eval_openset.py", line 112, in main mean_zs_tensor = torch.stack(mean_zs, dim=0) TypeError: expected Tensor as element 9 in argument 0, but got list

Thanks if you could assist me

MrtnMndt commented 2 years ago

Hey,

thanks for the message and for raising the issue. It's a bit tough to debug based on the above output alone, but I think I have an idea what happened.

I think your pre-trained model that you load with --resume is trained on FashionMNIST, but the default dataset that is loaded in the cmdparser is MNIST. What happens now is that it tries to evaluate and get a "correctly classified tensor" (z embedding), but of course this is empty because it does not really correctly classify anything.

We have checked for this scenario in various functions with "isinstance" checks to see if there are empty lists or tensors present. But it does look like in the visualization line that you pasted in your error, we have forgotten this check.

Could you see if it works if you just re-execute your above command with an additional "--dataset FashionMNIST" (to not only indicate the open set dataset you want to check, but also which dataset has been trained on originally).

If this solves the problem and my above hypothesis is correct, I will include the additional mentioned type check so if the same crash happens again the user can get informed

limzh123 commented 2 years ago

Hi, It can work after I added the command --dataset FashionMNIST

Thanks a lot and have a nice day!

MrtnMndt commented 2 years ago

Great, good to know. Happy I could help.