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

attributes error- graph_nets_basics issue #68

Closed ghost closed 5 years ago

ghost commented 5 years ago

When running the graph_nets_basics.ipynb on Colab, the following code got AttributeError. Thanks.

tf.reset_default_graph()
graph_network = modules.GraphNetwork(
    edge_model_fn=lambda: snt.Linear(output_size=10),
    node_model_fn=lambda: snt.Linear(output_size=15),
    global_model_fn=lambda: snt.Linear(output_size=20))

input_graphs = utils_tf.data_dicts_to_graphs_tuple(graph_dicts)
output_graphs = graph_network(input_graphs)

for var in graph_network.variables:
  print(var)

AttributeErrorTraceback (most recent call last)

in () 8 output_graphs = graph_network(input_graphs) 9 ---> 10 for var in graph_network.variables: 11 print(var) AttributeError: 'GraphNetwork' object has no attribute 'variables'
alvarosg commented 5 years ago

Thank you for pointing this out.

I think this issue may be related to the fact that the library is currently pinned to sonnet v1.23 (see issue).

This is in the process of being fixed, but you may try upgrading sonnet manually in the meantime: pip install dm-sonnet --upgrade (or !pip install dm-sonnet --upgrade if you are in Colaboratory).

Alternatively you may use graph_network.get_variables().

Hope this helps!

ghost commented 5 years ago

It works! Thanks!