Skip to content

Commit 0fd1cf8

Browse files
committed
using spektral layers
1 parent 3075b60 commit 0fd1cf8

File tree

5 files changed

+10
-950
lines changed

5 files changed

+10
-950
lines changed

Autoencoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from keras.backend import tf
77
from spektral.layers import GraphConvSkip
88
from spektral.layers import MinCutPool
9+
from spektral.utils.convolution import normalized_adjacency
910
from utils.misc import sp_matrix_to_sp_tensor_value, get_sw_key
1011
from tqdm import tqdm
11-
from spektral.utils.convolution import normalized_adjacency
1212
from pygsp import graphs
1313

1414

Clustering.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections import OrderedDict
2+
from tqdm import tqdm
23
import matplotlib.pyplot as plt
34
import numpy as np
45
import pandas as pd
@@ -15,8 +16,7 @@
1516
from spektral.layers.convolutional import GraphConvSkip
1617
from spektral.utils import init_logging
1718
from spektral.utils.convolution import normalized_adjacency
18-
from tqdm import tqdm
19-
from layers import DiffPool, MincutPool
19+
from spektral.layers import MinCutPool, DiffPool
2020
from utils import citation
2121
from utils.misc import sp_matrix_to_sp_tensor_value, product_dict
2222
np.random.seed(0) # for reproducibility
@@ -97,7 +97,6 @@
9797
S_in = Input(tensor=tf.placeholder(tf.int32, shape=(None,), name='segment_ids_in'))
9898

9999
if P['apply_GNN'] and P['method'] != 'diff_pool':
100-
print('DEBUG--applying GNN')
101100
A_norm = normalized_adjacency(A)
102101
X_1 = GraphConvSkip(P['n_channels'],
103102
kernel_initializer='he_normal',
@@ -107,7 +106,7 @@
107106
X_1 = X_in
108107

109108
if P['method'] == 'mincut_pool':
110-
pool1, adj1, seg1, C = MincutPool(k=n_clust,
109+
pool1, adj1, seg1, C = MinCutPool(k=n_clust,
111110
h=P['H_'],
112111
activation=P['ACTIV'])([X_1, A_in, S_in])
113112

Graph_Classification.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from keras.regularizers import l2
1313
from sklearn.model_selection import train_test_split
1414
from spektral.layers import GraphConv, GlobalAvgPool, ARMAConv, GraphConvSkip
15+
from spektral.layers import MinCutPool, DiffPool, TopKPool, SAGPool
1516
from spektral.utils import batch_iterator, log, init_logging
1617
from spektral.utils.convolution import normalized_adjacency
1718
from spektral.layers.ops import sp_matrix_to_sp_tensor_value
18-
from layers import MincutPool, DiffPool, TopKPool, SAGPool
1919
from utils.dataset_loader import get_graph_kernel_dataset
2020

2121

@@ -77,7 +77,7 @@ def evaluate(A_list, X_list, y_list, ops):
7777
# Tunables
7878
tunables = OrderedDict(
7979
dataset_ID=['PROTEINS'],
80-
method=['flat', 'dense', 'diff_pool', 'top_k_pool', 'mincut_pool', 'sag_pool']
80+
method=['mincut_pool'] # 'flat', 'dense', 'diff_pool', 'top_k_pool', 'mincut_pool', 'sag_pool'
8181
)
8282
log(tunables)
8383

@@ -170,7 +170,7 @@ def evaluate(A_list, X_list, y_list, ops):
170170
elif P['method'] == 'sag_pool':
171171
X_1, A_1, I_1 = SAGPool(0.5)([gc1, A_in, I_in])
172172
elif P['method'] == 'mincut_pool':
173-
X_1, A_1, I_1, M_1 = MincutPool(k=int(average_N // 2),
173+
X_1, A_1, I_1, M_1 = MinCutPool(k=int(average_N // 2),
174174
h=P['mincut_H'],
175175
activation=P['activ'],
176176
kernel_regularizer=l2(P['pool_l2']))([gc1, A_in, I_in])
@@ -202,7 +202,7 @@ def evaluate(A_list, X_list, y_list, ops):
202202
elif P['method'] == 'sag_pool':
203203
X_2, A_2, I_2 = SAGPool(0.5)([gc2, A_1, I_1])
204204
elif P['method'] == 'mincut_pool':
205-
X_2, A_2, I_2, M_2 = MincutPool(k=int(average_N // 4),
205+
X_2, A_2, I_2, M_2 = MinCutPool(k=int(average_N // 4),
206206
h=P['mincut_H'],
207207
activation=P['activ'],
208208
kernel_regularizer=l2(P['pool_l2']))([gc2, A_1, I_1])

Segmentation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from skimage.filters import sobel
88
from skimage.io import imread
99
from keras.models import Model
10-
from layers import DiffPool, MincutPool
10+
from spektral.layers import MinCutPool
1111
from keras import Input
1212
from keras import backend as K
1313
from tqdm import tqdm
@@ -123,8 +123,7 @@ def merge_boundary(graph, src, dst):
123123
A_in = Input(tensor=tf.placeholder(tf.float32, shape=(None, None)), name='A_in')
124124
S_in = Input(tensor=tf.placeholder(tf.int32, shape=(None,), name='segment_ids_in'))
125125

126-
# pool1, adj1, seg1, C = DiffPool(n_clust, activation='relu')([X_in, A_in, S_in])
127-
pool1, adj1, seg1, C = MincutPool(n_clust, activation=ACTIV, h=H_)([X_in, A_in, S_in])
126+
pool1, adj1, seg1, C = MinCutPool(n_clust, activation=ACTIV, h=H_)([X_in, A_in, S_in])
128127

129128
model = Model([X_in, A_in, S_in], [pool1, seg1])
130129
model.compile('adam', None)

0 commit comments

Comments
 (0)