Closed raphaelmourad closed 3 years ago
Hi,
you have the wrong input shapes for batch mode.
They should be (N, F)
and (N, N)
respectively (since the batch size is implicit when defining Input layers).
One way to circumvent this kind of issues is to use the more modern model subclassing approach, give it a spin :)
Cheers
Ok I got it using reshaping with Lambda layer using keras backend!
Hello Daniele,
I am trying to use batchLoader because I have a set of graphs with the same dimension. But as far as I tried I could not make it work when I use model.fit(). Note that I cannot use your ready to use fonction spektral.models.gcn.GCN(), since I do some feature engineering with classical convolution within my model.
I could easily make my own dataset using examples you provided (thanks for that):
[Graph(n_nodes=5, n_node_features=200, n_edge_features=None, n_labels=5), Graph(n_nodes=5, n_node_features=200, n_edge_features=None, n_labels=5), Graph(n_nodes=5, n_node_features=200, n_edge_features=None, n_labels=5), Graph(n_nodes=5, n_node_features=200, n_edge_features=None, n_labels=5), Graph(n_nodes=5, n_node_features=200, n_edge_features=None, n_labels=5), .................................]
I built batchLoaders from the dataset containing many graphs:
Here is my data from the loader. For each batch, I have a matrix of 5 samples and 200 features, and a graph of 5x5 as inputs, as output the node class (5 binary values, one for each sample).
[[[1 2 2 2 3 2 1 3 1 3 3 0 1 1 1 0 1 3 2 0 2 1 1 0 3 2 1 2 3 2 0 2 1 0 3 2 3 2 3 0 3 2 1 0 2 2 1 0 3 0 3 0 3 2 0 0 1 0 3 2 3 2 3 0 3 2 1 3 1 0 3 0 3 3 1 0 0 1 0 3 2 2 0 3 0 3 1 0 0 1 2 1 0 1 0 3 0 2 0 3 0 0 1 0 1 0 3 0 1 2 0 0 2 3 2 2 3 3 3 2 0 0 3 0 0 2 0 0 0 1 2 0 0 0 2 0 1 3 3 2 1 0 1 0 2 2 1 3 1 0 2 2 3 2 3 3 3 2 0 2 1 1 2 3 3 2 2 1 1 3 1 1 0 2 3 3 2 2 3 2 2 1 0 1 3 2 3 3 3 2 2 2 2 0 2 0 2 2 2 3] [3 3 0 0 1 0 3 0 0 2 1 2 3 2 0 1 0 3 3 0 0 0 1 1 0 0 1 1 1 0 0 3 3 1 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3 3 0 3 3 2 1 0 0 1 0 1 0 2 1 1 0 0 2 1 3 1 0 1 3 1 0 3 3 1 0 3 2 3 0 3 3 2 3 1 3 2 3 2 2 1 3 2 1 3 3 3 1 0 3] [0 1 0 0 0 2 3 3 3 3 2 2 1 1 0 0 1 3 0 2 3 3 0 3 2 2 0 0 1 0 3 1 1 3 3 2 0 3 2 0 0 0 3 0 1 3 3 1 1 1 1 1 1 1 1 3 1 1 1 3 3 1 3 3 1 0 1 3 1 3 1 3 3 3 0 2 2 0 3 2 3 2 0 3 2 0 1 0 0 3 2 2 0 3 2 2 1 1 3 1 1 3 1 3 0 3 2 0 1 1 3 1 0 1 0 2 0 2 0 0 2 1 0 0 2 3 1 3 0 3 1 0 3 0 3 3 2 2 2 1 2 0 1 0 2 2 3 3 1 3 1 0 3 2 2 1 3 3 3 2 2 3 2 0 2 0 1 3 3 2 0 1 0 2 0 1 0 3 0 1 3 3 0 3 2 2 2 3 3 3 3 2 2 0 0 2 2 2 0 2]]] [[[0.2 0.4472136 0.4472136 0.4472136 0.4472136] [0. 1. 0. 0. 0. ] [0. 0. 1. 0. 0. ] [0. 0. 0. 1. 0. ] [0. 0. 0. 0. 1. ]]] [[1 0 0 0 0]]
Here is my model: seqlen=200 N=5
When I run:
I get this message (see bellow). I understand this is due to the fact that the loader gives me a batch (of size 1), thus I have (5, 200, 1) as input feature node matrix. But even after trying to change many times my code, I could not make it work.
Epoch 1/200 WARNING:tensorflow:Model was constructed with shape (None, 200) for input KerasTensor(type_spec=TensorSpec(shape=(None, 200), dtype=tf.float32, name='input_56'), name='input_56', description="created by layer 'input_56'"), but it was called on an input with incompatible shape (None, None, None). WARNING:tensorflow:Model was constructed with shape (None, 5) for input KerasTensor(type_spec=TensorSpec(shape=(None, 5), dtype=tf.float32, name='input_57'), name='input_57', description="created by layer 'input_57'"), but it was called on an input with incompatible shape (None, None, None).
ValueError Traceback (most recent call last)