Type Invalid Error
yellowtownhz opened this issue · 3 comments
Hi,
I tried to run ur code, i got an error, do u know how to fix this?
thx~ :)
Here is the Traceback Information:
yellowtown@Yellowtown:/media/yellowtown/Work/Github/pytorch-capsule$ python3.5 main.py
Traceback (most recent call last):
File "main.py", line 61, in
output_unit_size=output_unit_size).cuda()
File "/media/yellowtown/Work/Github/pytorch-capsule/capsule_network.py", line 53, in init
self.reconstruct0 = nn.Linear(num_output_units*output_unit_size, (reconstruction_size * 2) / 3)
File "/home/yellowtown/.local/lib/python3.5/site-packages/torch/nn/modules/linear.py", line 39, in init
self.weight = Parameter(torch.Tensor(out_features, in_features))
TypeError: torch.FloatTensor constructor received an invalid combination of arguments - got (float, int), but expected one of:
- no arguments
- (int ...)
didn't match because some of the arguments have invalid types: (float, int) - (torch.FloatTensor viewed_tensor)
- (torch.Size size)
- (torch.FloatStorage data)
- (Sequence data)
Is this a problem only in Python 3.5? I use 2.7. I can check later on a different machine, but can you try casting to int explicitly like this?
(reconstruction_size * 2) / 3)
to
int(reconstruction_size * 2) / 3))
Confirmed this is python3 int/float stuff, fixed in b193a4c
it works!~
thank u so much~ :)