N Neurarch Architectures Checks Docs Open the app

Architectures / Recommendation

๐Ÿงฎ Neural Collaborative Filtering

He et al. 2017 NCF โ€” user/item embeddings โ†’ concat โ†’ MLP โ†’ score (concat-then-MLP variant)

Layers
12
Parameters
35.21M
Input
1
Output
1 ร— 1
Verifier
Clean

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

Open Neural Collaborative Filtering on the canvas Free, no account needed

When to pick it

Pick as the simplest deep CF baseline before reaching for fused (NeuMF) or graph-based variants. No feature engineering required.

Structure

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

LayerTypeParametersOutput shape
1User IDInputshape=[1]1
2User EmbeddingEmbeddingvocabSize=1000001 ร— 32
3Item IDInputshape=[1]1
4Item EmbeddingEmbeddingvocabSize=10000001 ร— 32
5Concat [u; i]Concatenate1 ร— 64
6MLP 1LinearoutFeatures=64, inFeatures=641 ร— 64
7ReLU 1ReLU1 ร— 64
8MLP 2LinearoutFeatures=32, inFeatures=641 ร— 32
9ReLU 2ReLU1 ร— 32
10Score HeadLinearoutFeatures=1, inFeatures=321 ร— 1
11SigmoidSigmoid1 ร— 1
12P(click)Output1 ร— 1

What the verifier says

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

info"Sigmoid" feeds directly into Output. PyTorch's nn.CrossEntropyLoss already applies log-softmax internally, an explicit Softmax causes double-application and degrades training stability. Fix: Remove Softmax/Sigmoid for training. Restore it in a separate inference wrapper or ONNX export. (Sigmoid)
output-activation
infoSigmoid saturates to [0,1] / [-1,1], and its gradient approaches zero for large inputs. In networks deeper than 5 layers, this halts learning in early layers. Fix: Use ReLU, GELU, or SiLU for hidden layers. Keep Sigmoid only at binary classification outputs; Tanh in specific contexts (GAN generators, LSTM gates). (Sigmoid)
vanishing-gradient
info9 layers with no BatchNorm, LayerNorm, or GroupNorm. Without normalization, activations can explode or vanish across layers, causing slow or unstable training. Fix: Add BatchNorm after Conv2d (CV tasks), LayerNorm after attention/FFN (NLP/LLM), or GroupNorm for small batch sizes.
deep-no-norm
infoPyTorch initializes Linear/Conv with Kaiming (He) init, which is derived for ReLU-family activations. Feeding a saturating activation (sigmoid/tanh) from a He-initialized layer starts training in the saturated tails, shrinking early gradients. Fix: Initialize these layers with Xavier instead: nn.init.xavier_uniform_(w, gain=nn.init.calculate_gain("sigmoid"|"tanh")), or switch the activation to a ReLU-family one. (Score Head)
init-activation-mismatch

The PyTorch it exports

Generated from the graph above. First 46 lines; the app exports the whole file, plus the training loop, the data contract and a deploy bundle.

# 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 NeuralCollaborativeFiltering(nn.Module):
    def __init__(self):
        super().__init__()

        self.embedding_1 = nn.Embedding(100000, 32)
        self.embedding_2 = nn.Embedding(1000000, 32)
        self.linear_1 = nn.Linear(64, 64)
        self.linear_2 = nn.Linear(64, 32)
        self.linear_3 = nn.Linear(32, 1)

    def forward(self, src, tgt=None):
        # User ID shape: [1]
        # Item ID shape: [1]
        embedding_er_emb = self.embedding_1(src)
        embedding_em_emb = self.embedding_2(tgt)
        concatenate_concat = torch.cat([embedding_er_emb, embedding_em_emb], dim=-1)
        linear_fc1 = self.linear_1(concatenate_concat)
        relu_act1 = F.relu(linear_fc1)
        linear_fc2 = self.linear_2(relu_act1)
        relu_act2 = F.relu(linear_fc2)
        linear_fc3 = self.linear_3(relu_act2)
        sigmoid_sig = torch.sigmoid(linear_fc3)
        # Output
        return sigmoid_sig


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

    src = torch.randint(0, 1, (1))  # (batch, src_seq_len)
    tgt = torch.randint(0, 1, (1))  # (batch, tgt_seq_len)
    with torch.no_grad():
        output = model(src, tgt)

    print(f'Src shape    : {tuple(src.shape)}')
    print(f'Tgt shape    : {tuple(tgt.shape)}')

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