Question about using from_networkx #2150
-
Hi! Sorry in advance if this simply betrays my lack of understanding: I am using utils.from_networkx to create a Data object. My networkx graph has four features per node, and one feature per edge, as I construct it like this: clusterx = nx.Graph() and something similar for the edges; then I convert to a data object like so: cluster = from_networkx( clusterx ) Everything fine up to here, but then, when I interrogate cluster (a torch_geometric.Data object) about the number of node features I get 1, when I expected to get 4 (spec, x, y, z). Am I misunderstanding something here? All the data seems to be there in cluster, because cluster.keys produces 'x', 'edge_index', 'y', etc, but I am surprised by the fact that num_node_features produces an unexpected result. Sorry if this is a trivial issue. Thanks Eduardo |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is to be expected since data.x = torch.stack([data.species, data.x, data.y, data.z], dim=-1) |
Beta Was this translation helpful? Give feedback.
This is to be expected since
num_node_features
will return the node feature size ofdata.x
. In general, we expect that node features are grouped insidedata.x
- in your case, that would mean groupingspecies
,x
,y
andz
into a feature matrix of shape[num_nodes, 4]
: