【导读】本文介绍了一个理由Keras和TensorFlow进行图数据学习、分类的工程。

Github链接：

https://github.com/CVxTz/graph_classification

https://linqs.soe.ucsc.edu/data

python eda.py

python word_features_only.py # for baseline model 53.28% accuracy

python graph_embedding.py # for model_1 73.06% accuracy

python graph_features_embedding.py # for model_2 76.35% accuracy

#### 添加图信息:

def get_graph_embedding_model(n_nodes):

in_1 = Input((1,))

in_2 = Input((1,))

emb = Embedding(n_nodes, 100, name=”node1″)

x1 = emb(in_1)

x2 = emb(in_2)

x1 = Flatten()(x1)

x1 = Dropout(0.1)(x1)

x2 = Flatten()(x2)

x2 = Dropout(0.1)(x2)

x = Multiply()([x1, x2])

x = Dropout(0.1)(x)

x = Dense(1, activation=”linear”, name=”spl”)(x)

model = Model([in_1, in_2], x)

model.summary()

return model

#### 改进图形特征学习

def get_graph_embedding_model(n_nodes, n_features):

in_1 = Input((1,))

in_2 = Input((1,))

in_3 = Input((n_features,))

in_4 = Input((n_features,))

emb = Embedding(n_nodes, 50, name=”node1″)

x1 = emb(in_1)

x2 = emb(in_2)

x1 = Flatten()(x1)

x1 = Dropout(0.02)(x1)

x2 = Flatten()(x2)

x2 = Dropout(0.02)(x2)

x = Multiply()([x1, x2])

d = Dense(10, kernel_regularizer=l2(0.0005), name=”features”)

x1_ = d(in_3)

x2_ = d(in_4)

x_ = Multiply()([x1_, x2_])

x = Concatenate()([x, x_])

x = Dropout(0.02)(x)

x = Dense(1, activation=”linear”, name=”spl”)(x)

model = Model([in_1, in_2, in_3, in_4], x)

model.summary()

return model