I got this error when run this model:
class VAMetric(nn.Module):
def init(self):
super(VAMetric, self).init()
self.cnnv1 = nn.Conv2d(1, 128, 5, stride=1, padding=2)
self.cnnv2 = nn.Conv2d(128, 1, 5, stride=1, padding=2)
self.cnna1 = nn.Conv2d(1, 96, 5, stride=1, padding=2)
self.cnna2 = nn.Conv2d(96, 1, 5, stride=1, padding=2)
self.fca = nn.Linear(128, 32)
self.fcv = nn.Linear(1024, 32)
self.fc1 = nn.Linear(64, 1)
self.fc2 = nn.Linear(120, 1)
self.init_params()
def init_params(self):
for m in self.modules():
if isinstance(m, nn.Linear):
nn.init.xavier_uniform(m.weight)
nn.init.constant(m.bias, 0)
def forward(self, vfeat, afeat):
vfeat_1 = torch.FloatTensor(1, 64, 120, 1024).zero_()
afeat_1 = torch.FloatTensor(1, 64, 120, 128).zero_()
vfeat_t = Variable(vfeat_1)
afeat_t = Variable(afeat_1)
vfeat_t[0] = vfeat
afeat_t[0] = afeat
vfeat_t = torch.transpose(vfeat_1, 0, 1)
afeat_t = torch.transpose(afeat_1, 0, 1)
vfeat_t = self.cnnv1(vfeat_t)
afeat_t = self.cnna1(afeat_t)
vfeat_t = self.cnnv2(vfeat_t)
afeat_t = self.cnna2(afeat_t)
vfeat_t = F.sigmoid(self.fcv(vfeat_t))
afeat_t = F.sigmoid(self.fca(afeat_t))
feat = F.sigmoid(self.fc1(torch.cat((vfeat_t, afeat_t), 3)))
feat_ = F.sigmoid(self.fc2(torch.transpose(feat, 2, 3)))
return feat_[0][0]
I scan the same topic and got the idea to update my pytorch to 0.1.2, but I am on pytorch 0.2.0