N Neurarch Architectures Checks Docs Open the app

Architectures / Recommendation

๐Ÿ•ธ GraphSAGE Recommender

Inductive node embeddings via neighbor sampling + aggregation โ€” for graph-based recommenders (PinSage style)

Layers
10
Parameters
263.0K
Input
128
Output
128 ร— 64
Verifier
1 advisory

Every number on this page is computed from the graph by the same functions the app runs, not written by hand.

Open GraphSAGE Recommender on the canvas Free, no account needed

When to pick it

Pick when your recsys has a rich item-item or user-item graph and cold-start items must generalize via neighbors (PinSage-style production setup).

Structure

10 layers. Output shapes are propagated from the input shape, batch dimension excluded.

LayerTypeParametersOutput shape
1Node FeaturesInputshape=[128]128
2SAGE Layer 1GraphSAGEoutChannels=256, inChannels=128128 ร— 64
3ReLUReLU128 ร— 64
4DropoutDropoutp=0.2128 ร— 64
5SAGE Layer 2GraphSAGEoutChannels=256, inChannels=256128 ร— 64
6ReLUReLU128 ร— 64
7DropoutDropoutp=0.2128 ร— 64
8SAGE Layer 3GraphSAGEoutChannels=128, inChannels=256128 ร— 64
9LayerNormLayerNormnormalizedShape=[128]128 ร— 64
10Node EmbeddingOutput128 ร— 64

What the verifier says

The same 41 structural checks that run on every edit in the app, on this graph.

warn"LayerNorm" (layerNorm) is the last layer before Output. Normalizing the raw logits constrains the output range and breaks standard loss functions. Fix: Move normalization before the final Linear/Conv layer. (LayerNorm)
bn-at-output

The PyTorch it exports

Generated from the graph above.

# Architecture designed with Neurarch: https://neurarch.com
# PyTorch: compatible with Python 3.8+ and torch>=1.12
# Colab: pip install torch torchvision  (usually pre-installed)

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple

class GraphSAGERecommender(nn.Module):
    def __init__(self):
        super().__init__()

        self.dropout_1 = nn.Dropout(p=0.2)
        self.dropout_2 = nn.Dropout(p=0.2)
        self.layerNorm_1 = nn.LayerNorm(64)

    def forward(self, x):
        # Node Features shape: [128]
        graph_s_a_g_e_sage1 = self.graphSAGE_1(x, edge_index)  # pass edge_index from graph data
        relu_relu1 = F.relu(graph_s_a_g_e_sage1)
        dropout_drop1 = self.dropout_1(relu_relu1)
        graph_s_a_g_e_sage2 = self.graphSAGE_2(dropout_drop1, edge_index)  # pass edge_index from graph data
        relu_relu2 = F.relu(graph_s_a_g_e_sage2)
        dropout_drop2 = self.dropout_2(relu_relu2)
        graph_s_a_g_e_sage3 = self.graphSAGE_3(dropout_drop2, edge_index)  # pass edge_index from graph data
        layer_norm_norm = self.layerNorm_1(graph_s_a_g_e_sage3)
        # Output
        return layer_norm_norm


if __name__ == '__main__':
    model = GraphSAGERecommender()
    model.eval()

    x = torch.randint(0, 50000, (1, 128))  # (batch, features)
    with torch.no_grad():
        output = model(x)

    print(f'Input  shape : {tuple(x.shape)}')
    print(f'Output shape : {tuple(output.shape)}')
    total = sum(p.numel() for p in model.parameters())
    trainable = sum(p.numel() for p in model.parameters() if p.requires_grad)
    print(f'Parameters   : {total:,} total, {trainable:,} trainable')

For agents

This architecture is machine-readable end to end. An agent can list the set, fetch this graph, edit it, and have the edit verified before any GPU time is spent.

Also in Recommendation

๐Ÿ—ผ Two-Tower
User+Item dual encoder for retrieval โ€” embeddings โ†’ MLP per side โ†’ dot product score
12 layers ยท 70.43M
๐Ÿ“ Wide & Deep
Memorization
13 layers ยท 3.65M
๐Ÿ›’ DLRM
Meta's Deep Learning Recommendation Model โ€” bottom MLP for dense, embedding for sparse, feature interaction, top MLP
14 layers ยท 32.35M
๐Ÿค Neural Collaborative Filtering
He et al
16 layers ยท 105.61M