All models

HyperTransformer

A Transformer that writes a small CNN's weights from a handful of labeled examples per class.

Image classification · 554 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (30 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
2.6M
Operations
554
Framework
PyTorch
Recurrent
No
Published
ICML 2022
Cited by
29 (as of 18 October 2026)
Authors
Andrey Zhmoginov, Mark Sandler, Max Vladymyrov
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m25469
Graph hash
63d12107e2dc4b013f9759854a5efb1aa8a405bef1550cac44db845bbcf3efb2
Skeleton hash
c55c21c4ccda7c4471d2b9ee615d8a99c81ef6549b0cdac6f1cdc84908a42d7f
Architecture hash
5aaa924f3f49dfe7b3411289f2e86109cbf9a1a2be320fd23c582af37923fa81
Diagram SHA-256
875c4e09dff7339b257672bb7e8f54dc244a631905e1bcbe54451d69caa9359f
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

About this model's family

HyperTransformer is a few-shot learner that does not fine-tune a classifier so much as write one: a Transformer reads the labeled support images and emits the weights of a small convolutional network directly. The motivation is capacity: with the task-dependent knowledge held in a high-capacity Transformer, the complexity of the whole task space is decoupled from the complexity of any single generated model. That matters most for tiny target networks, where a single fixed, task-independent embedding is not the best one can do.

Weights are produced layer by layer, starting from the first. Each layer's generator receives a concatenation of image embeddings, embeddings of the previous layer's activations and the support labels, so later layers are conditioned on what the already generated layers compute. Alongside the sample tokens, the input sequence holds learnable placeholder tokens, one per slice of the weight tensor to be generated, and their outputs are read off and assembled into the final weights. Self-attention is a deliberate choice because its output is invariant to the order of the support samples. Unlabeled support images can be added to the support set, turning the method semi-supervised without substantial changes to the model or training approach. The paper reports that accuracy grows with the number of unlabeled samples, and peaks only once the Transformer encoder has at least two layers.

Generating only the final logits layer is already enough to beat MAML++ and RFS for smaller CNNs. The margin narrows as the generated CNN grows, with large-model results comparable to those methods. Generating every convolutional layer rather than just the logits helped further, but only below a certain model size: at 8 channels the last layer alone was sufficient. The target networks are 4-layer CNNs identical to those used in MAML++ and many other papers. Batch-norm variables in those networks are learned, not generated. In the PyTorch port the captured members are built from, the Transformer stage takes a set of input embeddings and returns a set of output embeddings that contain the CNN weights.

Key idea. HyperTransformer replaces per-task fine-tuning with a Transformer that, given a few-shot episode, generates the weights of a small CNN in a single pass, trained end to end through the query-set loss.

  • HyperTransformer
  • HT
  • hypernetwork transformer
  • few-shot learning
  • weight generation
  • meta-learning
  • Omniglot
  • semi-supervised few-shot

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{zhmoginov2022hypertransformermodelgenerationsupervised,
      title={HyperTransformer: Model Generation for Supervised and Semi-Supervised Few-Shot Learning}, 
      author={Andrey Zhmoginov and Mark Sandler and Max Vladymyrov},
      year={2022},
      eprint={2201.04182},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2201.04182}, 
}