Elamur Research

Memory Matching Networks for One-Shot Image Recognition

Paper · 2018 · Qi Cai, Yingwei Pan, Ting Yao et al.

Summary

Recognizing a new category from a single labelled image requires a different kind of preparation from ordinary image classification. A recognition system trained with many examples of every category may learn useful visual features, yet still struggle when a new task supplies almost no labelled data. Memory Matching Networks, abbreviated MM-Net, addresses this problem by making the training task resemble the eventual test task. During training, the system repeatedly receives a small collection of labelled examples and must classify other images from the same categories. At test time, the procedure stays the same, while the categories change. This is a form of few-shot learning: the aim is to acquire a reusable way of learning from scarce examples.

The paper’s distinctive contribution is to make the current collection of examples influence both sides of image matching. The labelled examples form a support set. Their visual features are written into an external memory, where related examples can be combined and distinct examples can occupy separate slots. Reading from this memory enriches the representation of each support image with information from the surrounding task. A separate contextual learner also reads the memory and generates parameters for the network that represents an unlabelled image. The resulting representations are compared through dot products, and the image receives the label of its strongest match. Adaptation to the new categories therefore happens through memory construction and parameter generation, without an additional round of fine-tuning.

A further contribution concerns variation between tasks. A system prepared only for a fixed number of categories and examples may perform less well when those quantities change. MM-Net uses a memory interface that accommodates support sets of different sizes, allowing the authors to vary the task during training. Their mixed strategy changes both the number of categories and the number of labelled examples available for each category. The intended result is a shared recognition procedure that can handle several few-shot settings without separate training for each setting.

The experiments cover handwritten characters in Omniglot and natural images in miniImageNet. On Omniglot, MM-Net reaches 99.28% mean accuracy for 5-way 1-shot recognition and 97.16% for 20-way 1-shot recognition. On miniImageNet, its reported 5-way mean accuracies are 53.37% with 1-shot support and 66.97% with 5-shot support. The authors also find that mixed training generalizes better across the tested support sizes than training for a fixed setting. These results support the usefulness of combining task-shaped training, external memory, and support-conditioned parameter prediction. They do not establish that every component is independently necessary, that the memory is insensitive to ordering, or that the same gains would carry over to language tasks.

Interesting ideas

Train on the decision you will actually face. MM-Net repeatedly practises recognition from a small labelled collection because that is what it must do at deployment. This makes the training example a complete task rather than an isolated image. The reusable idea is to reproduce the information constraints of the intended application: what examples are available, which labels are known, and what must be inferred. It applies whenever an application has a narrow adaptation budget, including classification systems that must accept new categories from a handful of demonstrations. The relevant match is between training and use, not merely between the visual appearance of their inputs.

Use memory as a common interface. The support collection can change size while the rest of the architecture continues to consume memory slots. This separates the variable amount of task evidence from the interface used to process it. An engineer could borrow that separation when a downstream component needs a predictable input structure but the available examples arrive in irregular quantities. The important design question is what survives compression. MM-Net attempts to retain both shared class characteristics and distinctive examples; a reusable implementation should likewise make explicit which distinctions its memory preserves.

Adapt representations to the current alternatives. An image representation can be useful in general yet poorly suited to distinguishing the categories that happen to occur together. MM-Net lets the support collection alter the representation used for comparison. The idea applies to other matching problems in which relevance depends on the current candidate set. A task-specific representation can emphasize differences that matter locally. The paper’s evidence concerns image categories, so transferring this principle to document matching, lexical decisions, or other settings would require a fresh evaluation.

Generate a limited parameter subset. The contextual learner does not need to regenerate every parameter in the image-processing architecture. In the experimental design, the last convolutional layer on the unlabelled-image branch uses a factorized form whose parameters are predicted from memory. This provides a practical pattern for dynamic adaptation: keep much of the computation stable and make a smaller component depend on current evidence. It is useful when generating an entire network would impose an excessive output burden on the component that produces the weights.

Preserve the original signal while adding context. The support-image embedding combines a transformed memory read with the image’s existing feature vector through a shortcut connection. This gives contextual information a direct route into the representation without forcing it to replace the original features. The pattern is useful whenever shared context may help but individual evidence remains valuable. In another system, the corresponding distinction might be between an item’s own attributes and information gathered from its neighbours. MM-Net supplies an architectural example, although it does not separately quantify the contribution of the shortcut.

Vary the adaptation conditions during training. The authors change both the number of categories and the number of examples per category. This exposes the recognition procedure to variation in how much evidence is available and how many alternatives compete. The broader lesson is to treat task configuration as part of the training distribution. That can matter when a deployed system receives changing inventories or irregular amounts of supervision. The paper supports this idea over its tested few-shot settings; it does not establish unrestricted generalization to any possible task size.

Separate adaptation from iterative optimization. At test time, MM-Net constructs memory and predicts parameters through forward computation. This makes the adaptation procedure different from running repeated gradient updates on a tiny support set. The same distinction can guide engineering choices elsewhere: a system may learn, during a larger training process, how to produce a useful local configuration from a small amount of evidence. That is an architectural possibility instead of an automatic efficiency guarantee. Its practical value depends on the cost and reliability of the memory and parameter-generation components.

Deep dive: Memory Matching Networks for One-Shot Image Recognition

How Memory Matching Networks use support-set memory and predicted network weights to recognize new image categories from very few examples. · about 35 minutes to read

How Mova uses it

For Mova, the small transparent language system in Rust, this paper offers design possibilities rather than evidence of an existing implementation. There is no basis for saying that Mova already contains MM-Net’s memory controller, convolutional architecture, or contextual learner. The useful connection is more specific: a compact system might keep a visible collection of task examples, derive a temporary task representation from them, and use that representation to guide a local decision.

A concrete candidate is a support-set interface for text classification. A user could supply labelled examples for the categories relevant to the current task. Mova could retain those examples explicitly and compare a new item against them. The lesson from MM-Net would be to evaluate whether the representation used for matching should depend on the entire current collection, rather than treating every example independently. This remains a proposed application. The image experiments do not show that such conditioning improves language classification.

The memory-writing rule is also useful as an inspectable design sketch. MM-Net combines an incoming example with its nearest stored representation when the labels agree, while a conflicting label normally leads to a new slot. A transparent language system could expose the corresponding event: which example was considered nearest, whether it had the same label, and whether the new evidence was merged or kept separately. That would make the behaviour of the memory visible to a developer or user. Such visibility would be an additional engineering choice for Mova; the paper evaluates recognition accuracy rather than explanations of memory updates.

The distinction between memory keys and values could help keep numerical similarity separate from explicit category information. In MM-Net, a key is a visual vector and a value is a class label. For a language application, the analogous structure could associate a representation with an explicitly named category. The categories would remain available for inspection even if similarity were computed numerically. This does not make the numerical representation inherently interpretable. It simply preserves a clear boundary between the representation used for matching and the label attached to it.

Parameter prediction deserves more caution. MM-Net uses a bidirectional recurrent learner to generate part of an image-processing network. Reproducing that machinery would introduce learned internal behaviour that may not serve Mova’s preference for transparency. A narrower experiment could first ask whether current support examples should select or configure a small scoring component. The borrowed question is whether adaptation can happen through an explicit computation over available evidence. The exact neural mechanism is optional until an evaluation shows that it is useful.

The training lesson transfers more directly than the image architecture. If Mova is expected to work with changing category inventories and scarce examples, its evaluation should reproduce those conditions. It would be informative to compare a fixed-configuration training procedure with one that varies the available categories and examples. The comparison should use language tasks and measures appropriate to Mova, while keeping the support examples separate from the items being classified.

Any such use should begin with a simple matching baseline. MM-Net combines several mechanisms, and its analysis does not isolate all of them. Mova could therefore borrow the task structure first, then test contextual memory and dynamic configuration separately. This would turn the paper’s architecture into a sequence of reviewable hypotheses: whether explicit examples suffice, whether shared context helps, and whether adapting a scoring component adds value beyond contextual matching.

The problem and its context

Why scarce examples change the task

The paper starts from a tension in visual recognition. Deep convolutional networks can achieve strong performance when supplied with extensive labelled training data. Recognizing a newly introduced category from a single labelled image creates a different situation. There may be enough evidence to identify a visual correspondence, but too little evidence to fit a conventional category-specific classifier reliably.

The authors identify both a data problem and a procedural problem. The data problem is familiar: optimizing a large network from very little supervision risks overfitting. Starting from a pretrained network can help, but the paper notes that transfer becomes less reliable when the earlier task differs substantially from the target task. A representation learned elsewhere may carry useful structure without already providing the distinctions needed for the new categories.

The procedural problem concerns how training examples are organized. Ordinary supervised training can present many examples from each category. Few-shot testing instead presents a small support collection and asks for decisions about other images. A training procedure that never practises that arrangement leaves an important part of the intended behaviour untested during learning.

This matters because the task is relational. An unlabelled image is classified with respect to the categories represented in its current support set. The relevant alternatives can change from one task to the next. A useful system therefore needs both transferable visual knowledge and a way to use the particular examples available now.

MM-Net’s answer is to make each training episode contain both parts of the eventual decision: labelled support examples and separate images to classify. The categories change between episodes, but the recognition procedure remains shared. Through this repetition, the system learns how support evidence should influence a new decision.

Earlier routes to one-shot recognition

The paper organizes earlier approaches into several broad directions. Data augmentation expands a small collection by manufacturing additional training instances. Its purpose is to obtain more usable evidence from what is already available. Transfer learning instead carries knowledge from previous tasks into the new one. The authors discuss work that learns a transformation from a small-sample solution toward the kind of solution that would be available with more examples.

Embedding approaches change the representation in which examples are compared. Instead of fitting a separate classifier from scratch for every new category, they learn a space in which examples from the same category should match well. A new image can then be classified by comparing it with labelled examples. This is the direction in which the authors place MM-Net.

The Siamese Networks baseline illustrates a relatively direct version of that idea. It learns from pairs of images and uses a nearest-neighbour decision in the learned space. Matching Networks goes further by making support-based matching central to the training arrangement. Its fully contextual variant also uses relationships within the support collection when forming representations.

Meta-learning introduces another level of reuse. In the paper’s account, learning within an individual task is distinguished from learning across tasks. The former must happen quickly from scarce evidence. The latter gradually acquires knowledge about how that rapid learning should proceed. The discussed LSTM-based meta-learner learns an update procedure for another network, while MAML seeks parameters that can adapt readily through gradient descent.

These directions overlap in purpose without being identical in mechanism. An embedding system changes the geometry of comparison. An optimization-based learner changes how parameters are updated. A memory-based system provides an explicit place to store task evidence. MM-Net combines support-based matching with memory and parameter prediction, so its contribution cannot be reduced to introducing any one of those ingredients in isolation.

Why external memory enters the design

A recurrent network can process support examples sequentially and keep information in its hidden state. The authors argue that this internal state may provide insufficient capacity or separation for remembering diverse category information. Their alternative is an external memory with distinct slots and explicit reading and writing operations.

The paper situates this choice within earlier memory-network research. Original memory networks augmented neural computation with a storage component. Subsequent end-to-end variants made the arrangement trainable with less supervision. Hierarchical memory addressed access to large storage structures. Key-value memory separated the representation used to address a stored item from the associated information.

MM-Net adopts a key-value structure, but its contents are specific to the recognition task. Keys hold representations derived from support images. Values hold category labels. The memory is built from the current support set and then used to contextualize the matching procedure.

This is different from merely saving every earlier training image for later lookup. The paper compares with a Siamese approach that uses lifelong memory of previous examples. MM-Net’s emphasis is the current task: its memory represents the available support categories and helps configure the computation used to recognize images from them.

Why predict parameters as well as features?

Context can affect a recognition system in different places. It can be appended to a feature, used to reweight stored examples, or used to alter the function that computes a feature. MM-Net uses the last possibility for the unlabelled-image branch.

The authors connect this to earlier work on fast weights, where one network produces context-dependent weights for another. They also discuss parameter-prediction research suggesting that a network’s parameters can contain substantial redundancy. Their cited applications include visual question answering and recognition without category-specific training images.

The resulting motivation is practical. If an embedding network could be configured directly from the current support evidence, it might adapt without optimizing that network on the few available examples. The contextual learner is trained across many episodes to perform this configuration. At test time, it applies that learned procedure to the memory of new categories.

The paper’s distinction from fully contextual Matching Networks lies here. Both use information across support examples. MM-Net additionally uses the support-derived memory to produce parameters for the branch that processes unlabelled images. Its adaptation therefore changes part of the feature-producing computation, rather than only feeding context through a fixed feature-producing architecture.

The method, step by step

Begin with a complete recognition task

The fundamental input is a support set containing labelled images from a small group of categories. Another image is presented without its label. The system must assign it to one of the categories represented in that support set.

Recognition with support-conditioned memory

The steps in order.

Recognition with support-conditioned memoryStep 1: Encode labelled support images1. Encode labelled support imagesStep 2: Write features and labels into memory2. Write features and labels into memoryStep 3: Read memory to enrich support embeddings3. Read memory to enrich support embeddingsStep 4: Encode memory with the contextual learner4. Encode memory with the contextual learnerStep 5: Predict query-branch convolutional parameters5. Predict query-branch convolutional parametersStep 6: Embed each unlabelled image6. Embed each unlabelled imageStep 7: Match embeddings and return a label7. Match embeddings and return a label

The support set is written as:

𝒮 = {(xₙ, yₙ)}ₙ₌₁ᴺ

Here, 𝒮 is the collection of labelled examples, N is its size, xₙ is a support image, and yₙ is that image’s category label. The index n identifies an example. The support collection contains examples from C categories.

The paper’s initial decision rule is:

ŷ = argmaxᵧₙ∈𝒞 P(yₙ | x̂, 𝒮)

The symbol x̂ denotes the unlabelled image. The set 𝒞 contains the available category labels. P gives the class score in the paper’s notation, conditioned on both the image and the support collection. The argmax operation selects the label with the largest score, and ŷ is the resulting prediction.

The dependence on 𝒮 is central. The same image need not be processed in isolation from the alternatives it is being asked to distinguish. Both branches of MM-Net receive information derived from the support collection.

The matching score is defined through the representations:

P(yₙ | x̂, 𝒮) = f(x̂ | 𝒮)ᵀ · g(xₙ | 𝒮)

The function f produces an embedding for the unlabelled image. The function g produces an embedding for a support image. The superscript ᵀ denotes transposition, and the dot indicates a dot product between the resulting vectors. A larger dot product means a stronger match under the learned representation.

Though the paper uses P to denote this quantity, the displayed dot product is a score rather than a normalized probability distribution. During training, exponentiation and normalization turn the support-image scores into the quantities used by the loss. Keeping these stages distinct makes the later objective easier to interpret.

Extract features for the support images

Before memory is built, each support image passes through a convolutional feature extractor. The resulting vector is called zₙ. It has D_z coordinates, where D_z is the dimension of the visual representation.

The experimental support branch contains four convolutional layers. In every layer, a 64-filter convolution with a 3 × 3 kernel precedes batch normalization, followed by ReLU activation and then max-pooling over a 2 × 2 window. These operations progressively transform the image into a feature vector suitable for matching and memory access.

The representation dimension depends on the dataset. D_z is 64 for Omniglot and 1,600 for miniImageNet. Those dimensions belong to the reported experimental architecture; they are not a requirement of the general support-memory idea.

The support feature initially describes an individual image. The next stage places it in a memory that also represents the other examples and categories in the current task.

Give the memory an explicit structure

The external memory consists of key-value pairs:

ℳ = {(mᵢᵏ, mᵢᵛ)}ᵢ₌₁ᴹ

The symbol ℳ denotes memory, and M is the number of slots. In slot i, mᵢᵏ is the key and mᵢᵛ is the associated value. The superscripts distinguish key from value rather than denoting powers.

A key is a D_m-dimensional vector. A value is an integer category label. This means the memory can be addressed through visual similarity while retaining explicit information about category membership.

The image features and memory keys need not have the same dimension. A learned projection maps between their spaces:

zₙᵏ = T_z zₙ

Here, zₙᵏ is the support image’s representation in memory-key space. T_z is a learned transformation matrix with D_m rows and D_z columns. Its role is to convert the image feature zₙ into a vector that can be compared with stored keys.

The experiments set D_m to 512. The memory therefore gives the contextual components a shared representational space even though the original image-feature dimension differs between datasets.

Decide whether to merge or allocate

The write controller processes support examples sequentially. Before the current example is inserted, memory contains information accumulated from earlier support examples. The controller finds the key with the largest dot product against zₙᵏ.

The index of this nearest key is iₙ. The crucial next step is to inspect its value, which is the label mᵢₙᵛ. Visual similarity alone does not determine whether two examples should be merged.

When the nearest stored example has the same category label as the incoming image, the controller updates its key:

mᵢₙᵏ = (mᵢₙᵏ + zₙᵏ) / ‖mᵢₙᵏ + zₙᵏ‖₂

The numerator adds the old key to the incoming representation. The denominator is the Euclidean norm of that sum. Dividing by it normalizes the updated key. The label remains associated with the slot.

This rule lets related examples contribute to a shared representation. It is not a stored arithmetic average over all examples with that label: the current key is normalized after an update, and the incoming vector is then combined with that state. The exact sequence of updates therefore matters to understanding the operation.

If the nearest key has a different label, the controller normally creates a new slot containing the incoming representation and its label. This avoids automatically combining visually similar examples that are known to belong to different categories.

There is an important capacity exception. If memory has no unused slot, the paper applies the same key-update operation even when the nearest stored label differs. The described update changes the key, while the text does not describe a corresponding replacement of the stored value. This is a meaningful boundary condition: limited storage can force an aggregation that the normal label-checking rule would avoid.

After all support examples have been processed, the final memory is denoted ℳ_N. The subscript records that the write procedure has consumed the support collection. Later operations condition on this memory as the compressed representation of the task.

Read shared context for each support image

Writing memory creates a task representation, but support matching still needs an embedding for each labelled image. The read controller retrieves relevant information from the final memory for that purpose.

It begins with a similarity-based attention weight:

aᵢ,ₙ = Softmaxᵢ((zₙᵏ)ᵀ · mᵢᵏ)

The quantity aᵢ,ₙ is the weight assigned to memory slot i when processing support example n. The dot product compares that example’s key-space representation with the stored key. Softmax is applied across the memory slots, so the weights describe relative relevance within the current memory.

The normalization is:

Softmax(vᵢ) = exp(vᵢ) / Σⱼ exp(vⱼ)

The symbol vᵢ is an input score for position i. The function exp exponentiates a score. The denominator sums the exponentiated scores over positions j, turning the collection into normalized weights.

The memory read is then:

cₙ = Σᵢ₌₁ᴹ aᵢ,ₙ mᵢᵏ

The vector cₙ is a weighted combination of the memory keys. Each key contributes according to aᵢ,ₙ. The sum ranges over the M slots.

This operation retrieves key vectors rather than category-label values. The labels help determine how memory is constructed, while the read supplies visual context for representation learning. That distinction matters because the contextual embedding is not simply a lookup of the nearest stored label.

The final support representation combines the retrieved context with the original feature:

g(xₙ | ℳ_N) = T_c cₙ + zₙ

The matrix T_c maps from the D_m-dimensional memory space back to the D_z-dimensional embedding space. It has D_z rows and D_m columns. The vector zₙ is then added through a shortcut connection.

The result preserves direct access to the individual image’s features while incorporating information from the support collection. A support image can therefore be represented differently depending on which other categories and examples accompany it.

Configure the unlabelled-image branch

The unlabelled-image branch also depends on memory, but through a different mechanism. Instead of only adding a retrieved contextual vector, MM-Net predicts parameters used to compute the image’s embedding.

The general parameter-generation relation is:

W = ω(ℳ_N; W′)

The vector W contains the parameters produced for the contextual embedding architecture. Its dimension is D_w. The function ω is the contextual learner, and W′ denotes that learner’s own parameters. Memory ℳ_N is its task-specific input.

There are therefore two timescales in the computation. Across training episodes, optimization learns W′ and the other shared parameters. Within a particular task, the trained contextual learner uses the current memory to produce W. At test time, this second operation does not require gradient updates on the newly introduced categories.

The contextual learner is a bidirectional LSTM. One recurrent direction reads memory keys in slot order, while the other reads them in reverse. The final hidden states from these directions are added to obtain a memory encoding, written h↔. The dimension of this encoding is D_r.

The output projection is:

W = T_p h↔

The matrix T_p maps the recurrent encoding into the parameter vector. It has D_w rows and D_r columns. The resulting W configures the contextual embedding computation for an unlabelled image.

Reading memory in both directions allows the encoding to depend on the surrounding sequence in each direction. It does not, on its own, make the representation invariant to permutations of memory slots. The architecture still processes an ordered sequence, a distinction that matters when interpreting its treatment of a support set.

Make parameter generation manageable

Generating convolutional parameters can require a large output vector. The authors therefore use a factorized convolutional design, drawing on earlier feed-forward one-shot learning work. The purpose is to reduce the parameter burden placed on the contextual learner.

The experimental query branch is similar to the support branch, but its last convolutional layer uses this factorized design and receives predicted parameters. Consequently, the reported implementation should not be understood as generating every parameter in a complete convolutional network for each new task.

This restriction is part of the engineering logic of MM-Net. Much of visual processing remains shared, while a task-dependent component can change with the current support memory. It gives the system a route to adaptation without requiring the contextual learner to synthesize the entire visual pipeline.

The description does not provide a full factorization equation in the method. It is therefore possible to explain why factorization is used and where it is applied without asserting a particular decomposition or parameter count.

Learn through support-and-query episodes

Training uses C-way k-shot tasks. The term C-way means that the episode contains C categories. The term k-shot means that each category contributes k labelled support images.

For each episode, the authors select C training categories uniformly. They draw k support examples from each selected category, then choose additional images from the same categories to form a separate collection, ℬ. These additional images are treated as unlabelled inputs to the recognition procedure, although their labels are available for calculating the training loss.

The support examples are encoded, written into memory, and contextualized. The contextual learner predicts the parameters required by the unlabelled-image branch. Each image in ℬ is then compared with the support embeddings.

The loss is written as:

ℒ(𝒮, ℬ) = −Σₓ̂∈ℬ Σ₍ₓₙ,ᵧₙ₎∈𝒮 𝕀[ŷ = yₙ] log(exp(P(yₙ | x̂, 𝒮)) / Σ₍ₓₜ,ᵧₜ₎∈𝒮 exp(P(yₜ | x̂, 𝒮)))

The symbol ℒ denotes the episode loss. The outer sum covers unlabelled inputs x̂ in ℬ. The inner sum covers labelled support pairs. The indicator 𝕀 selects support examples whose label matches the true label of the current input. In this training equation, ŷ denotes that true label, although the earlier decision equation used the same symbol for a prediction.

The index t ranges over support examples in the denominator. Exponentiating and normalizing the matching scores produces a distribution over support positions. The logarithm penalizes low normalized scores at positions carrying the correct label. The leading negative sign makes minimizing the loss favour correct matches.

This form deserves care in the few-shot case. The normalization runs over support examples, and the indicator can select several positions when a category has several labelled examples. The written objective is therefore more specific than simply taking a softmax over a separately produced vector of category logits.

Training optimizes the complete architecture across episodes. The absence of test-time fine-tuning does not mean that the system avoids back-propagation during its original preparation. It means that, once trained, the architecture handles a new support collection by executing the learned memory and parameter-generation procedure.

Vary the episode rather than fixing its shape

A fixed training regime uses the same C and k throughout. This mirrors a particular test configuration, but it may prepare the system too narrowly if deployment changes the category count or support size.

The mixed strategy varies those quantities between training episodes. The memory serves as a common interface for the changing support collections. Downstream components can therefore apply the same learned procedure even when the raw number of examples differs.

The paper evaluates a mixed k-shot setting that keeps the category count at 5 while varying the examples per category. It also evaluates a broader mixed C-way k-shot setting. In that setting, C is chosen from 2, 3, 4, and 5, while k is chosen from 1, 2, 3, 4, and 5.

At test time, the support collection comes from categories excluded from training. The system constructs a fresh task memory and performs matching through the same sequence of operations. No separate iterative fitting stage is introduced for those new categories.

Experiments and results

What the benchmarks contain

The experiments use evaluation benchmarks with category splits that make the transfer problem explicit. Training images teach the shared recognition procedure. Testing asks whether that procedure can use a small support collection from different categories.

Omniglot contains 32,460 handwritten-character images. Its 1,623 character categories belong to 50 alphabets, and each character has 20 images drawn by different people. The authors use 1,200 character categories for training and 423 for testing.

The preprocessing resizes Omniglot images to 28 × 28 pixels. Rotations by multiples of 90 degrees provide augmentation. These details matter because they define the visual evidence and training variation available to the recognition system.

miniImageNet contains 100 categories selected from ImageNet, with 600 images per category. Images have a resolution of 84 × 84 pixels. The experimental split assigns 64 categories to training, 16 to validation, and 20 to testing.

The datasets consequently test different visual conditions. Omniglot concerns handwritten character categories. miniImageNet concerns categories drawn from a natural-image collection. The paper reports results on both, but their accuracy values should be interpreted within their own task settings rather than treated as a common scale of difficulty.

How an evaluation episode is scored

For a test episode, the authors sample C categories from the test split and provide k labelled support examples per category. They then classify a disjoint collection containing 15 images per category.

The evaluation is repeated 500 times for each setting. The reported metric is mean classification accuracy across these sampled tasks. The paper also specifies 95% confidence intervals as its measure of uncertainty around the estimated means.

This procedure measures more than whether a fixed collection of test images is recognized. Support examples and category combinations are sampled, so the estimate reflects repeated encounters with small recognition tasks. The support collection is part of the experimental condition, rather than a permanently fixed training resource.

The category split is equally important. The final support examples come from categories absent during shared training. Strong performance therefore indicates that the learned procedure transfers to new category identities under the benchmark conditions. It does not imply recognition without support examples or without earlier training on other categories.

Shared architecture and optimization settings

The authors choose a convolutional backbone already used by relevant comparison systems. This helps align the basic feature-extraction setup, although the compared approaches still differ in how they adapt or use context.

The contextual learner has a bidirectional LSTM hidden-layer size of 512. Memory keys also have dimension 512. Training uses Adam with an initial learning rate of 0.001.

The learning rate is reduced to 50% of its current value every 20,000 iterations. The stated batch size is 16 for Omniglot and 4 for miniImageNet.

These are settings for the reported experiments. They should be distinguished from the method’s conceptual claims. The proposal is about how support evidence shapes recognition; its empirical performance also depends on a particular feature extractor, optimizer, training schedule, and data procedure.

What the baselines represent

The comparison includes several different adaptation mechanisms. Siamese Networks learns a pairwise embedding and applies nearest-neighbour classification. Matching Networks learns support-based matching, while its fully contextual variant also incorporates relationships among examples.

Memory-Augmented Neural Networks and Siamese with Memory provide memory-based comparisons. Their presence helps distinguish the general value of storage from MM-Net’s particular use of current-task memory to condition both representations and generated parameters.

The optimization-oriented comparisons include MAML and Meta-Learner LSTM. The former seeks a parameter initialization that can adapt readily; the latter learns an update rule. Meta-Networks provides another parameter-generation comparison, using support-set loss gradients as the information from which classification parameters are produced.

The paper also compares MM-Net with MM-Net⁻. The latter omits mixed training. This is the clearest named internal comparison because it changes a particular training choice while retaining the main architectural proposal.

Omniglot recognition

MM-Net reports 99.28% mean accuracy on the 5-way 1-shot Omniglot task. For the 20-way 1-shot task, the reported mean is 97.16%.

With 5-shot support, the corresponding results are 99.77% for 5-way recognition and 98.93% for 20-way recognition. These are distinct evaluation settings: increasing the number of categories changes the alternatives, while increasing the shots changes the available labelled evidence.

Omniglot 5-way 1-shot mean classification accuracy

MM-Net exceeds the earlier accuracy highlighted in the abstract.

Omniglot 5-way 1-shot mean classification accuracyEarlier result cited in the abstract: 98.95Earlier result cited in the abstract98.95MM-Net (this paper): 99.28MM-Net (this paper)99.28
The numbers
System or settingaccuracy %
Earlier result cited in the abstract98.95
MM-Net (this paper)99.28

The authors identify Meta-Networks as the strongest competitor for the discussed 1-shot Omniglot comparisons. They report absolute improvements of 0.33% in the 5-way setting and 0.16% in the 20-way setting. These are the paper’s stated comparisons, rather than independently calculated differences.

Their broader interpretation is that training procedures aligned with few-shot inference outperform a simpler pairwise-learning approach. Siamese Networks remains effective in the easier category-count setting described by the authors, but its performance deteriorates more sharply in the 20-way 1-shot task.

That comparison is suggestive instead of a fully controlled test of training alignment alone. The systems differ in architecture and adaptation machinery as well as in the organization of training. The results support the complete approaches under their evaluation conditions.

The authors also read the comparison with Siamese with Memory as evidence for the contextual learner. MM-Net’s advantage is consistent with the usefulness of generating query-side parameters from current support context. However, a comparison between complete systems cannot by itself assign the entire advantage to that component.

miniImageNet recognition

On miniImageNet, MM-Net reaches 53.37% mean accuracy in 5-way 1-shot recognition. Its 5-way 5-shot mean is 66.97%.

miniImageNet 5-way 1-shot mean classification accuracy

MM-Net improves on the earlier result emphasized in the abstract.

miniImageNet 5-way 1-shot mean classification accuracyEarlier result cited in the abstract: 49.21Earlier result cited in the abstract49.21MM-Net (this paper): 53.37MM-Net (this paper)53.37
The numbers
System or settingaccuracy %
Earlier result cited in the abstract49.21
MM-Net (this paper)53.37

The abstract’s earlier-result reference is kept separate from the later discussion of individual baselines. The paper’s results discussion compares MM-Net with MAML and states absolute improvements of 4.67% for 1-shot recognition and 3.86% for 5-shot recognition.

The authors report that fully contextual Matching Networks performs better than its non-contextual counterpart. This is relevant because it supports the general motivation for using information across a support collection. MM-Net then adds a different use of context through memory-conditioned parameter generation.

The comparison with Meta-Networks is especially informative conceptually. Both approaches generate parameters, but they use different conditioning signals. Meta-Networks uses loss gradients from the support collection. MM-Net⁻ uses memory to contextualize the support representations and to produce parameters for the unlabelled-image branch.

The reported advantage of MM-Net⁻ over that comparison supports the usefulness of the combined memory-based design. Adding mixed training yields a further improvement in the authors’ account. These observations separate the main architectural proposal from the additional benefit of varying the training tasks, although they do not isolate every internal operation.

The authors describe their miniImageNet results as the strongest reported at the time of the paper. That is a claim about the comparisons available in their study. The enduring empirical statement is narrower and clearer: under the reported benchmark configuration, MM-Net achieves the stated mean accuracies and exceeds the baselines discussed by the authors.

What the ablations show

Mixed training is the clearest internal comparison

The most direct analysis asks how the training-task configuration affects performance across different test conditions. The authors compare fixed-shot training with mixed strategies on miniImageNet.

The fixed strategies each use a particular support size during training. Evaluation then covers 5-way tasks with 1, 2, 3, 4, or 5 labelled examples per category. This tests whether matching a single training configuration is enough to obtain a broadly useful recognition procedure.

The reported result favours variation. The mixed k-shot strategy, which changes the number of examples while retaining 5-way episodes, outperforms the fixed-shot strategies across the tested conditions. The broader mixed C-way k-shot strategy performs best when it also varies the category count.

This supports a specific lesson about distribution design. The recognition procedure benefits from practising changes in the information available to it. The memory interface makes that variation architecturally convenient, but the experiment concerns the combined training strategy instead of proving that memory is the only possible way to accommodate varying support collections.

It also qualifies the paper’s emphasis on matching training and testing. Matching a single configuration is useful, yet deployment may itself contain several configurations. In that case, the appropriate training match is a distribution of tasks. The mixed strategy attempts to reproduce that variation.

The tested category and support ranges remain important. Evidence from these settings supports reuse over the examined tasks. It does not establish that training over modest task sizes guarantees unchanged behaviour when the category inventory or support collection becomes much larger.

Hidden-state size has a modest reported effect

The contextual learner’s recurrent capacity is examined by changing its hidden-state size. The tested sizes are 128, 256, 512, and 1,024, evaluated on miniImageNet in both 1-shot and 5-shot conditions.

The authors state that the performance variation remains within 0.013 for both tasks. That value is reported on the scale used in their analysis; it should not be silently rewritten as a percentage-point difference.

Their interpretation is practical: within the tested range, selecting the hidden-state size is not especially delicate. The recurrent learner does not require a uniquely narrow capacity choice to deliver similar results.

This is a sensitivity analysis, not a removal test. It shows how performance changes when an existing contextual learner is made smaller or larger. It does not show whether a simpler pooling operation, a different sequence encoder, or no parameter-generating learner would achieve the same result.

The distinction matters because robustness to a hyper-parameter is different from evidence for the necessity of a component. The analysis makes the reported implementation easier to assess, while leaving the architectural comparison open.

Embedding plots illustrate the intended separation

The paper compares representations from Matching Networks and MM-Net using t-SNE, which projects high-dimensional vectors into a displayable space. The setting is 5-way 5-shot recognition on miniImageNet.

The authors randomly choose 5 test categories. They visualize representations for 2,975 images after excluding the 25 support examples. In the displayed projection, MM-Net’s category groups appear more distinctly separated.

This observation is consistent with the proposed mechanism. If memory-conditioned representations make the relevant categories easier to distinguish, images from the same category should tend to occupy related regions, while competing categories should be more separable.

The plot does not supply a separate measure of classification performance. A low-dimensional projection is an illustration of representation structure, and the displayed categories are a selected task instance. It should therefore be read alongside the repeated recognition evaluation, rather than as a substitute for it.

Nor does the visualization identify which architectural component caused the separation. Contextual support reading, generated query parameters, and the training strategy all contribute to the representation-producing system that is being visualized.

Similarity matrices inspect the matching behaviour

A second visualization looks more directly at the values used for recognition. The authors construct dot-product similarity matrices between support embeddings and unlabelled-image embeddings.

The example uses 25 support images from 5 categories and 25 corresponding test images. Images are arranged by category so that within-category matches and cross-category matches form visible regions of the matrix.

The authors report that MM-Net generally produces stronger within-category similarities and weaker cross-category similarities than Matching Networks. This is the pattern its matching decision would benefit from: the correct support examples should receive stronger scores than competing examples.

The matrix is more closely connected to the decision rule than the t-SNE projection because it displays the dot products themselves. Still, it is an illustrative task instance instead of an aggregate decomposition of the accuracy results.

It also helps explain the goal of contextual representation learning. The point is not merely to move vectors in an embedding space. It is to change their relative similarities in a way that supports the current category decision.

What is not isolated

The paper offers training-strategy comparisons, a recurrent-capacity analysis, and representation visualizations. It does not present a complete component-by-component removal study in the described analysis.

In particular, the contribution of memory writing is not separated from that of memory reading. The contextual support branch is not independently removed while the parameter-generating branch is held fixed. The shortcut connection and factorized convolution are also not assigned individual accuracy gains.

This limits causal attribution. The experiments can establish that the complete system performs well and that mixed training improves the tested settings. They provide supporting illustrations for more discriminative representations. They leave open how much each memory operation contributes and whether a simpler combination could retain most of the benefit.

That is still useful evidence, provided the claims stay at the right level. MM-Net demonstrates a working integration of mechanisms. The analysis is less conclusive about the minimal architecture required to obtain its gains.

Limitations

The authors’ motivating constraints

The authors explicitly identify scarce labelled data, overfitting during adaptation, and a mismatch between training and testing as problems motivating the work. They also acknowledge that preparing for a fixed C-way k-shot setting can make a recognition procedure less suitable for other task configurations.

Mixed training is their proposed response to that last constraint. The empirical analysis supports it over the tested settings, but the paper’s broad language about handling varied scenarios should be read through those experiments.

The factorized query branch addresses another practical constraint stated in the method: predicting convolutional parameters can create an excessive parameter burden. Reducing the number of generated parameters makes the contextual learner more feasible. This design choice is part of the method’s scope, not evidence that unconstrained network generation would work equally well.

The conclusions do not provide an extended catalogue of failures. Several additional limits follow from the experimental setup and architecture. Those are careful-reader qualifications rather than limitations explicitly established by a dedicated failure study.

New categories come from the benchmark’s world

The test categories are excluded from training, which is an essential condition for the paper’s few-shot claim. However, the new categories still belong to the benchmark used for the corresponding experiment.

The study therefore tests transfer across category identities within Omniglot or within miniImageNet. It does not evaluate a larger shift in which the visual domain, acquisition process, or type of recognition task changes at the same time.

This matters when interpreting the role of earlier knowledge. MM-Net learns its shared feature extraction, memory operations, and contextual learner from training episodes. Its ability to configure a useful query branch depends on what those episodes teach it.

The experiments do not show that support-conditioned parameter generation removes the need for relevant prior training. It is a learned adaptation procedure whose successful range must be established empirically.

The task assumes a known set of alternatives

Every evaluated query belongs to one of the categories represented in its support collection. The decision rule selects among those available labels.

There is no reported test in which an input belongs to an unsupported category and should be rejected. Nor is there an evaluated mechanism for deciding that the current category inventory is incomplete.

This is a closed-set recognition problem. A practical application that receives unrelated inputs would need additional behaviour beyond the paper’s matching decision. High accuracy within the tested category set does not establish reliable novelty detection.

The support labels are also treated as available supervision. The experiments do not investigate incorrect labels, disputed category boundaries, or deliberate contamination of the memory. Since labels determine whether examples are merged or separated, errors in them could affect more than the final label lookup.

Storage capacity and ordering remain open questions

The memory-writing procedure depends on the current contents of memory. An example is compared with previously stored keys, then either merged or placed in a new slot.

This sequential construction creates a potential dependence on support order. The contextual learner introduces a second ordered operation by reading memory slots with a bidirectional LSTM. Processing both directions does not establish that arbitrary permutations yield the same representation.

The paper does not report an order-sensitivity experiment. A reader therefore cannot assume that the architecture treats every ordering of an otherwise identical support set equivalently.

Capacity introduces a related issue. When no slot is available, the stated rule can update a nearby key despite a label mismatch. The experiments do not isolate the effect of this fallback or report a systematic capacity study.

Consequently, the memory should be understood as a particular compression procedure with boundary conditions. Its fixed interface is useful, but compression can discard or combine distinctions. The results do not establish that this cost remains negligible for arbitrary support collections.

Accuracy does not establish computational advantage

Avoiding test-time gradient updates is a clear procedural property. It does not, on its own, prove that the complete recognition pipeline is faster, smaller, or cheaper than every adaptation-based alternative.

MM-Net still extracts support features, constructs memory, runs a recurrent contextual learner, generates parameters, and computes matches. The paper’s reported comparisons focus on classification accuracy.

There is no corresponding numerical study of latency, storage consumption, or energy use in the described experiments. The factorized layer is motivated by feasibility, but an implementation-level efficiency claim would require measurements beyond the accuracy results.

Likewise, generating parameters through forward computation does not make the adaptation transparent in the ordinary explanatory sense. Memory slots have explicit labels, but their keys and the generated weights remain learned numerical representations.

The evidence supports an integrated system

The comparisons with other approaches involve several simultaneous differences. Better performance against a memory-based baseline does not prove that parameter generation alone explains the improvement. Better performance against a parameter-generating baseline does not prove that the chosen conditioning signal is the sole cause.

The mixed-training comparison provides a more direct test of a particular choice. The visualization studies provide examples of the desired representation geometry. Together, these are meaningful but incomplete evidence about mechanism.

The uncertainty estimates also concern sampled evaluation tasks under the chosen procedure. They should not be interpreted as a guarantee about every support collection, every category combination, or every future application.

Finally, the work is about image recognition. Applying its ideas to language, including any use in Mova, remains a proposed transfer. Text representations, labels, and task structures would need their own design and evaluation. The paper supplies an architectural hypothesis for such work, not results for it.

What came after

No later citing work is identified here, so a documented account of follow-up research cannot be attached to MM-Net. The earlier systems discussed in its related work and experiments establish its intellectual setting; they do not establish what subsequently adopted or changed its ideas.

The paper nonetheless leaves a clear set of research questions. Its strongest experimentally supported continuation is task variation: mixed training improves performance across the few-shot configurations the authors examine. A follow-up could investigate how far that benefit extends when the number of categories, the support size, or the underlying data distribution changes more substantially.

The memory design suggests another question. Its label-aware aggregation attempts to preserve shared class information without merging visually similar examples from different categories. The capacity fallback and sequential updates make it useful to examine what information survives compression, how ordering affects the result, and when separate slots are necessary. These are implications of the architecture, not claims about completed later studies.

Parameter generation also remains a distinct hypothesis worth pursuing. MM-Net shows that a support-derived memory can configure part of a query embedding network within a successful recognition system. It does not settle how much generated computation is needed, whether a simpler contextual component would suffice, or which conditioning signals are best.

The contribution to carry forward is therefore a concrete combination: practise recognition under scarce supervision, turn the current examples into an explicit task representation, and let that representation influence both stored-example embeddings and the computation applied to new inputs. The paper’s experiments support that combination on its image benchmarks, while leaving its broader range and minimal requirements open.

Cite

Cite as Qi Cai, Yingwei Pan, Ting Yao, Chenggang Clarence Yan and Tao Mei. 2018. Memory Matching Networks for One-Shot Image Recognition. IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.1109/cvpr.2018.00429 · arXiv 1804.08281

@inproceedings{cai2018memory,
  title = {{Memory Matching Networks for One-Shot Image Recognition}},
  author = {Qi Cai, Yingwei Pan, Ting Yao, Chenggang Clarence Yan and Tao Mei},
  booktitle = {IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings},
  year = {2018},
  doi = {10.1109/cvpr.2018.00429},
  eprint = {1804.08281},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.1109/cvpr.2018.00429}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/cai-2018-memory-matching-networks-one-shot/

References

35 references, from the paper's own bibliography.

  1. D. Bahdanau, K. Cho, and Y. Bengio. Neural machine translation by jointly learning to align and translate. In ICLR, 2015. our card
  2. D. Bahdanau, J. Chorowski, D. Serdyuk, P. Brakel, and Y. Bengio. End-to-end attention-based large vocabulary speech recognition. In ICASSP, 2016. our card
  3. Y. Bengio. Deep learning of representations for unsupervised and transfer learning. In ICML Workshop on Unsupervised and Transfer Learning,, 2012. OpenAlex ↗ · Scholar ↗
  4. L. Bertinetto, J. F. Henriques, J. Valmadre, P. Torr, and A. Vedaldi. Learning feed-forward one-shot learners. In NIPS, 2016. OpenAlex ↗ · Scholar ↗
  5. S. Chandar, S. Ahn, H. Larochelle, P. Vincent, G. Tesauro, and Y. Bengio. Hierarchical memory networks. arXiv preprint arXiv:1605.07427, 2016. OpenAlex ↗ · Scholar ↗
  6. M. Denil, B. Shakibi, L. Dinh, N. de Freitas, et al. Predicting parameters in deep learning. In NIPS, 2013. OpenAlex ↗ · Scholar ↗
  7. A. Dosovitskiy, J. T. Springenberg, M. Riedmiller, and T. Brox. Discriminative unsupervised feature learning with convolutional neural networks. In NIPS, 2014. OpenAlex ↗ · Scholar ↗
  8. L. Fei-Fei, R. Fergus, and P. Perona. A bayesian approach to unsupervised one-shot learning of object categories. In ICCV, 2003. OpenAlex ↗ · Scholar ↗
  9. C. Finn, P. Abbeel, and S. Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In ICML, 2017. our card
  10. A. Graves, N. Jaitly, and A.-r. Mohamed. Hybrid speech recognition with deep bidirectional lstm. In ASRU, 2013. OpenAlex ↗ · Scholar ↗
  11. B. Hariharan and R. Girshick. Low-shot visual object recognition. In ICCV, 2017. OpenAlex ↗ · Scholar ↗
  12. K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In CVPR, 2016. our card
  13. S. Hochreiter and J. Schmidhuber. Long short-term memory. Neural Computation, 1997. OpenAlex ↗ · Scholar ↗
  14. Ł. Kaiser, O. Nachum, A. Roy, and S. Bengio. Learning to remember rare events. ICLR, 2017. OpenAlex ↗ · Scholar ↗
  15. D. Kingma and J. Ba. Adam: A method for stochastic optimization. In ICLR, 2015. our card
  16. G. Koch, R. Zemel, and R. Salakhutdinov. Siamese neural networks for one-shot image recognition. In ICML Workshop on Deep Learning, 2015. OpenAlex ↗ · Scholar ↗
  17. B. M. Lake, R. Salakhutdinov, and J. B. Tenenbaum. Human-level concept learning through probabilistic program induction. Science, 2015. OpenAlex ↗ · Scholar ↗
  18. J. Lei Ba, K. Swersky, S. Fidler, et al. Predicting deep zero-shot convolutional neural networks using textual descriptions. In ICCV, 2015. OpenAlex ↗ · Scholar ↗
  19. L. v. d. Maaten and G. Hinton. Visualizing data using t-SNE. JMLR, 2008. OpenAlex ↗ · Scholar ↗
  20. A. Miller, A. Fisch, J. Dodge, A.-H. Karimi, A. Bordes, and J. Weston. Key-value memory networks for directly reading documents. In EMNLP, 2016. our card
  21. T. Munkhdalai and H. Yu. Meta networks. In ICML, 2017. OpenAlex ↗ · Scholar ↗
  22. H. Noh, P. Hongsuck Seo, and B. Han. Image question answering using convolutional neural network with dynamic parameter prediction. In CVPR, 2016. OpenAlex ↗ · Scholar ↗
  23. Y. Pan, T. Mei, T. Yao, H. Li, and Y. Rui. Jointly modeling embedding and translation to bridge video and language. In CVPR, 2016. OpenAlex ↗ · Scholar ↗
  24. Y. Pan, Z. Qiu, T. Yao, H. Li, and T. Mei. To create what you tell: Generating videos from captions. In MM, 2017. OpenAlex ↗ · Scholar ↗
  25. S. Ravi and H. Larochelle. Optimization as a model for few-shot learning. In ICLR, 2017. OpenAlex ↗ · Scholar ↗
  26. O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, et al. Imagenet large scale visual recognition challenge. IJCV, 2015. our card
  27. A. Santoro, S. Bartunov, M. Botvinick, D. Wierstra, and T. Lillicrap. Meta-learning with memory-augmented neural networks. In ICML, 2016. OpenAlex ↗ · Scholar ↗
  28. J. Schmidhuber. Learning to control fast-weight memories: An alternative to dynamic recurrent networks. Neural Computation, 1992. OpenAlex ↗ · Scholar ↗
  29. M. Schuster and K. K. Paliwal. Bidirectional recurrent neural networks. IEEE Transactions on Signal Processing, 1997. OpenAlex ↗ · Scholar ↗
  30. S. Sukhbaatar, J. Weston, R. Fergus, et al. End-to-end memory networks. In NIPS, 2015. OpenAlex ↗ · Scholar ↗
  31. O. Vinyals, C. Blundell, T. Lillicrap, D. Wierstra, et al. Matching networks for one shot learning. In NIPS, 2016. our card
  32. Y.-X. Wang and M. Hebert. Learning to learn: Model regression networks for easy small sample learning. In ECCV, 2016. OpenAlex ↗ · Scholar ↗
  33. J. Weston, S. Chopra, and A. Bordes. Memory networks. In ICLR, 2014. OpenAlex ↗ · Scholar ↗
  34. T. Yao, Y. Pan, Y. Li, Z. Qiu, and T. Mei. Boosting image captioning with attributes. In ICCV, 2017. OpenAlex ↗ · Scholar ↗
  35. J. Yosinski, J. Clune, Y. Bengio, and H. Lipson. How transferable are features in deep neural networks? In NIPS, 2014. our card