google-deepmind / graph_nets

Build Graph Nets in Tensorflow

Home Page:https://arxiv.org/abs/1806.01261

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while trying to run tensoflow2 *sorting* demo in colab

maguileracanon opened this issue · comments

I am trying to run the new tensoflow2 sorting demo but I'm getting this error while running the "Visualize the sort task"

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-5aa1227097fa> in <module>()
      5 
      6 inputs_nodes = inputs.nodes.numpy()
----> 7 targets = utils_tf.nest_to_numpy(targets)
      8 sort_indices_nodes = sort_indices.nodes.numpy()
      9 ranks_nodes = ranks.nodes.numpy()

AttributeError: module 'graph_nets.utils_tf' has no attribute 'nest_to_numpy'


That method is new in the latest version of the library, so I suspect you don't have the correct latest version 1.1 of the library installed.

If you are running on a local kernel, make sure you install the correct version of the dependencies as per README instructions:
pip install graph_nets "tensorflow>=2.1.0-rc1" "dm-sonnet>=2.0.0b0" tensorflow_probability

Note that if you already had a previous version of the graph_nets library library installed, you will need to force updating with either:
pip install "graph_nets>1.1" or pip install --upgrade graph_nets

If you are running in Google Colaboratory, make sure you set Yes in the Install the Graph Nets library on this Colaboratory runtime cell. And run that cell to install the correct dependencies before running anything else. Equivalently you can run !pip install "graph_nets>=1.1" "dm-sonnet>=2.0.0b0" at the start.

This error occurs only when I am running in Google Colaboratory. And I had set the install cell to "Yes". But I am still getting the error

I found that the only way to make it run locally was to setup the package via pip install . from the cloned Github repository because when I tried to install through pip install graph_nets "tensorflow>=2.1.0-rc1" "dm-sonnet>=2.0.0b0" tensorflow_probability the tf2 sort demo is not even there

I just tried in Google Colaboratory, using the hosted kernels and it seems to run fine in my case, may try the demo again in a fresh hosted kernel, and make sure you run the cell after you select "yes". The logs should include something like this indicating that the 1.1 version of the library is being installed:

Found existing installation: dm-sonnet 1.35
Uninstalling dm-sonnet-1.35:
Successfully uninstalled dm-sonnet-1.35
Found existing installation: graph-nets 1.0.5
Uninstalling graph-nets-1.0.5:
Successfully uninstalled graph-nets-1.0.5
Successfully installed dm-sonnet-2.0.0b0 dm-tree-0.1.2 graph-nets-1.1.0

It is expected that demos are not included in the installation packages installed automatically with the library or uploaded to pypi to reduce package and installation size. Easiest way is to just download the demo colabs from the github. So long as demos_tf/models.py is there they should run find.

I tried in another machine this morning and it is working now for me. I am still not sure about what was happening. Thanks.

PS: Will the other examples also be updated for TensorFlow 2 anytime soon ?

Glad to hear it is working :)

Yes, we will eventually provide more examples, either updated versions of those, or new ones, but hopefully the sort example is sufficient to get users started for now!