Matching networks
Matching networks are yet another simple and efficient one-shot learning algorithm published by Google's DeepMind team. It can even produce labels for the unobserved class in the dataset.
Let's say we have a support set, S, containing K examples as
![](https://static.packt-cdn.com/products/9781789534207/graphics/aa9e7062-1d70-42a2-918b-9ec50989fea2.png)
. When given a query point (a new unseen example),
![](https://static.packt-cdn.com/products/9781789534207/graphics/0b351588-5946-4892-9191-59cd33111fee.png)
, the matching network predicts the class of
![](https://static.packt-cdn.com/products/9781789534207/graphics/21408c6c-982b-4146-85f0-f5b48eff634a.png)
by comparing it with the support set.
We can define this as
![](https://static.packt-cdn.com/products/9781789534207/graphics/c7636bc6-eeab-4078-a600-fbfbd87db2a7.png)
, where
![](https://static.packt-cdn.com/products/9781789534207/graphics/7094b845-d13c-4c87-b4a2-a9087513c746.png)
is the parameterized neural network,
![](https://static.packt-cdn.com/products/9781789534207/graphics/562f1611-d709-48cc-9b27-751432857398.png)
is the predicted class for the query point,
![](https://static.packt-cdn.com/products/9781789534207/graphics/b9ac0f49-1381-41bc-a213-2ffa1f874fca.png)
, and
![](https://static.packt-cdn.com/products/9781789534207/graphics/01c23682-1ca6-4d39-9bcd-4427247ab3ed.png)
is the support set.
![](https://static.packt-cdn.com/products/9781789534207/graphics/c7636bc6-eeab-4078-a600-fbfbd87db2a7.png)
will return the probability of
![](https://static.packt-cdn.com/products/9781789534207/graphics/b0553169-166d-4ff8-968f-3c2007c2e9e1.png)
belonging to each of the classes in the dataset. Then, we select the class of
![](https://static.packt-cdn.com/products/9781789534207/graphics/16731e36-2a76-4ecd-aac8-3b5c2351258c.png)
as the one that has the highest probability. But how does this work exactly? How is this probability computed? Let's us see that now.
The output,
![](https://static.packt-cdn.com/products/9781789534207/graphics/29a3f9a0-e1a7-4cb3-93dd-6be092211b92.png)
, for the query point,
![](https://static.packt-cdn.com/products/9781789534207/graphics/76646a2a-ec6c-42fc-88f6-4b0373fa7574.png)
, can be predicted as follows:
![](https://static.packt-cdn.com/products/9781789534207/graphics/6f4d2d91-0586-476f-a033-a873a95d43cf.png)
Let's decipher this equation.
![](https://static.packt-cdn.com/products/9781789534207/graphics/abebf13a-ca60-4f4b-a264-e798d90190bc.png)
and
![](https://static.packt-cdn.com/products/9781789534207/graphics/3cab578a-692c-4b9a-854e-14ea48f30398.png)
are the input and labels of the support set.
![](https://static.packt-cdn.com/products/9781789534207/graphics/ac51fd77-df9c-4d69-b035-91ddb2af8ed6.png)
is the query input— the input to which we want to predict the label....