Skip to content

Instantly share code, notes, and snippets.

@eileen-code4fun
Created January 7, 2022 19:58
Show Gist options
  • Save eileen-code4fun/f01bf4ec7906cb1bf0e469b6d44db6a5 to your computer and use it in GitHub Desktop.
Save eileen-code4fun/f01bf4ec7906cb1bf0e469b6d44db6a5 to your computer and use it in GitHub Desktop.
GCN Definition
from dgl.nn.tensorflow import GraphConv
class GCN(tf.keras.Model):
def __init__(self, feat_dim, hidden_dim, class_num):
super(GCN, self).__init__()
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, g, features):
h = features
h = self.h1(g, h)
h = self.dropout(h)
h = self.h2(g, h)
return h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment