wohlert/generative-query-network-pytorch

AttributeError: 'int' object has no attribute 'size'

Closed this issue · 4 comments

in draw.py, I get this error at the line 118 (batch_size = z.size(0))
Sorry if this is obvious, thanks for help anyway.

~ % pip show torch :(
Name: torch
Version: 1.0.1.post2

Looks like you are giving the sample function an integer as input. Giving it no argument, i.e. model.sample() should sample from the prior. This can only be done after running the forward function at least once.

I only get this error by running run-draw.py without arguments, I didn't write any code yet. Sadly I cannot debug it right now because I am only running the program with optirun on my optimus laptop. When I get access to debug, I might be more specific about the issue.

Hi again.
I went back to debugging and, well, I don't know where and how precisely I should run the forward function at first.
Also, I do not get the reason for the comment "# Not sustainable if not dataparallel" in the run-draw file.

If you change the following line
x_sample = model.module.sample(args.batch_size) to x_sample = model.sample(args.batch_size)
and run it again it should work, however, doing this will break the script when running on multiple GPUs.