コード例 #1
0
 def __init__(self, channels, n_layers, n_out):
     super().__init__()
     tf.random.set_seed(0)
     self.convs = []
     for l in range(n_layers-1):
         tf.random.set_seed(l)
         self.convs.append(GINConv(channels, epsilon=0, mlp_hidden=[channels, channels], kernel_initializer='glorot_uniform', bias_initializer='glorot_uniform'))
     tf.random.set_seed(n_layers-1)
     self.conv2 = GINConv(channels, epsilon=0, mlp_hidden=[channels, n_out], kernel_initializer='glorot_uniform', bias_initializer='glorot_uniform')
コード例 #2
0
 def __init__(self, channels, n_layers):
     super().__init__()
     self.conv1 = GINConv(channels, epsilon=0, mlp_hidden=[channels, channels])
     self.convs = []
     for i in range(1, n_layers):
         self.convs.append(
             GINConv(channels, epsilon=0, mlp_hidden=[channels, channels]))
     self.pool = GlobalAvgPool()
     self.dense1 = Dense(channels, activation='relu')
     self.dropout = Dropout(0.5)
     self.dense2 = Dense(n_out, activation='softmax')
コード例 #3
0
X, A, _, y = ogb.dataset_to_numpy(dataset, dtype='f8')
A = [a.toarray() for a in A]
F = X[0].shape[-1]
X = pad_jagged_array(X, (N, F))
A = pad_jagged_array(A, (N, N))
X_tr, A_tr, y_tr = X[tr_idx], A[tr_idx], y[tr_idx]
X_va, A_va, y_va = X[va_idx], A[va_idx], y[va_idx]
X_te, A_te, y_te = X[te_idx], A[te_idx], y[te_idx]

################################################################################
# BUILD MODEL
################################################################################
X_in = Input(shape=(N, F))
A_in = Input(shape=(N, N))

X_1 = GINConv(32, mlp_hidden=[32], activation='relu')([X_in, A_in])
X_1, A_1 = MinCutPool(N // 2)([X_1, A_in])
X_2 = GINConv(32, mlp_hidden=[32], activation='relu')([X_1, A_1])
X_3 = GlobalSumPool()(X_2)
output = Dense(n_out)(X_3)

# Build model
model = Model(inputs=[X_in, A_in], outputs=output)
opt = Adam(lr=learning_rate)
model.compile(optimizer=opt, loss='mse')
model.summary()

################################################################################
# FIT MODEL
################################################################################
model.fit([X_tr, A_tr],