From 29b91b15244061f6915bb6b6f82b1bb7d4c58cef Mon Sep 17 00:00:00 2001 From: Rajitha Hathurusinghe Date: Fri, 16 Apr 2021 08:45:24 -0400 Subject: [PATCH 1/3] changes for keras 2.4.3 and tf 2.4.1 --- kegra/layers/graph.py | 12 +++++++----- kegra/train.py | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kegra/layers/graph.py b/kegra/layers/graph.py index 9ed7bd5..b82628a 100644 --- a/kegra/layers/graph.py +++ b/kegra/layers/graph.py @@ -4,7 +4,7 @@ from keras import regularizers from keras.engine import Layer import keras.backend as K - +import tensorflow as tf class GraphConvolution(Layer): """Basic graph convolution layer as in https://arxiv.org/abs/1609.02907""" @@ -44,8 +44,9 @@ def compute_output_shape(self, input_shapes): def build(self, input_shapes): features_shape = input_shapes[0] - assert len(features_shape) == 2 - input_dim = features_shape[1] + print(len(features_shape)) + # assert len(features_shape) == 2 + input_dim = features_shape[-1] self.kernel = self.add_weight(shape=(input_dim * self.support, self.units), @@ -69,11 +70,12 @@ def call(self, inputs, mask=None): supports = list() for i in range(self.support): - supports.append(K.dot(basis[i], features)) + # print(type(basis[i]), type(features)) + supports.append(K.dot(tf.sparse.to_dense(basis[i]), features)) supports = K.concatenate(supports, axis=1) output = K.dot(supports, self.kernel) - if self.bias: + if self.bias is not None: output += self.bias return self.activation(output) diff --git a/kegra/train.py b/kegra/train.py index d6d25d4..842e01e 100644 --- a/kegra/train.py +++ b/kegra/train.py @@ -31,7 +31,8 @@ A_ = preprocess_adj(A, SYM_NORM) support = 1 graph = [X, A_] - G = [Input(shape=(None, None), batch_shape=(None, None), sparse=True)] + G = [Input(shape=(None, None), sparse=True)] + # G = [Input(shape=(None, None), batch_shape=(None, None), sparse=True)] elif FILTER == 'chebyshev': """ Chebyshev polynomial basis filters (Defferard et al., NIPS 2016) """ @@ -42,6 +43,7 @@ support = MAX_DEGREE + 1 graph = [X]+T_k G = [Input(shape=(None, None), batch_shape=(None, None), sparse=True) for _ in range(support)] + # G = [Input(shape=(None, None), sparse=True) for _ in range(support)] else: raise Exception('Invalid filter type.') From c803769033c0a2e5c050007ad2839210ac72926c Mon Sep 17 00:00:00 2001 From: Rajitha Hathurusinghe Date: Fri, 16 Apr 2021 09:15:08 -0400 Subject: [PATCH 2/3] changes for keras 2.4.3 and tf 2.4.1 --- kegra/layers/graph.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kegra/layers/graph.py b/kegra/layers/graph.py index b82628a..3b09f11 100644 --- a/kegra/layers/graph.py +++ b/kegra/layers/graph.py @@ -44,7 +44,6 @@ def compute_output_shape(self, input_shapes): def build(self, input_shapes): features_shape = input_shapes[0] - print(len(features_shape)) # assert len(features_shape) == 2 input_dim = features_shape[-1] From 5b617f46fea21a867e8ebfda7339e220e5327aeb Mon Sep 17 00:00:00 2001 From: Rajitha Hathurusinghe Date: Mon, 19 Apr 2021 19:36:18 -0400 Subject: [PATCH 3/3] changes for keras 2.4.3 and tf 2.4.1 --- kegra/layers/graph.py | 2 -- kegra/train.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/kegra/layers/graph.py b/kegra/layers/graph.py index 3b09f11..e5e0885 100644 --- a/kegra/layers/graph.py +++ b/kegra/layers/graph.py @@ -44,7 +44,6 @@ def compute_output_shape(self, input_shapes): def build(self, input_shapes): features_shape = input_shapes[0] - # assert len(features_shape) == 2 input_dim = features_shape[-1] self.kernel = self.add_weight(shape=(input_dim * self.support, @@ -69,7 +68,6 @@ def call(self, inputs, mask=None): supports = list() for i in range(self.support): - # print(type(basis[i]), type(features)) supports.append(K.dot(tf.sparse.to_dense(basis[i]), features)) supports = K.concatenate(supports, axis=1) output = K.dot(supports, self.kernel) diff --git a/kegra/train.py b/kegra/train.py index 842e01e..ab44c41 100644 --- a/kegra/train.py +++ b/kegra/train.py @@ -32,7 +32,6 @@ support = 1 graph = [X, A_] G = [Input(shape=(None, None), sparse=True)] - # G = [Input(shape=(None, None), batch_shape=(None, None), sparse=True)] elif FILTER == 'chebyshev': """ Chebyshev polynomial basis filters (Defferard et al., NIPS 2016) """ @@ -43,7 +42,6 @@ support = MAX_DEGREE + 1 graph = [X]+T_k G = [Input(shape=(None, None), batch_shape=(None, None), sparse=True) for _ in range(support)] - # G = [Input(shape=(None, None), sparse=True) for _ in range(support)] else: raise Exception('Invalid filter type.')