Skip to content

Instantly share code, notes, and snippets.

@eileen-code4fun
Last active January 6, 2022 21:41
Show Gist options
  • Save eileen-code4fun/2874fa34080b6d0085d615aa4ff25803 to your computer and use it in GitHub Desktop.
Save eileen-code4fun/2874fa34080b6d0085d615aa4ff25803 to your computer and use it in GitHub Desktop.
GCN Model
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