tkipf / keras-gcn

Keras implementation of Graph Convolutional Networks
MIT License
791 stars 266 forks source link

All inputs to the layer should be tensors. #31

Open aloreggia opened 6 years ago

aloreggia commented 6 years ago

Hi, I'm trying to use GCN for graph learning, but when I run your train.py script I get the following error:

Using local pooling filters... Traceback (most recent call last): File "train.py", line 55, in H = GraphConvolution(16, support, activation='relu', kernel_regularizer=l2(5e-4))([H]+G) File "/Users/aloreggia/Documents/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 575, in call self.assert_input_compatibility(inputs) File "/Users/aloreggia/Documents/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 448, in assert_input_compatibility str(inputs) + '. All inputs to the layer ' ValueError: Layer graph_convolution_1 was called with an input that isn't a symbolic tensor. Received type: <class 'theano.sparse.basic.SparseVariable'>. Full input: [if{}.0, SparseVariable{csr,float32}]. All inputs to the layer should be tensors.

Can you help me solving this issue?

Thank you Andrea

tkipf commented 6 years ago

Maybe this is a keras version issue. Can you try with v. 1.0.9?

aloreggia commented 6 years ago

Keras version is 2.2.0. I'm using the Anaconda environment.

tkipf commented 6 years ago

Thanks - it could be that 2.2.0 is not working due to some change in the API. Can you try v.1.0.9?

aloreggia commented 6 years ago

I think I've just get where the code fails with this version of Keras. Creating the Input layers G = [Input(shape=(None, None), batch_shape=(None, None))]

with no specification about sparsity, everything works perfectly. Is this correct?

Thanks Andrea

tkipf commented 6 years ago

Interesting, maybe the new keras version doesn't need the sparsity argument anymore for sparse inputs. Glad you could figure it out. Let's leave this issue open so others can find it in case they run into the same problem.

tehreemnaqvi commented 4 years ago

Hi, I also got this error in keras. Can anyone tell me how to fix it? Thanks

thisishardik commented 2 years ago

I was able to solve this error. Probably my solution helps. What you need to do is define a keras Input layer, for e.g.
inputs = tf.keras.Input(shape=(128, 128, 3)) to feed into the first layer of your model. Use it like this - conv_1 = tf.keras.layers.Conv2D(filters=filters, kernel_size=kernel_size, padding=padding)(inputs)

Hope this helps !!

mrtrieuphong commented 2 years ago

Thank you @thisishardik, it's work for me!

I was able to solve this error. Probably my solution helps. What you need to do is define a keras Input layer, for e.g. inputs = tf.keras.Input(shape=(128, 128, 3)) to feed into the first layer of your model. Use it like this - conv_1 = tf.keras.layers.Conv2D(filters=filters, kernel_size=kernel_size, padding=padding)(inputs)

Hope this helps !!