gnn icon indicating copy to clipboard operation
gnn copied to clipboard

TF-GNN Colab Installation

Open cnhung opened this issue 4 years ago • 3 comments

  4 # Model builder initialization:

----> 5 gnn = tfgnn.keras.ConvGNNBuilder( 6 lambda edge_set_name: WeightedSumConvolution(), 7 lambda node_set_name: tfgnn.keras.layers.NextStateFromConcat(

AttributeError: module 'tensorflow_gnn' has no attribute 'keras'

cnhung avatar Nov 19 '21 08:11 cnhung

Hi,

How are you running your import and install?

This should work as far as I can tell:

https://github.com/tensorflow/gnn/blob/main/tensorflow_gnn/init.py#L22

sibonli avatar Nov 20 '21 03:11 sibonli

!pip install --upgrade pip !git clone https://github.com/tensorflow/gnn.git tensorflow_gnn !install graphviz graphviz-dev

import numpy as np import os

import tensorflow as tf import tensorflow_gnn as tfgnn

Model hyper-parameters:

h_dims = {'user': 256, 'movie': 64, 'genre': 128}

Model builder initialization:

gnn = tfgnn.keras.ConvGNNBuilder( lambda edge_set_name: WeightedSumConvolution(), lambda node_set_name: tfgnn.keras.layers.NextStateFromConcat( tf.keras.layers.Dense(h_dims[node_set_name])) )

Two rounds of message passing to target node sets:

model = tf.keras.models.Sequential([ gnn.Convolve({'genre'}), # sends messages from movie to genre gnn.Convolve({'user'}), # sends messages from movie and genre to users tfgnn.keras.layers.Readout(node_set_name="user"), tf.keras.layers.Dense(1) ])

cnhung avatar Nov 20 '21 04:11 cnhung

Please try with pip install tensorflow-gnn==0.2.0 only (and nothing from git).

If it still fails, please provide a complete repro - WeightedSumConvolution appears to not be from the TF-GNN library.

arnoegw avatar Jul 06 '22 10:07 arnoegw

I believe this is no longer an issue - our Colab tutorials have been using tfgnn.keras.* for a long time now.

arnoegw avatar Mar 24 '23 08:03 arnoegw