google-deepmind / graph_nets

Build Graph Nets in Tensorflow
https://arxiv.org/abs/1806.01261
Apache License 2.0
5.34k stars 783 forks source link

Graph Nets tutorial compatibility for TF2 #116

Closed caiodeberaldini closed 3 years ago

caiodeberaldini commented 4 years ago

Hi guys, what's up?

First of all, your lib is something really awesome and incredible. I was excited with the ideas of models' entities invariance and its relational inductive bias that graph networks brings, as stated by you in the article. Congratulations, folks!

Second, I wanna say I'm not a great expert with TF2, but I was really looking for using your lib with this "new" version of TensorFlow, due to its ease. So, I've made a Graph Nets basics tutorial using yours and I was able to run it locally with TF2. Some change in the original code was required, either in graph_nets lib and in graph_nets_basics notebook.

Do you guys mind if I make a PR for this changes? Of course I'm expecting a look-up on the code by you, guys, and hoping for some feedbacks too.

Thanks!

alvarosg commented 4 years ago

Hi Caio!

Thanks for your message and for enjoying the paper and library :)

Actually we had a similar conversation with @Mistobaan last week and he has already submitted a PR #117 today, which we will be reviewing soon. It would be great if you wanted to get involved in that too, or propose other ideas for things to add to it (either as a comment) or in a subsequent PR.

Some change in the original code was required, either in graph_nets lib

I am curious about which changes you required in the library, the library itself was intended to be fully usable in TF2 without any changes, so I would be very interested to hear about any functionality we may have missed!

Thanks!

caiodeberaldini commented 4 years ago

Hi Alvaro, how are you?

Thanks for your reply! I didn't see that PR until your message, but that's great. People are interested in the library :D

I'm truly interested helping and/or get involved with this project, thanks!

When I tried to use the lib in TF2, I had a problem trying to plot the created tensor GraphsTuple. The main issue was that I needed to typecast the offset when using a tensor GraphsTuple in the _compute_stacked_offsets, called in the function graphs_tuple_to_data_dicts. Otherwise, with the original code, replacing tf.Session by corresponding tf.function, it gave me the following error message: 'Failed to convert a NumPy array to a Tensor (Unsupported numpy type: NPY_INT).' It works fine after type casting the return of _compute_stacked_offsets function.

Thanks, see ya!

alvarosg commented 3 years ago

PR #117 is now submitted so closing for now :)