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.
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 .
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:
- Restrict node embeddings:
- Fix Adjacency matrix:
- Reduce the convolution block:
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.
Restrict the node embeddings to
Fix the Adjacency Metric:
q is the number of examples in each class.
- Replace the convolution block by:
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.
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.
- How to decide ? Link to Answer
I believe, the label were randomly sampled from the dataset for each task.
- Explain how are parameters trained? Link to Answer
- 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 .
- How to generate one hot encoding in Figure 1. Link to Answer
- What is ? How to generate ? Link to Answer
- What is the meaning of ? Link to Answer
- Explain how prototypers are generated in prototypical networks? Explain how they are equivalent?
- How to calculate probability ? Link to Answer
- How is attention vector generated?
Attention vector is also trained.
- What is ? Link to Answer
- Tutorial on Meta-Learning by Dr. Lilian Weng
- Koch, Gregory, Richard Zemel, and Ruslan Salakhutdinov. Siamese neural networks for one-shot image recognition. ICML deep learning workshop. 2015.
- Vinyals, Oriol, et al. Matching networks for one shot learning. NeurIPS. 2016.
- Snell, Jake, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. NeurIPS. 2017.