TF-GNN Colab Installation
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'
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
!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) ])
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.
I believe this is no longer an issue - our Colab tutorials have been using tfgnn.keras.* for a long time now.