Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All inputs to the layer should be tensors. #31

Open
aloreggia opened this issue Jun 12, 2018 · 8 comments
Open

All inputs to the layer should be tensors. #31

aloreggia opened this issue Jun 12, 2018 · 8 comments

Comments

@aloreggia
Copy link

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
Copy link
Owner

tkipf commented Jun 13, 2018

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

@aloreggia
Copy link
Author

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

@tkipf
Copy link
Owner

tkipf commented Jun 19, 2018

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
Copy link
Author

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
Copy link
Owner

tkipf commented Jun 19, 2018

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
Copy link

tehreemnaqvi commented Aug 9, 2020

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

@thisishardik
Copy link

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
Copy link

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 !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants