edgarschnfld / CADA-VAE-PyTorch

Official implementation of the paper "Generalized Zero- and Few-Shot Learning via Aligned Variational Autoencoders" (CVPR 2019)
MIT License
283 stars 57 forks source link

A problem about the loss and accuracy. #6

Closed Hanzy1996 closed 5 years ago

Hanzy1996 commented 5 years ago

When I train the VAE, the loss decreases first, but then the loss increases and will never decrease any more. For example, during training: epoch 0 | iter 0 | loss 8543. epoch 0 | iter 50 | loss 5377. epoch 0 | iter 100 | loss 4846. epoch 1 | iter 0 | loss 4675. .... epoch 19 | iter 0 | loss 3503. epoch 19 | iter 50 | loss 3372. epoch 19 | iter 100 | loss 3357. epoch 20 | iter 0 | loss 3681. ... epoch 35 | iter 0 | loss 6382. epoch 35 | iter 50 | loss 6518. epoch 35 | iter 100 | loss 6475. ... epoch 99 | iter 0 | loss 13399 epoch 99 | iter 50 | loss 12820 epoch 99 | iter 100 | loss 13844

Then, during test, the results are not good, like: [0.0] novel=0.0020, seen=0.0004, h=0.0007 , loss=5.0318 [1.0] novel=0.0024, seen=0.0014, h=0.0018 , loss=4.7751 [2.0] novel=0.0014, seen=0.0074, h=0.0023 , loss=4.5471 ... [20.0] novel=0.0020, seen=0.0351, h=0.0038 , loss=2.5270 [21.0] novel=0.0020, seen=0.0345, h=0.0038 , loss=2.4551 [22.0] novel=0.0020, seen=0.0369, h=0.0038 , loss=2.4068

How could I fix this problem?

Hanzy1996 commented 5 years ago

SEE https://github.com/edgarschnfld/CADA-VAE-PyTorch/issues/3#issuecomment-500818861

Hanzy1996 commented 5 years ago

I have got the similar results with the paper. May I ask why the choice of pytorch have so huge effect on the performance? Since the effect can't be ignored, which version of pytorch is the best choice until now?

edgarschnfld commented 5 years ago

I only worked with pytorch 0.4.1, so that seems the best choice. Apart from that, I do not know why different pytorch versions behave differently.

Hanzy1996 commented 5 years ago

Much appreciation! One last confusion, do you use python2 or python3?

edgarschnfld commented 5 years ago

You're welcome :) I used python 3.5.6, to be very precise.

Hanzy1996 commented 5 years ago

Thanks so much. I think the main problem is the version of python. The code works well with python3 no matter which pytorch I use. But the results are bad when I use python2. Maybe you could remind others that python3 is a better choice in your README. By the way, your work is so excellent and I am so inspired.

edgarschnfld commented 5 years ago

I updated the readme. Thank you for the kind words, and good luck with your work :)

divyanshusharma1709 commented 4 years ago

Hi! I know this issue is really old, but I am having the same error as @Hanzy1996. I have setup the environment exactly as mentioned by the author, but still get these results:

[0.0] novel=0.0000, seen=0.0182, h=0.0000 , loss=4.0405 [1.0] novel=0.0000, seen=0.0180, h=0.0000 , loss=3.9586 [2.0] novel=0.0000, seen=0.0177, h=0.0000 , loss=3.8913 [3.0] novel=0.0000, seen=0.0168, h=0.0000 , loss=3.8519 [4.0] novel=0.0000, seen=0.0165, h=0.0000 , loss=3.8334 [5.0] novel=0.0000, seen=0.0162, h=0.0000 , loss=3.7746 [6.0] novel=0.0000, seen=0.0166, h=0.0000 , loss=3.7464 [7.0] novel=0.0000, seen=0.0176, h=0.0000 , loss=3.7225 [8.0] novel=0.0000, seen=0.0166, h=0.0000 , loss=3.7080 [9.0] novel=0.0000, seen=0.0165, h=0.0000 , loss=3.6731 [10.0] novel=0.0000, seen=0.0175, h=0.0000 , loss=3.6680 [11.0] novel=0.0000, seen=0.0171, h=0.0000 , loss=3.6450 [12.0] novel=0.0011, seen=0.0162, h=0.0020 , loss=3.6349 [13.0] novel=0.0022, seen=0.0171, h=0.0038 , loss=3.6105 [14.0] novel=0.0022, seen=0.0173, h=0.0038 , loss=3.6129 [15.0] novel=0.0022, seen=0.0176, h=0.0038 , loss=3.6025 [16.0] novel=0.0032, seen=0.0175, h=0.0054 , loss=3.5328 [17.0] novel=0.0032, seen=0.0174, h=0.0054 , loss=3.5407 [18.0] novel=0.0022, seen=0.0175, h=0.0038 , loss=3.5225 [19.0] novel=0.0022, seen=0.0182, h=0.0038 , loss=3.5302 [20.0] novel=0.0022, seen=0.0184, h=0.0039 , loss=3.5368 [21.0] novel=0.0022, seen=0.0167, h=0.0038 , loss=3.5115 [22.0] novel=0.0032, seen=0.0170, h=0.0054 , loss=3.4782 [23.0] novel=0.0056, seen=0.0173, h=0.0085 , loss=3.4906 [24.0] novel=0.0043, seen=0.0175, h=0.0069 , loss=3.4371 [25.0] novel=0.0045, seen=0.0166, h=0.0071 , loss=3.4738 [26.0] novel=0.0067, seen=0.0175, h=0.0097 , loss=3.4174 [27.0] novel=0.0056, seen=0.0184, h=0.0086 , loss=3.4653 [28.0] novel=0.0067, seen=0.0177, h=0.0097 , loss=3.4711 [29.0] novel=0.0077, seen=0.0175, h=0.0107 , loss=3.4394 [30.0] novel=0.0077, seen=0.0178, h=0.0108 , loss=3.4429 [31.0] novel=0.0099, seen=0.0174, h=0.0126 , loss=3.4128 [32.0] novel=0.0109, seen=0.0177, h=0.0135 , loss=3.4260 [33.0] novel=0.0120, seen=0.0178, h=0.0143 , loss=3.4201 [34.0] novel=0.0120, seen=0.0180, h=0.0144 , loss=3.3901 [35.0] novel=0.0109, seen=0.0177, h=0.0135 , loss=3.3965 [36.0] novel=0.0142, seen=0.0173, h=0.0156 , loss=3.4226 [37.0] novel=0.0142, seen=0.0174, h=0.0156 , loss=3.4043 [38.0] novel=0.0142, seen=0.0188, h=0.0162 , loss=3.4088 [39.0] novel=0.0152, seen=0.0188, h=0.0168 , loss=3.4133 [40.0] novel=0.0152, seen=0.0175, h=0.0163 , loss=3.4013 [41.0] novel=0.0174, seen=0.0179, h=0.0176 , loss=3.4220 [42.0] novel=0.0184, seen=0.0175, h=0.0180 , loss=3.4031 [43.0] novel=0.0163, seen=0.0185, h=0.0173 , loss=3.3607 [44.0] novel=0.0152, seen=0.0179, h=0.0165 , loss=3.3655 [45.0] novel=0.0152, seen=0.0180, h=0.0165 , loss=3.3808 [46.0] novel=0.0163, seen=0.0179, h=0.0170 , loss=3.3966 [47.0] novel=0.0195, seen=0.0187, h=0.0191 , loss=3.3460 [48.0] novel=0.0195, seen=0.0179, h=0.0187 , loss=3.3633 [49.0] novel=0.0206, seen=0.0172, h=0.0187 , loss=3.3768

edgarschnfld commented 4 years ago

Hi, I added cadavae.yaml, so with conda env create --file=cadavae.yml you will have a replica of my currently installed environment for this repository. Let me know if it is still not working after that.

divyanshusharma1709 commented 4 years ago

Hi @edgarschnfld ! Thanks for the swift reply. It seems that I made a mistake in loading the data. Confirmed working for PyTorch 1.4 and Python 3.6

edgarschnfld commented 4 years ago

Great, thanks for confirming that it works for other PyTorch and Python versions :)