Course contentsShow
← Machine Learning and Deep Learning
Lesson 2520 of 3,53854. Graph Neural NetworksFree lesson

Heterogeneous Graph Neural Networks

Type-specific transformations and attention for graphs with multiple node and edge types.

Heterogeneous Graph Neural Networks

What you'll learn: How to handle graphs with multiple node types and edge types using specialized transformations and attention mechanisms.

The Challenge of Heterogeneous Graphs

So far, we've worked with homogeneous graphs where all nodes and edges are the same type. But real-world networks are often heterogeneous: a social network might have "User" and "Post" nodes connected by "likes" and "creates" edges; a knowledge graph has "Person," "Organization," and "Location" nodes with different relationship types.

Standard GNNs apply the same transformation to all nodes, which doesn't work when node types have fundamentally different meanings and features.

Type-Specific Transformations

Heterogeneous GNNs use different weight matrices for different node types. Instead of one transformation W, you maintain W_user, W_post, etc. Each node type gets processed by its own learnable parameters, respecting the semantic differences between types.

Similarly, edge types require different message functions. A "likes" relationship carries different meaning than a "creates" relationship, so you use separate transformations for each edge type during aggregation.

Attention Across Heterogeneous Relations

Type-specific attention mechanisms help the model learn which relations matter most. For example, when updating a "User" node, you might attend more strongly to incoming "friend" edges than "viewed" edges, with separate attention weights per relation type.

This combines the semantic-level attention (which relation types matter) with node-level attention (which specific neighbors matter within each relation).

The Architecture Pattern

The general flow: group messages by edge type → apply type-specific transformations → aggregate with type-aware attention → combine information from all relation types → update node representations.

Key Takeaway: Heterogeneous GNNs extend message passing with type-specific transformations and attention mechanisms, allowing the model to respect the semantic differences between node types and edge types in complex, multi-relational graphs.