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

TypeError: super() takes at least 1 argument (0 given) #5

Open
tlok666 opened this issue Dec 5, 2018 · 3 comments
Open

TypeError: super() takes at least 1 argument (0 given) #5

tlok666 opened this issue Dec 5, 2018 · 3 comments

Comments

@tlok666
Copy link

tlok666 commented Dec 5, 2018

I used python2.7 to test the example:

import pyvarinf
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
class Net(nn.Module):
def init(self):
super(Net, self).init()
self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
self.fc1 = nn.Linear(320, 50)
self.fc2 = nn.Linear(50, 10)
self.bn1 = nn.BatchNorm2d(10)
self.bn2 = nn.BatchNorm2d(20)
def forward(self, x):
x = self.bn1(F.relu(F.max_pool2d(self.conv1(x), 2)))
x = self.bn2(F.relu(F.max_pool2d(self.conv2(x), 2)))
x = x.view(-1, 320)
x = F.relu(self.fc1(x))
x = self.fc2(x)
return F.log_softmax(x)
model = Net()
var_model = pyvarinf.Variationalize(model)
var_model.cuda()

But Error report: TypeError: super() takes at least 1 argument (0 given)

@leonardblier
Copy link
Contributor

This error is because of python 2.7, it should work fine with python 3. I will add something in the requirements part of the README saying that this module only works for python 3.

@leonardblier
Copy link
Contributor

leonardblier commented Dec 7, 2018

The corresponding PR is here: #6

@tlok666
Copy link
Author

tlok666 commented Dec 7, 2018

This error is because of python 2.7, it should work fine with python 3. I will add something in the requirements part of the README saying that this module only works for python 3.

Hi,
I revised the vi.py:

  1. line228: super(Variationalize,self).init()
  2. revmoe the '.' in line 262, 272 etc
    then, it works for python2.7
    If you need this implement, i could send your email.

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