In my attempt to port Node Classification with Graph Neural Networks to keras_core, I hit an issue when trying to pass a list of indices to the gnn_model
line 613:
produces the error:
It seems that instead of considering [1,10,100] as argument, it just considers 1 as argument.
Comment From: prateekgargX
I also tried to cast input into keras_core.KerasTensor
object but that throws the error:
Comment From: AakashKumarNain
Two things:
1. Pass a tensor/ndarray as an input argument to gnn_model(...)
and not a list
2. The second error suggests that your has some inbuilt state. For each layer in the final model, can you check if the layers that you are using in call(...)
has been built? You can check it using the built
attribute
Comment From: prateekgargX
Tried ndarray as well
Interestingly,
input_node_indices
is being cast into tf.Tensor(shape=(3,), dtype=float32)
here with the error thrown for a layer inside Model.
I'll try to make it work with your suggestions, but it should be noted that I started with code that had no issues using Keras. So something is broken with keras_core
And no graph_conv1
is not built.
these print statements are inside
call(...)
for gnn_model(...)
Comment From: AakashKumarNain
Interestingly, input_node_indices is being cast into tf.Tensor(shape=(3,), dtype=float32)
That is fine. Depending upon the backend, the inputs would be converted to the corresponding tensors.
And no graph_conv1 is not built.
Can you build it and try again?
Comment From: prateekgargX
Not sure how to do that
Comment From: dhantule
Hi @prateekgargX, Thanks for reporting this.
If you convert the input list [1,10,100]
into a tensor using keras.ops.convert_to_tensor
, your code should run without any issues. Attaching gist for reference.