-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path尝试data.py
73 lines (55 loc) · 1.8 KB
/
尝试data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import torch as th
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.autograd import Variable
import matplotlib.pyplot as plt
import dgl
import networkx as nx
import dgl.function as fn
from dgl.data import MiniGCDataset
import dgl.function as fn
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
from dgl.nn.pytorch import SumPooling
import numpy as np
from dgl.data.utils import save_graphs, get_download_dir, load_graphs
from dgl.subgraph import DGLSubGraph
from torch.utils.data import Dataset, DataLoader
from dset import dgraph, collate
from dgl.nn.pytorch.conv import GraphConv
from torch.nn import Linear
# from experience_poor import replayer, process
# from playagent import agent, play_qlearning
# from environment import env
# from qnet import dqn
# from experience_poor import replayer
from networkx.algorithms.isomorphism import GraphMatcher, DiGraphMatcher
import networkx.algorithms.isomorphism as iso
from net import sub_GMN
device = torch.device('cuda:0')
GCN_in_size, GCN_out_size, q_size, da_size, NTN_k = 10, 128, 5, 18, 16
md = sub_GMN(GCN_in_size, GCN_out_size, q_size, da_size, NTN_k)
md.train()
md.to(device)
a = './数据/train/'
dset = dgraph(root_dir=a)
data_loader = DataLoader(dset, batch_size=2, shuffle=False, collate_fn=collate)
# nm = iso.numerical_node_match('x', 1.0)
# aaaa = torch.arange(10, dtype=torch.float32).reshape(10,1)
for i, (bbg1, bbg2, lllabel, same) in enumerate(data_loader):
print(i)
bbg1.to(device)
bbg2.to(device)
bsame = same.to(device)
y = md(bg_da=bbg1, bg_q=bbg2, b_same=bsame)
print(y)
# print(bbg1)
# print(bbg2)
# print(lllabel)
# print(m)
# print(lllabel.shape)
# print(m.shape)