Comments (5)
Thanks for your message!
There are two options here and hopefully at least one of them would work for you:
- Option 1: if the graphs change structure over time, define the input as a sequence of graphs tuples as you mention. Then you can use this method to get a signature as in the TF demo, but instead of getting a single signature, you can get getting a signature for each graph in the sequence, and passing this list of signatures as the input_signature to the
tf.function
, because specs passed totf.function
can be arbitrarily nested this should work. - Option 2: If all graphs in the sequence share the same structure (nodes and edges), you can make any node features and edge features have shape [total_num_nodes/edges, sequence_length, feature_size], and just give a single GraphsTuple as the input to your update function. Then inside your update function you can do something like this to build graphs at each step:
def update_fn(input_graph_sequence, ...)
def loop_body(step_i,...):
graph_step_i = input_graph_sequence.replace(
nodes=input_graph_sequence.nodes[:, step_i],
edges=input_graph_sequence.edges[:, step_i])
num_steps = input_graph_sequence.nodes.shape.as_list()[1]
tf.scan(loop_body, tf.range(num_steps), ...)
...
Hope this helps!
from graph_nets.
This worked. Thanks @alvarosg !
from graph_nets.
Follow-on issue:
I am passing batches to the model during training like so:
outputs = tf.convert_to_tensor([model(graphs_tuple) for graphs_tuple in inputs])
As a reminder, each batch is an iterable of GaphsTuple
s, and each GraphsTuple
represents a sequence of graphs for one training data point.
The GraphIndependent
object of the encoder block (EncodeProcessDecode
) throws the error: AttributeError: 'GraphsTuple' object has no attribute 'replace'
. Location of the error according to the stack trace is here in modules.GraphIndependent``._build()
.
Any ideas on how to solve?
from graph_nets.
Could you check the type of the object being passed to the model?
My guess is that the GraphsTuple
input that your are passing is not actually a graphs.GraphsTuple
, but some serialization library or something like that has transformed it into a namedtuple that looks the same, but is not actually the same class, and does not have the extra methods
A simple fix to get the right type just do:
graphs_tuple = graphs.GraphsTuple(*graphs_tuple)
before passing it to EncodeProcessDecode
, but it may be good to understand where the type gets messed up.
from graph_nets.
Your hunch was correct! It was being transformed into collections.GraphsTuple
during the list comprehension:
outputs = tf.convert_to_tensor([model(inputs) for inputs in inputs_train])
Is that^^ the preferred way to feed a batch of graph sequences during the update step? Wondering if it isn't, since when run graphs.GraphsTuple(*inputs)
during training, I receive the following error:
OperatorNotAllowedInGraphError: iterating over 'tf.Tensor' is not allowed: AutGraph did convert this function. This might indicate you are trying to use an unsupported feature.
Checking a bit more, type(inputs)
when this error is thrown is a symbolic tensor, not a GraphsTuple, which I guess means this happens before the backend actually runs the first batch through the model.
from graph_nets.
Related Issues (20)
- GraphTuple from batched tensors does not offset Senders/Receivers HOT 3
- Support Apple Silicon HOT 6
- Error while importing sonnet about gast HOT 1
- AttributeError: module 'sonnet' has no attribute 'AbstractModule' HOT 3
- issue with passing *_model_kwargs parameter HOT 2
- how to build an heterogeneous graph network? HOT 3
- Question about repeat implementation HOT 2
- Inference - shortest path demo HOT 1
- What's the difference between graph_nets and jraph? HOT 3
- Performance issue in /graph_nets/tests (by P3) HOT 2
- Error when calling trained model: "AttributeError: tuple object has no attribute "as_list" HOT 3
- Performance issue HOT 9
- Is this project still live? HOT 2
- Error while using the placeholder function from utils_tf HOT 1
- ZeroDivsion error? HOT 2
- no output from processor HOT 6
- Issue with understanding HOT 2
- TensorFlow 1 is not supported in Google Colab HOT 1
- Problem with plot_compare_graphs function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graph_nets.