All models

hypertransformer_adapter

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

Image classification · 550 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
843.3K
Operations
550
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
m5397
Graph hash
60517ae6afe848e0f565c54821f5156fa99ad5ebfefde8a0413b96d5a25f0a7f
Skeleton hash
af5b070eddbfbd74da1c06709c9f3522b32f1be3b398d06874bde87e25c707a4
Architecture hash
097d3304b29204891a0bdda01cd3253fb7bdb3c5f55cc62814e0adfe74dcadbe
Diagram SHA-256
a2143a1ad23b12d9ce420ad4a95511f076963dfdc2816ed1baa4de99030bcbc6
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}, 
}