mrp(11,15) :- mrp(23). mrp(X,Y) :- mrp(Y,X). :- X=0..15, #count{Y: mrp(X,Y)} = 1. :- X=0..15, #count{Y: mrp(X,Y)} >= 3. reachable(X, Y) :- mrp(X, Y). reachable(X, Y) :- reachable(X, Z), mrp(Z, Y). :- mrp(X, _), mrp(Y, _), not reachable(X, Y). ''' ######## # Define nnMapping and initialze NeurASP object ######## m = FC(40, *[50, 50, 50, 50, 50], 24) nnMapping = {'mrp': m} NeurASPobj = NeurASP(dprogram+aspProgram, nnMapping, optimizers=None) ######## # Load pretrained model ######## saveModelPath = 'data/model.pt' m.load_state_dict(torch.load(saveModelPath, map_location='cpu')) ######## # Start testing ######## NeurASPobj.testConstraint(dataList=dataListTest, obsList=obsListTest, mvppList=[aspProgram])
sp(9,13) :- nn_edge(g, 17, t). sp(2,6) :- nn_edge(g, 18, t). sp(6,10) :- nn_edge(g, 19, t). sp(10,14) :- nn_edge(g, 20, t). sp(3,7) :- nn_edge(g, 21, t). sp(7,11) :- nn_edge(g, 22, t). sp(11,15) :- nn_edge(g, 23, t). sp(X,Y) :- sp(Y,X). mistake :- X=0..15, #count{Y: sp(X,Y)} = 1. mistake :- X=0..15, #count{Y: sp(X,Y)} >= 3. reachable(X, Y) :- sp(X, Y). reachable(X, Y) :- reachable(X, Z), sp(Z, Y). mistake :- sp(X, _), sp(Y, _), not reachable(X, Y). ''' m = FC(40, *[50, 50, 50, 50, 50], 24) nnMapping = {'m': m} optimizer = {'m':torch.optim.Adam(m.parameters(), lr=0.001)} dlpmlnObj = DeepLPMLN(dprogram, nnMapping, optimizer) # process the data dataset = GridProbData("data/data.txt") # print(dataset.valid_data.shape) # print(dataset.train_labels[0]) # sys.exit()