Created
January 7, 2022 19:58
-
-
Save eileen-code4fun/f01bf4ec7906cb1bf0e469b6d44db6a5 to your computer and use it in GitHub Desktop.
GCN Definition
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, 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