Last active
January 6, 2022 21:41
-
-
Save eileen-code4fun/2874fa34080b6d0085d615aa4ff25803 to your computer and use it in GitHub Desktop.
GCN Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dgl.nn.tensorflow import GraphConv | |
class GCN(tf.keras.Model): | |
def __init__(self, g, feat_dim, hidden_dim, class_num): | |
super(GCN, self).__init__() | |
self.g = g | |
self.h1 = GraphConv(feat_dim, hidden_dim, activation=tf.nn.relu, allow_zero_in_degree=True) | |
self.dropout = tf.keras.layers.Dropout(0.5) | |
self.h2 = GraphConv(hidden_dim, class_num), allow_zero_in_degree=True | |
def call(self, features): | |
h = features | |
h = self.h1(self.g, h) | |
h = self.dropout(h) | |
h = self.h2(self.g, h) | |
return h | |
g_model = GCN(g, 1433, 16, 7) | |
loss_fcn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) | |
opt = tf.keras.optimizers.Adam(0.01) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment