def forward(self, puzzles):
nBatch = puzzles.size(0)
x = puzzles.view(nBatch,-1)
x = self.fc_in(x)
e = Variable(torch.Tensor())
h = self.G.mv(self.z)+self.s
x = QPFunction(verbose=False)(
self.Q, x, self.G, h, e, e,
)
x = self.fc_out(x)
x = x.view_as(puzzles)
return x
# if __name__=="__main__":
# sudoku = SolveSudoku(2, 0.2)
# puzzle = [[4, 0, 0, 0], [0,0,4,0], [0,2,0,0], [0,0,0,1]]
# Y = Variable(torch.DoubleTensor(np.array([[np.array(np.eye(5,4,-1)[i,:]) for i in row] for row in puzzle])).cuda())
# solution = sudoku(Y.unsqueeze(0))
# print(solution.view(1,4,4,4))
评论列表
文章目录