All models

TripletNet

Three few-shot image learners: the MAML conv base learner, a Matching Network and a Triplet network.

Image classification · 50 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 (14 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
505.1K
Operations
50
Framework
PyTorch
Recurrent
No
Published
ICML 2017
Cited by
8,510 (as of 17 October 2026)
Authors
Chelsea Finn, Pieter Abbeel, Sergey Levine
License
MIT
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
m3202
Graph hash
f456cbf98422faa0d831b5a7a7a813adedbb00cb97c7c70dbbb61866292dc011
Skeleton hash
b0f5651b94129b46058971ce51cadb6412d0748bdede7af51dee40a3480f6674
Architecture hash
7122b5ab4697afc406cef082cce416f2865333e5bcf94f5b15dc0174e947f99e
Diagram SHA-256
84f37ae88930b23a4afee3dba66cdb29ae89282a077cba1769844753598127ed
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

TripletNet is the triplet network: when fed with 3 samples, the network outputs 2 intermediate values, the L2 distances between the embedded representation of two of its inputs from the representation of the third.

About this model's family

Three few-shot learners share this family: the convolutional base learner from Model-Agnostic Meta-Learning (MAML), a Matching Network and a Triplet network, all small image networks meant to solve new learning tasks using only a small number of training samples. MAML's idea is to train the model's initial parameters such that the model has maximal performance on a new task after the parameters have been updated through one or more gradient steps. In effect, the method trains the model to be easy to fine-tune. The network traced here is MAML's classification learner, which has 4 modules with a 3 × 3 convolutions and 64 filters, followed by batch normalization, a ReLU nonlinearity, and 2 × 2 max-pooling. For MiniImagenet the paper used 32 filters per layer to reduce overfitting, and that is the width the captured member carries.

The Matching Network comes from Matching Networks for One Shot Learning, which learns a network that maps a small labelled support set and an unlabelled example to its label, obviating the need for fine-tuning to adapt to new class types. Its output for a new class is a linear combination of the labels in the support set. The weights come from an attention kernel, the simplest form being the softmax over the cosine distance between the embedded query and support examples. The paper's second insight is a training procedure built on a simple principle: test and train conditions must match. The embedding the captured member uses is the paper's simple yet powerful CNN: a stack of modules, each a 3 × 3 convolution with 64 filters followed by batch normalization, a Relu non-linearity and 2 × 2 max-pooling. The captured build leaves out the Full Contextual Embeddings, the LSTM additions that on Omniglot made no difference.

The Triplet network, from Deep metric learning using Triplet network, aims to learn useful representations by distance comparisons rather than as a side effect of classification. It is comprised of 3 instances of the same feedforward network with shared parameters, and when fed with 3 samples it outputs the two L2 distances between the embedded representation of two of its inputs from the representation of the third. A SoftMax over the two distances turns the task into a 2-class classification problem: which of x+ and x− is of the same class as x. On STL10 the TripletNet achieved the best known result for non-augmented data.

Key idea. MAML trains the model's parameters so that a small number of gradient steps with a small amount of training data from a new task will produce good generalization performance on that task. Matching Networks learn a network that maps a small labelled support set and an unlabelled example to its label, with no fine-tuning needed for new class types. The Triplet network learns useful representations by distance comparisons, using 3 instances of the same feedforward network with shared parameters.

  • meta-learning
  • few-shot learning
  • one-shot learning
  • MAML
  • Model-Agnostic Meta-Learning
  • MAML-net
  • Matching Networks
  • Matching Nets
  • MatchingNet
  • Triplet network
  • TripletNet
  • metric learning
  • Omniglot
  • miniImageNet
  • learn2learn
  • CNN4
  • Conv4

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

Cite the paper

@misc{he2015deepresiduallearningimage,
      title={Deep Residual Learning for Image Recognition}, 
      author={Kaiming He and Xiangyu Zhang and Shaoqing Ren and Jian Sun},
      year={2015},
      eprint={1512.03385},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/1512.03385}, 
}