What it does
A dense layer multiplies its input vector by a weight matrix and adds a bias vector. Each output unit has one weight per input and one bias, so it can mix all input features in any proportion. Stacked with a nonlinearity in between, dense layers can approximate complicated functions; on their own they only draw straight boundaries. They appear as the last layer of almost every classifier, where each output is the logit for one class, and inside transformers as the projections and the feed-forward block. In ONNX a dense layer is a Gemm, or a MatMul followed by an Add.
Formula
y = W x + byj = Σi Wji xi + bjShapes and parameters
- Shapes
- Input [N, K] (or [..., K] for MatMul, which applies the same matrix to every position), weights [K, M], bias [M]; output [N, M].
- Parameters
- K × M weights plus M biases. A 4 → 8 hidden layer has 4 × 8 + 8 = 40 parameters; a 2000 → 6 classifier head has 12,006.
- Used for
- Classifier and regression heads, MLPs for tabular data and control, the Q, K, V and output projections in attention, and the feed-forward block of a transformer.
In WeightSpace
This is where most WeightSpace edits land. Catalog models expose biases of their final dense layer (and in one reranker, a few of its weights), within ±8 of the shipped value. The game NPC brains are small dense networks, and every weight and bias in them can be edited.
Where it appears
- Read a phrase aloudKokoro 82M14881M params
- Segment an object by clickingSlimSAM979.7M params
- Translate a Chinese sentenceHelsinki-NLP OPUS-MT97111M params
- Find a caption that fits a photoTinyCLIP ViT-8M/168023M params
- Fill a gap in ChineseBERT Base Chinese74102M params
- Transcribe a short English recordingWav2Vec2 Base 960h7494M params
- Forecast a time seriesGranite TinyTimeMixer R251805K params
- Estimate depth from a photoDepth Anything V2 Small4825M params
- Classify text with your labelsXtremeDistil zero-shot3813M params
- Find an answer in a passageDistilBERT SQuAD3765M params
- Find the most relevant answerall-MiniLM-L6-v23623M params
- Ask a question about a tableGoogle TAPAS Tiny164.5M params
- Rerank search resultsMS MARCO TinyBERT-L2144.4M params
- Track a subject between framesOpenCV VitTrack12174K params
- Remove background noiseGTCRN848K params
- Find video shot changesTransNetV267.6M params
- Land a rocket on the moonDI-engine LunarLander DQN646K params
- Change how a voice speakstiny-voca44.5M params
- Detect speech in a recordingSilero VAD4545K params
- Track fingertips in a photoMediaPipe Hand Landmarker42.0M params
- Balance a pole on a moving cartStable Baselines3 PPO34.6K params
- Balance a swinging pendulumDI-engine Pendulum DDPG34.5K params
- Drive a car out of a valleyStable Baselines3 DQN367K params
- Estimate a vintage car’s fuel economyAuto MPG MLP3257 params
- Find beats and downbeatsBeat This! Small33.2M params
- Find rows and cells in a tablePaddleOCR SLANet+31.9M params
- Gas turbine monitorWeightSpace health monitor3146 params
- Name the emotion in a sentenceALBERT Base v2 Emotion312M params
- Push a puck onto a targetWeightSpace Puck Policy3794 params
- Spot unusual sensor readingsWeightSpace NAB Predictor3745 params
- Swing a two-link robot upwardStable Baselines3 PPO34.8K params
- Classify the tone of a film reviewTensorFlow IMDB CNN22.7M params
- Cut out a portraitMODNet26.5M params
- Fox navigationWeightSpace navigation policy237 params
- Hide and seek seekerWeightSpace seeker policy231 params
- Home occupancyWeightSpace occupancy model229 params
- Meadow animal brainWeightSpace ecosystem brain242 params
- Recognize 18 spoken wordsSpeech Commands 18w21.5M params
- Recognize sounds in a recordingYAMNet24.0M params
- Recognize voice commandsSpeech Commands21.4M params
- Restore punctuation in a transcriptEdge-Punct-Casing27.4M params
- Signal Run guardWeightSpace guard policy224 params
- Support ticket routerWeightSpace ticket router267 params
- Yard truck policyWeightSpace drive policy258 params
- Cell arenaWeightSpace cell policy15 params
- Continue a melodyMagenta MelodyRNN13.2M params
- Finish a cat doodleSketchRNN11.1M params
- Finish a dog doodleSketchRNN11.1M params
- Finish an elephant doodleSketchRNN11.1M params
- Finish an owl doodleSketchRNN11.1M params
- Identify houseplantsMobileNet V11219K params
- Read a facial expressionOpenCV Zoo MobileFaceNet11.2M params
- Recognize a handwritten digitMNIST CNN16.0K params
- Track the pitch of a soundCREPE Tiny1487K params