1Konny/Beta-VAE

Tensor dimension bug in visualization code

tonymetger opened this issue · 3 comments

Hi
I just started using your code to play around with beta-VAE and it's great. Unfortunately, there is one bug when I try to turn on visualization:

Traceback (most recent call last):
File "main.py", line 65, in
main(args)
File "main.py", line 24, in main
net.train()
File "/home/tony/Github/Beta-VAE/solver.py", line 178, in train
self.viz_lines()
File "/home/tony/Github/Beta-VAE/solver.py", line 230, in viz_lines
klds = torch.cat([dim_wise_klds, mean_klds, total_klds], 1).cpu()
RuntimeError: invalid argument 0: Tensors must have same number of dimensions: got 2 and 1 at /pytorch/aten/src/TH/generic/THTensorMath.c:3577

Steps to reproduce:
python -m visdom.server
sh run_dsprites_B_gamma100_z10.sh

I guess this is quite easy to fix and it doesn't appear in an earlier version (commit 66fcd41), but I'm very new to Pytorch, so it's hard for me to find a fix.

Thanks again for the code and I hope this can be fixed easily,
Tony

P.S.: Would it be possible for you to add a license so that we can use your code to benchmark other models in our research (which might get published at some point)? That would be great!

Hi. sorry for the late reply, I just checked this issue.

I found that this issue occurs on the latest version of pytorch(0.4), not on the previous versions(0.3.1, 0.3.0, 0.2.0). anyway the bug has been fixed and now the codes will work.(though some warnings may still appear on the latest version 0.4.0 but it seems not a big problem.)

for the license, thank you for noticing me, and I will update regarding this soon.

if you have any questions and find any issues in the near future, feel free to make an issue or contact me via email. thanks.

Hi. Thanks for the fix, it works well now. Odd that the pytorch update caused this...

There is one other bug I came across, which occurs when one sets "--viz-on False" in the parameters. Running the same sh script as above with that option gives me:

Traceback (most recent call last):
File "main.py", line 65, in
main(args)
File "main.py", line 24, in main
net.train()
File "/home/tony/Github/Beta-VAE/solver.py", line 176, in train
self.viz_reconstruction()
File "/home/tony/Github/Beta-VAE/solver.py", line 212, in viz_reconstruction
self.viz.images(images, env=self.viz_name+'_reconstruction',
AttributeError: 'Solver' object has no attribute 'viz'

I tried fixing it myself (see pull request), I would be happy if you could have a look at it and merge it if you like it.

Thanks
Tony

Thank you for your interest and contribution to my humble(?) codes!

I merged your PR after modifying some minor things(e.g. maybe printing and checking the values of "C" on the terminal is necessary because it represents the current capacity of the bottlenecks, though it can also be checked in visdom.)

Your pull request is very helpful and much appreciated.

Thanks
Konny