F EW -S HOT L EARNING WITH G RAPH N EURAL N ETWORKS
Anonymous authors
Paper under double-blind review
A BSTRACT
We propose to study the problem of few-shot learning with the prism of inference on a partially observed graphical model, constructed from a collection of input images whose label can be either observed or not.
By assimilating generic message-passing inference algorithms with their neural-network counterparts, we deﬁne a graph neural network architecture that generalizes several of the recently proposed few-shot learning models.
Besides providing improved numerical performance, our framework is easily extended to variants of few-shot learning, such as semi-supervised or active learning, demonstrating the ability of graph-based models to operate well on ‘relational’ tasks.
I NTRODUCTION
Supervised end-to-end learning has been extremely successful in computer vision, speech, or machine translation tasks, thanks to improvements in optimization technology, larger datasets and streamlined designs of deep convolutional or recurrent architectures.
Despite these successes, this learning setup does not cover many aspects where learning is nonetheless possible and desirable.
One such instance is the ability to learn from few examples, in the so-called few-shot learning tasks.
Rather than relying on regularization to compensate for the lack of data, researchers have explored ways to leverage a distribution of similar tasks, inspired by human learning Lake et al.
This deﬁnes a new supervised learning setup (also called ‘meta-learning’) in which the input-output pairs are no longer given by iid samples of images and their associated labels, but by iid samples of collections of images and their associated label similarity.
A recent and highly-successful research program has exploited this meta-learning paradigm on the few-shot image classiﬁcation task Lake et al.
; Koch et al.
; Vinyals et al.
; Mishra et al.
; Snell et al.
In essence, these works learn a contextual, task-speciﬁc similarity measure, that ﬁrst embeds input images using a CNN, and then learns how to combine the embedded images in the collection to propagate the label information towards the target image.
In particular, Vinyals et al.
(2016) cast the few-shot learning problem as a supervised classiﬁcation task mapping a support set of images into the desired label, and developed an end-to-end architecture accepting those support sets as input via attention mechanisms.
In this work, we build upon this line of work, and argue that this task is naturally expressed as a supervised interpolation problem on a graph, where nodes are associated with the images in the collection, and edges are given by a trainable similarity kernels.
Leveraging recent progress on representation learning for graphstructured data Bronstein et al.
(2016b)
; Gilmer et al.
(2017), we thus propose a simple graph-based few-shot learning model that implements a task-driven message passing algorithm.
The resulting architecture is trained end-to-end, captures the invariances of the task, such as permutations within the input collections, and offers a good tradeoff between simplicity, generality, performance and sample complexity.
Besides few-shot learning, a related task is the ability to learn from a mixture of labeled and unlabeled examples — semi-supervised learning, as well as active learning , in which the learner has the option to request those missing labels that will be most helpful for the prediction task.
Our graphbased architecture is naturally extended to these setups with minimal changes in the training design.
We validate experimentally the model on few-shot image classiﬁcation, matching state-of-the-art performance with considerably fewer parameters, and demonstrate applications to semi-supervised and active learning setups.
Our contributions are summarized as follows:
• We cast few-shot learning as a supervised message passing task which is trained end-to-end using graph neural networks.
• We match state-of-the-art performance on Omniglot and Mini-Imagenet tasks with fewer parameters.
• We extend the model in the semi-supervised and active learning regimes.
The rest of the paper is structured as follows.
Section 2 describes related work, Sections 3, 4 andpresent the problem setup, our graph neural network model and the training, and Section 6 reports numerical experiments.
R ELATED W ORK
One-shot learning was ﬁrst introduced by Fei-Fei et al.
, they assumed that currently learned classes can help to make predictions on new ones when just one or few labels are available.
More recently, Lake et al.
(2015) presented a Hierarchical Bayesian model that reached human level error on few-shot learning alphabet recongition tasks.
Since then, great progress has been done in one-shot learning.
Koch et al.
(2015) presented a deeplearning model based on computing the pair-wise distance between samples using Siamese Networks, then, this learned distance can be used to solve one-shot problems by k-nearest neighbors classiﬁcation.
Vinyals et al.
(2016) Presented an end-to-end trainable k-nearest neighbors using the cosine distance, they also introduced a contextual mechanism using an attention LSTM model that takes into account all the samples of the subset T when computing the pair-wise distance between samples.
Snell et al.
(2017) extended the work from Vinyals et al.
(2016), by using euclidean distance instead of cosine which provided signiﬁcant improvements, they also build a prototype representation of each class for the few-shot learning scenario.
Mehrotra & Dukkipati (2017) trained a deep residual network together with a generative model to approximate the pair-wise distance between samples.
A new line of meta-learners for one-shot learning is rising lately: Ravi & Larochelle (2016) introduced a Meta-Learning method where an LSTM updates the weights of a classiﬁer for a given episode.
Munkhdalai & Yu (2017) also presented a Meta-Learning architecture that learns metalevel knowledge across tasks, and it changes its inductive bias via fast parametrization.
Finn et al.
(2017) are using a model agnostic meta learner based on gradient descent, the goal is to train a classiﬁcation model such that given a new task, a small amount of gradient steps with few data will be enough to generalize.
Lately, Mishra et al.
(2017) used Temporal Convolutions which are deep recurrent networks based on dilated convolutions, this method also exploits contextual information from the subset T providing very good results.
Another related area of research concerns deep learning architectures on graph-structured data.
The
GNN was ﬁrst proposed in Gori et al.
; Scarselli et al.
(2009), as a trainable recurrent messagepassing whose ﬁxed points could be adjusted discriminatively.
Subsequent works Li et al.
(2015b);
Sukhbaatar et al.
(2016b) have relaxed the model by untying the recurrent layer weights and proposed several nonlinear updates through gating mechanisms.
Graph neural networks are in fact natural generalizations of convolutional networks to non-Euclidean graphs.
Bruna et al.
; Henaff et al.
(2015) proposed to learn smooth spectral multipliers of the graph Laplacian, albeit with high computational cost, and Defferrard et al.
; Kipf & Welling (2016) resolved the computational bottleneck by learning polynomials of the graph Laplacian, thus avoiding the computation of eigenvectors and completing the connection with GNNs.
In particular, Kipf & Welling (2016) was the ﬁrst to propose the use of GNNs on semi-supervised classiﬁcation problems.
We refer the reader to
Bronstein et al.
(2016b) for an exhaustive literature review on the topic.
GNNs and the analogous
Neural Message Passing Models are ﬁnding application in many different domains.
Battaglia et al.
; Chang et al.
(2016) develop graph interaction networks that learn pairwise particle interactions and apply them to discrete particle physical dynamics.
Duvenaud et al.
; Kearnes et al.
(2016) study molecular ﬁngerprints using variants of the GNN architecture, and Gilmer et al.
(2017) further develop the model by combining it with set representations Vinyals et al.
(2015), showing state-of-the-art results on molecular prediction.
P ROBLEM S ET - UP
We describe ﬁrst the general setup and notations, and then particularize it to the case of few-shot learning, semi-supervised learning and active learning.
We consider input-output pairs ( T i , Y i )
i drawn iid from a distribution P of partially-labeled image collections
[Equation]
and Y
[Equation] [Equation]
for arbitrary values of s, r, t and K .
Where s is the number of labeled samples, r is the number of unlabeled samples ( r > 0 for the semi-supervised and active learning scenarios) and t is the number of samples to classify.
K is the number of classes.
We will focus in the case t = 1 where we just classify one sample per task T .
P l ( R N ) denotes a class-speciﬁc image distribution over R N .
In our context, the targets Y i are associated with image categories of designated images ¯ x 1 , . . .
, ¯ x t ∈ T i with no observed label.
Given a training set { ( T i , Y i ) i } i ≤ L , we consider the standard supervised learning objective
[Equation]
using the model Φ( T ; Θ)
= p ( Y | T ) speciﬁed in Section 4 and R is a standard regularization objective.
Few-Shot Learning When r = 0 , t = 1 and s = qK , there is a single image in the collection with unknown label.
If moreover each label appears exactly q times, this setting is referred as the q -shot, K -way learning.
Semi-Supervised Learning When r > 0 and t = 1 , the input collection contains auxiliary images ˜ x 1 , . .
˜ x r that the model can use to improve the prediction accuracy, by leveraging the fact that these samples are drawn from common distributions as those determining the output.
Active Learning In the active learning setting, the learner has the ability to request labels from the sub-collection { ˜ x 1 , . . .
, ˜ x r } .
We are interested in studying to what extent this active learning can improve the performance with respect to the previous semi-supervised setup, and match the performance of the one-shot learning setting with s 0 known labels when s + r = s 0 , s (cid:28) s 0 .
M ODEL
This section presents our approach, based on a simple end-to-end graph neural network architecture.
We ﬁrst explain how the input context is mapped into a graphical representation, then detail the architecture, and next show how this model generalizes a number of previously published few-shot learning architectures.
4. S ET AND G RAPH I NPUT R EPRESENTATIONS
The input T contains a collection of images, both labeled and unlabeled.
The goal of few-shot learning is to propagate label information from labeled samples towards the unlabeled query image.
This propagation of information can be formalized as a posterior inference over a graphical model determined by the input images and labels.
Following several recent works that cast posterior inference using message passing with neural networks deﬁned over graphs Scarselli et al.
; Duvenaud et al.
; Gilmer et al.
, we associate T with a fully-connected graph G T =
( V, E ) where nodes v a ∈ V correspond to the images present in T (both labeled and unlabeled).
In this context, the setup does not specify a ﬁxed similarity e a,a (cid:48) between images x a and x a (cid:48) , suggesting an approach where this similarity measure is learnt in a discriminative fashion with a parametric model similarly as in Gilmer et al.
(2017), such as a siamese neural architecture.
This framework is closely related to the set representation from Vinyals et al.
but extends the inference mechanism using the graph neural network formalism that we detail next.
4. G RAPH N EURAL N ETWORKS
Graph Neural Networks, introduced in Gori et al. (2005); Scarselli et al.
(2009) and further simpliﬁed in Li et al.
(2015a)
; Duvenaud et al.
; Sukhbaatar et al.
(2016a) are neural networks based on local operators of a graph G =
( V, E )
, offering a powerful balance between expressivity and sample complexity; see Bronstein et al.
(2016a)
for a recent survey on models and applications of deep learning on graphs.
In its simplest incarnation, given an input signal F ∈ R V × d on the vertices of a weighted graph G , we consider a family A of graph intrinsic linear operators that act locally on this signal.
The simplest is the adjacency operator A : F (cid:55)→ A ( F ) where ( AF ) i :=
(cid:80) j ∼ i w i,j F j , with i ∼ j iff ( i, j
) ∈ E and w i,j its associated weight.
A GNN layer Gc ( · ) receives as input
a signal x ( k ) ∈
R V ×
d k and produces x (
k +1) ∈ R V ×
d k +1 as
[Equation]
where Θ = { θ ( k ) 1 , . .
, θ ( k ) |A| } k , θ ( k ) B ∈ R d k × d k +1 , are trainable parameters and ρ ( · ) is a point-wise non-linearity, chosen in this work to be a ‘leaky’ ReLU
Xu et al.
Authors have explored several modeling variants from this basic formulation, by replacing the pointwise nonlinearity with gating operations Duvenaud et al.
(2015), or by generalizing the generator family to Laplacian polynomials Defferrard et al.
; Kipf & Welling (2016); Bruna et al. (2013), or including 2 J -th powers of A to A , A J = min(1 , A 2 J ) to encode 2 J -hop neighborhoods of each node Bruna & Li (2017).
Cascaded operations in the form (2) are able to approximate a wide range of graph inference tasks.
In particular, inspired by message-passing algorithms, Kearnes et al.
(2016); Gilmer et al.
(2017) generalized the GNN to also learn edge features ˜
A ( k ) from the current
[Table]
[Equation]
where ϕ is a symmetric function parametrized with e.g. a neural network.
In this work, we consider a Multilayer Perceptron stacked after the absolute difference between two vector nodes.
See eq. 3:
[Equation]
Then ϕ is a metric, which is learned by doing a non-linear combination of the absolute difference between the individual features of two nodes.
Using this architecture the distance property Symmetry ϕ ˜ θ ( a, b ) =
ϕ
˜ θ ( b, a ) is fulﬁlled by construction and the distance property Identity ϕ ˜ θ ( a, a ) = 0 is easily learned.
The trainable adjacency is then normalized to a stochastic kernel by using a softmax along each row.
The resulting update rules for node features are obtained by adding the edge feature kernel ˜
A ( k ) into the generator family A =
{ ˜ A ( k ) , 1 } and applying (2).
Adjacency learning is particularly important in applications where the input set is believed to have some geometric structure, but the metric is not known a priori, such as is our case.
In general graphs, the network depth is chosen to be of the order of the graph diameter, so that all nodes obtain information from the entire graph.
In our context, however, since the graph is densely connected, the depth is interpreted simply as giving the model more expressive power.
Construction of Initial Node Features The input collection T is mapped into node features as follows.
For images x i ∈ T with known label l i , the one-hot encoding of the label is concatenated with the embedding features of the image at the input of the GNN.
[Equation]
where φ is a Convolutional neural network and h ( l ) ∈ R K + is a one-hot encoding of the label.
Architectural details for φ are detailed in Section 6.1.1 and 6.1.2.
For images ˜ x j , ¯ x j (cid:48) with unknown label l i , we modify the previous construction to account for full uncertainty about the label variable by replacing h ( l ) with the uniform distribution over the K -simplex: V j = ( φ (˜ x j ) , K − 1 1 K ) , and analogously for ¯ x .
4. R ELATIONSHIP WITH E XISTING M ODELS
The graph neural network formulation of few-shot learning generalizes a number of recent models proposed in the literature.
Siamese Networks Siamese Networks Koch et al.
(2015) can be interpreted as a single layer message-passing iteration of our model, and using the same initial node embedding (4) x (0) i
= ( φ ( x i ) , h i ) , using a non-trainable edge feature
[Equation]
and resulting label estimation
[Equation]
with u selecting the label ﬁeld from x .
In this model, the learning is reduced to learning image embeddings φ ( x i ) whose euclidean metric is consistent with the label similarities.
Prototypical Networks Prototypical networks Snell et al.
(2017) evolve Siamese networks by aggregating information within each cluster determined by nodes with the same label.
This operation can also be accomplished with a gnn as follows.
we consider
[Equation]
where q is the number of examples per class, and
[Equation]
where x (0) is deﬁned as in the Siamese Networks.
We ﬁnally apply the previous kernel ˜
A (1) =
softmax ( ϕ ) applied to x (1) to yield class prototypes:
[Equation]
Matching Networks Matching networks Vinyals et al.
(2016) use a set representation for the ensemble of images in T , similarly as our proposed graph neural network model, but with two important differences.
First, the attention mechanism considered in this set representation is akin to the edge feature learning, with the difference that the mechanism attends always to the same node embeddings, as opposed to our stacked adjacency learning, which is closer to Vaswani et al.
Second, the label and image ﬁelds are treated separately throughout the model, with a ﬁnal step that aggregates linearly the labels using a trained kernel.
This may prevent the model to leverage complex dependencies between labels and images at intermediate stages.
T RAINING
We describe next how to train the parameters of the GNN in the different setups we consider: fewshot learning, semi-supervised learning and active learning.
5. F EW -S HOT AND S EMI -S UPERVISED L EARNING
In this setup, the model is asked only to predict the label Y corresponding to the image to classify ¯ x ∈ T , associated with node ∗ in the graph.
The ﬁnal layer of the GNN is thus a softmax mapping the node features to the K -simplex.
We then consider the Cross-entropy loss evaluated at node ∗ :
[Equation]
The semi-supervised setting is trained identically — the only difference is that the initial label ﬁelds of the node will be ﬁlled with the uniform distribution on nodes corresponding to ˜ x j .
5. A CTIVE L EARNING
In the Active Learning setup, the model has the intrinsic ability to query for one of the labels from { ˜ x 1 , . . . ,
˜ x r } .
The network will learn to ask for the most informative label in order to classify the sample ¯ x j .
The querying is done after the ﬁrst layer of the GNN by using a Softmax attention over the unlabeled nodes of the graph.
For this we apply a function g ( x (1) i )
∈ R 1 that maps from each unlabeled vector node to a scalar value.
Function g is parametrized by a two layers neural network.
A Softmax is applied over the { 1 , . . .
, r } scalar values obtained after applying g :
Attention = Softmax ( g ( x (1) { 1 ,...,r } ))
In order to query only one sample, we set all elements from the Attention ∈ R r vector to 0 except for one.
At test time we keep the maximum value, at train time we randomly sample one value based on its multinomial probability.
Then we multiply this sampled attention by the label vectors:
[Equation]
The label of the queried vector h ( l i ∗ ) is obtained, scaled by the weight w ∈ (0 , 1) .
This value is then summed to the current representation x
(1) i ∗ , since we are using dense connections in our GNN model we can sum this w · h ( l i ∗ ) value directly to where the uniform label distribution was concatenated
[Equation]
After the label has been summed to the current node, the information is forward propagated.
This attention part is trained end-to-end with the rest of the network by backpropagating the loss from the output of the GNN.
E XPERIMENTS
For the few-shot, semi-supervised and active learning experiments we used the Omniglot dataset presented by Lake et al.
and Mini-Imagenet dataset introduced by Vinyals et al.
(2016) which is a small version of ILSVRC-12 Krizhevsky et al.
All experiments are based on the q -shot,
K -way setting.
For all experiments we used the same values q -shot and K -way for both training and testing.
[Table]
6. D ATASETS AND I MPLEMENTATION 6.1. O MNIGLOT
Dataset: Omniglot is a dataset of 1623 characters from 50 different alphabets, each character/class has been drawn by 20 different people.
Following Vinyals et al.
(2016) implementation we split the dataset into 1200 classes for training and the remaining 423 for testing.
We augmented the dataset by multiples of 90 degrees as proposed by Santoro et al.
Architectures: Inspired by the embedding architecture from Vinyals et al.
(2016), following
Mishra et al.
(2017), a CNN was used as an embedding φ function consisting of four stacked blocks of { 3 × 3-convolutional layer with 64 ﬁlters, batch-normalization, 2 × 2 max-pooling, leaky-relu } the output is passed through a fully connected layer resulting in a 64-dimensional embedding.
For the
GNN we used 3 blocks each of them composed by 1) a module that computes the adjacency matrix and 2) a graph convolutional layer.
A more detailed description of each block can be found at Figure 8.
6.1. M INI -I MAGENET
Dataset: Mini-imagenet is a more challenging dataset for one-shot learning proposed by Vinyals et al.
(2016) derived from the original ILSVRC-12 dataset Krizhevsky et al.
It consists of 84 × 84 RGB images from 100 different classes with 600 samples per class.
It was created with the purpose of increasing the complexity for one-shot tasks while keeping the simplicity of a light size dataset, that makes it suitable for fast prototyping.
We used the splits proposed by Ravi & Larochelle (2016) of 64 classes for training, 16 for validation and 20 for testing. Using 64 classes for training, and the 16 validation classes only for early stopping and parameter tuning.
Architecture: The embedding architecture used for Mini-Imagenet is formed by 4 convolutional layers followed by a fully-connected layer resulting in a 128 dimensional embedding. This light architecture is useful for fast prototyping:
1 ×{ 3 × 3-conv. layer (64 ﬁlters), batch normalization, max pool (2 , 2) , leaky relu } , 1 ×{ 3 × 3-conv.
layer (96 ﬁlters), batch normalization, max pool (2 , 2) , leaky relu } , 1 ×{
[Figure]
[Figure]
[Figure]
× fc-layer The two dropout layers are useful to avoid overﬁtting the GNN in Mini-Imagenet dataset.
The GNN architecture is similar than for Omniglot, it is formed by 3 blocks, each block is described at Figure 8.
6. F EW -S HOT
Few-shot learning experiments for Omniglot and Mini-Imagenet are presented at Table 3 and Table 4 respectively.
We evaluate our model by performing different q-shot, K-way experiments on both datasets.
For every few-shot task T , we sample K random classes from the dataset, and from each class we sample q random samples.
An extra sample to classify is chosen from one of that K classes.
Omniglot : The GNN method is providing competitive results while still remaining simpler than other methods.
State of the art results are reached in the 5-Way and 20-way 1-shot experiments.
In the 20-Way 1-shot setting the GNN is providing slightly better results than Munkhdalai & Yu (2017) while still being a more simple approach.
The TCML approach from Mishra et al.
(2017) is in the same conﬁdence interval for 3 out of 4 experiments, but it is slightly better for the 20-Way 5-shot, although the number of parameters is reduced from ∼ 5M (TCML) to ∼ 400K (3 layers GNN).
At Mini-Imagenet table we are also presenting a baseline ” Our metric learning + KNN ” where no information has been aggregated among nodes, it is a K-Nearest Neighbors applied on top of the pair-wise learnable metric ϕ θ ( x (0) i , x (0) j ) and trained end-to-end, this learnable metric is competitive by itself compared to other state of the art methods.
Even so, a signiﬁcant improvement (from 64.02% to 66.41%) can be seen for the 5-shot 5-Way Mini-Imagenet setting when aggregating information among nodes by using the GNN architecture.
A variety of embedding functions φ are used among the different papers for Mini-Imagenet experiments, in our case we are using a simple network of 4 conv. layers followed by a fully connected layer (Section 6.1.2) which served us to compare between Our GNN and Our metric learning + KNN and it is useful for fast prototyping.
More complex embeddings have proven to produce better results, at Mishra et al.
(2017) a deep residual network is used as embedding network φ increasing the accuracy considerably.
Regarding the TCML architecture for Mini-Imagenet, the number of parameters is reduced from ∼ 11M (TCML) to ∼ 400K (3 layers GNN).
6. S EMI -S UPERVISED
Semi-supervised experiments are performed on the 5-way 5-shot setting.
Different results are presented when 20% and 40% of the samples are labeled.
The labeled samples are balanced among classes in all experiments, in other words, all the classes have the same amount of labeled and unlabeled samples.
[Table]
Our metric learning + KNN
[Table]
Our GNN [Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table]
[Figure] [Table] Two strategies can be seen at Tables 5 and 6. ” GNN - Trained only with labeled” is equivalent to the supervised few-shot setting, for example, in the 5-Way 5-shot 20%-labeled setting, this method is equivalent to the 5-way 1-shot learning setting since it is ignoring the unlabeled samples. ”
GNN - Semi supervised” is the actual semi-supervised method, for example, in the 5-Way 5-shot 20%- labeled setting, the GNN receives as input 1 labeled sample per class and 4 unlabeled samples per class.
Omniglot results are presented at table 5, for this scenario we observe that the accuracy improvement is similar when adding images than when adding labels.
The GNN is able to extract information from the input distribution of unlabeled samples such that only using 20% of the labels in a 5-shot semi-supervised environment we get same results as in the 40% supervised setting.
In Mini-Imagenet experiments, Table 6, we also notice an improvement when using semi-supervised data although it is not as signiﬁcant as with Omniglot.
The distribution of Mini-Imagenet images is more complex than for Omniglot.
In spite of it, the GNN manages to improve by ∼ 2% in the 20% and 40% settings.
6. A CTIVE L EARNING
We performed Active Learning experiments on the 5-Way 5-shot set-up when 20% of the samples are labeled.
In this scenario our network will query for the label of one sample from the unlabeled ones.
The results are compared with the Random baseline where the network chooses a random sample to be labeled instead of one that maximally reduces the loss of the classiﬁcation task T .
Results are shown at Table 7.
The results of the GNN-Random criterion are close to the Semisupervised results for 20%-labeled samples from tables 5 and 6.
It means that selecting one random label practically does not improve the accuracy at all.
When using the GNN-AL learned criterion, we notice an improvement of ∼ 3.4% for Mini-Imagenet, it means that the GNN manages to correctly choose a more informative sample than a random one.
In Omniglot the improvement is smaller since the accuracy is almost saturated and the improving margin is less.
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
C ONCLUSIONS
This paper explored graph neural representations for few-shot, semi-supervised and active learning.
From the meta-learning perspective, these tasks become supervised learning problems where the input is given by a collection or set of elements, whose relational structure can be leveraged with neural message passing algorithms, where cascaded node and edge features generalize the contextual similarity learning underpinning previous few-shot learning models.
The graph formulation is helpful to unify several training setups (few-shot, active, semi-supervised) under the same framework, a necessary step towards the goal of having a single learner which is able to operate simultaneously in different regimes (stream of labels with few examples per class, or stream of examples with few labels).
This general goal requires scaling up graph models to millions of nodes, motivating graph hierarchical and coarsening approaches Defferrard et al.
Another future direction is to generalize the scope of the active learning, to include e.g. the ability to ask questions Rothe et al.
(2017), or in reinforcement learning setups, where few-shot learning is critical to adapt to non-stationary environments.