Few-Shot Learning with Graph Neural Networks

Victor Garcia, Joan Bruna ICLR 2018

This paper focuses on -shot -way classification problem – where we have class labels and for each class label we have example images, so totally we have training images. Authors propose to leverage the progress in Graph Convolutional Networks by formulating this problem as a node classification problem in graph , where nodes are images and an edge between two nodes indicate those two images are similar and may have same labels.

Given dataset containing Task and true label for a single test image .

Embeddings – are obtained from a convolutional neural network (CNN) for all the images (), as highlighted in the image below.

These embeddings are then concatenated with one-hot encoding of the labels . Together they form nodes of the graph.

For labels, is a binary vector of size k. One-hot encoding is obtained for training image with the label , by setting all the values in to except for element which is i.e. . For test image, since the label is not known in , uniform distribution is used instead of one hot encoding i.e. , for .

superscript indicate the layer input. So, indicates the node embeddings for first layer in GNN.

Edges of the graph are learnt as adjacency matrix using a MLP.

Then Graph Convolution () is performed on the nodes and adjacency matrix . .

Proposed block of GNN containing the Adjacency matrix and Graph Convolution.

The block containing learning of adjacency matrix and graph convolution is repeated multiple times in the experiments and output of the last layer is passed through a sigmoid activation function to obtain class probabilities .

The complete network, including the adjacency matrix is trained end-to-end with following objective .

Note that the labels/predictions of the training data are not used to compute the loss. Hence the GNN will not overfit to the part of the embedding.

The over all idea of finding image embeddings and then using distance between the image embeddings to find the class label is explored in various other papers. Authors show equivalence of their approach to three other papers.

1. Convolutional Siamese Neural Network

Koch et al. 2015 proposed to use Convolutional Siamese Neural Network (CSNN) to learn similarity between two images, i.e probability that both images were drawn from same label set.

They used two parallel twin CNN to obtain embeddings to two input images , computed absolute distance between these embeddings (d), and then computed probability by passing the distance from linear feedforward layer and sigmoid function.

CSNN are trained to reduce the following loss function for all pairs of images.

While testing, the test image () is compared with all the training images () and 1 Nearest-Neighbour approach is used to assign the class label.

Equivalence to GNN

GNN approach is similar to CSNN if we make following changes:

  1. Restrict node embeddings:
  1. Fix Adjacency matrix:
  1. Reduce the convolution block:

where, indicates elementwise multiplication and is a binary vector for selection of labels. So, it is 1 only for elements which correspond to labels in and 0 otherwise. indicates the test example. .

2. Matching Network

Vinyals et al., 2016 extended the SCNN approach of -way comparison to -way comparison by using an attention function to compute cosine similarity of test image embedding with input image embeddings and use it as a weighted sum to compute the class probability of the test image.

Note here is the number of examples not the number of class labels.

Parameters are trained to maximize the loglikelihood of the test images.

Equivalence to GNN

GNN approach can be considered equivalent to Matching Network if and and .

2. Prototypical Network

Snell et al. 2017 reduced the number of comparisons in Matching Network by computing a class representative for each class and instead of comparing with all available images, the test image is only compared with the class representatives.

This paper first computes embeddings of all images and then computes a class representative/prototype for each class as mean of those embeddings.

The class probability distribution of test example is then computed by taking softmax of the distance between the embedding of test image and the class prototype. The distance measure used here is squared euclidean distance.

The network is trained to reduce the negative loglikelihood.

Equivalence to GNN

GNN approach can be reduced to Prototypical Network if we make following changes.

  1. Restrict the node embeddings to

  2. Fix the Adjacency Metric:

q is the number of examples in each class.

  1. Replace the convolution block by:

Extentions

Paper also proposed a way to extend the few-shot learning setting to semi-supervised learning and active learning setting. Although straight forward I do not see the intuition clear enough or experiments strong enough to suggest that those setting have any added benefit on reducing uncertainty of the model.

Critique

Although the paper is a fascinating read since it connect various approaches of few-shot / one-shot learning with graph-convolutional network. I find the experiments very weak. Especially since authors only use 1 test example per task. Lack of intuition for the attention mechanism for active learning setting is also discouraging.

Questions

  1. How to decide ? Link to Answer

I believe, the label were randomly sampled from the dataset for each task.

  1. Explain how are parameters trained? Link to Answer
  2. How to compute the adjacency matrix for each layer of GNN? Link to Answer

Question 2 and 3 are equivalent, since is a function of .

  1. How to generate one hot encoding in Figure 1. Link to Answer
  2. What is ? How to generate ? Link to Answer
  3. What is the meaning of ? Link to Answer
  4. Explain how prototypers are generated in prototypical networks? Explain how they are equivalent?
  5. How to calculate probability ? Link to Answer
  6. How is attention vector generated?

Attention vector is also trained.

  1. What is ? Link to Answer

References

  1. Tutorial on Meta-Learning by Dr. Lilian Weng
  2. Koch, Gregory, Richard Zemel, and Ruslan Salakhutdinov. Siamese neural networks for one-shot image recognition. ICML deep learning workshop. 2015.
  3. Vinyals, Oriol, et al. Matching networks for one shot learning. NeurIPS. 2016.
  4. Snell, Jake, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. NeurIPS. 2017.