pyvarinf
pyvarinf copied to clipboard
TypeError: super() takes at least 1 argument (0 given)
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)
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.
The corresponding PR is here: #6
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:
- line228: super(Variationalize,self).init()
- revmoe the '.' in line 262, 272 etc then, it works for python2.7 If you need this implement, i could send your email.