You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TransformerConv update rule is supposed to handle nodes with node edges and just transform the nodes with the W1 root transformation.
To separate nodes with neighbors to nodes without neighbors, it applies if isinstance(x, Tensor): x = (x, x)
At the beggining. Essentially, if x has no neighbors, than x is a tensor instead of a tuple.
This logic fails when wrapping with HeteroConv in senario where nodes only appear as source nodes but not as target nodes, and with at least two layers of convolutions.
This is because HeteroConv iterates over edge types, and only outputs new representations for destination nodes, as filtered at its end:
` out = conv(*args, **kwargs)
if dst not in out_dict:
out_dict[dst] = [out]
else:
out_dict[dst].append(out)
for key, value in out_dict.items():
out_dict[key] = group(value, self.aggr)
return out_dict`
So on the first layer, nodes that have not incoming edges but only appear as source nodes, will not be transformed at all, and not outputed at all in out_dict for the next layer. elif src in value_dict or dst in value_dict: kwargs[arg] = ( value_dict.get(src, None), value_dict.get(dst, None), )
Then in the next layer, they will appear as None for the input to the TransformerCov, yet still in a tuple.
Then it fails in the key computation of the conv as x[0] is none. key = self.lin_key(x[0]).view(-1, H, C)
This result in HeteroConv with TransformerConv not being able to handle graphs where some node types only appear as source nodes.
Versions
2.6.3
The text was updated successfully, but these errors were encountered:
mayabechlerspeicher
changed the title
HeteroConv with TransformerConv cannot be applied to graphs where some node types only appear as source nodes
HeteroConv cannot be applied to graphs where some node types only appear as source nodes
May 19, 2025
🐛 Describe the bug
TransformerConv update rule is supposed to handle nodes with node edges and just transform the nodes with the W1 root transformation.
To separate nodes with neighbors to nodes without neighbors, it applies
if isinstance(x, Tensor): x = (x, x)
At the beggining. Essentially, if x has no neighbors, than x is a tensor instead of a tuple.
This logic fails when wrapping with HeteroConv in senario where nodes only appear as source nodes but not as target nodes, and with at least two layers of convolutions.
This is because HeteroConv iterates over edge types, and only outputs new representations for destination nodes, as filtered at its end:
` out = conv(*args, **kwargs)
So on the first layer, nodes that have not incoming edges but only appear as source nodes, will not be transformed at all, and not outputed at all in out_dict for the next layer.
elif src in value_dict or dst in value_dict: kwargs[arg] = ( value_dict.get(src, None), value_dict.get(dst, None), )
Then in the next layer, they will appear as None for the input to the TransformerCov, yet still in a tuple.
Then it fails in the key computation of the conv as x[0] is none.
key = self.lin_key(x[0]).view(-1, H, C)
This result in HeteroConv with TransformerConv not being able to handle graphs where some node types only appear as source nodes.
Versions
2.6.3
The text was updated successfully, but these errors were encountered: