def forward(self, x):
nBatch = x.size(0)
x = F.max_pool2d(self.conv1(x), 2)
x = F.max_pool2d(self.conv2(x), 2)
x = x.view(nBatch, -1)
L = self.M*self.L
Q = L.mm(L.t()) + self.eps*Variable(torch.eye(self.nHidden)).cuda()
Q = Q.unsqueeze(0).expand(nBatch, self.nHidden, self.nHidden)
G = self.G.unsqueeze(0).expand(nBatch, self.nineq, self.nHidden)
z0 = self.qp_z0(x)
s0 = self.qp_s0(x)
h = z0.mm(self.G.t())+s0
e = Variable(torch.Tensor())
inputs = self.qp_o(x)
x = QPFunction()(Q, inputs, G, h, e, e)
x = x[:,:10]
return F.log_softmax(x)
评论列表
文章目录