Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Invalid Error #5

Closed
yellowtownhz opened this issue Nov 8, 2017 · 3 comments
Closed

Type Invalid Error #5

yellowtownhz opened this issue Nov 8, 2017 · 3 comments

Comments

@yellowtownhz
Copy link

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)
@timomernick
Copy link
Owner

timomernick commented Nov 8, 2017

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))

@timomernick
Copy link
Owner

Confirmed this is python3 int/float stuff, fixed in b193a4c

@yellowtownhz
Copy link
Author

it works!~
thank u so much~ :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants