# Effect of Probabilistic Similarity Measure on Metric-Based Few-Shot Classification
## 4 Proposed Method  
### Few-Shot Classification Using Probabilistic Similarity  
The assumption for deriving the explicit form of Equation (6) is rather impractical to deal with diverse variations of real data, but it could be effectively applied to the data representation obtained from the well-trained embedding function. Based on this consideration, we propose to combine the probabilistic similarity with the metric-based few-shot classification model. Though the probabilistic similarity does not depend on the structure of the embedding network and can be combined with various few-shot learning models, we adopt the prototypical network, the primary and representative model, in order to focus on the effect of the similarity.  
When the probabilistic similarity \(S_{G}(\mathbf{x},\ \mathbf{x}^{\prime})\) of Equation (6) is applied to the few-shot classification model, \(\mathbf{x}\  
prototype vector \(c_{k}\) for each class \(c_{k}\) is calculated first by taking the mean of embedding support vectors \(f_{\phi}(\mathbf{x})\) in \(c_{k}\), which is written as:  
\[\mathbf{c}_{k}=\frac{1}{|S_{k}|}\sum_{\mathbf{x}\in S_{k}}f_{\phi}(\mathbf{x}). \tag{8}\]  
Then, the class-label of query data \(\mathbf{x}\) is determined by the similarity between embedding query vector \(f_{\phi}(\mathbf{x})\) and the prototype \(\mathbf{c}_{k}\) for each class \(c_{k}\);  
\[S_{G}\big{(}f_{\phi}(\mathbf{x}),\,c_{k}\big{)}=-\big{(}f_{\phi}(\mathbf{x})-c_{k} \big{)}^{T}\sum_{\Omega}{}^{-1}\big{(}f_{\phi}(\mathbf{x})-\mathbf{c}_{k}\big{)} \tag{9}\]  
According to the format of the distance-based classifier, the similarity function defined above is rewritten as a distance function and we finally obtain:  
\[dist\Big{(}f_{\phi}(\mathbf{x}),\,\mathbf{c}_{k},\,\sum_{\Omega}\Big{)}=\big{(}f_{\phi }(\mathbf{x})-\mathbf{c}_{k}\big{)}^{T}\sum_{\Omega}{}^{-1}\big{(}f_{\phi}(\mathbf{x})- \mathbf{c}_{k}\big{)} \tag{10}\]  
Here, the covariance matrix \(\sum_{\Omega}\) is a parameter to be estimated during learning of embedding network as well as classification. Note that this probabilistic similarity has an advantage in that the number of samples for estimating \(\sum_{\Omega}\) is relatively large even under the few-shot situation. Since the set of intra-class difference vectors is used for estimation, the number of samples in \(\Omega\) is finally \(N\times K^{2}\) in the case of the \(N\)-way \(K\)-shot problem.  
In the few-shot classification, it is important to catch common distributional property shared by different classes at the learning phase and use them to classify the newly given classes in the test phase. Since the probabilistic similarity measure is derived from the distribution of environmental components shared by all classes, it can be estimated iteratively through episodic learning.  
At \(t\)-th iteration of episodic learning, with the set of difference vectors \(\Omega_{t}\), the covariance \(\sum_{t}\) is estimated as:  
\[\sum_{t}=(1-\alpha)\sum_{\Omega}+\alpha\sum_{t-1}, \tag{11}\]  
where \(\alpha(0\leq\alpha\leq 1)\) is a user-defined parameter to control the proportion of the previously obtained estimation at \((t-1)\)-th episode. In the test phase, we have the set of difference vectors \(\Omega_{\text{lst}}\) composed of support samples in test classes, and the covariance \(\sum_{lst}\) is estimated as:  
\[\sum_{lst}=(1-\alpha)\sum_{\Omega_{lst}}+\alpha\sum_{tm^{\prime}} \tag{12}\]  
where \(\sum_{tm}\) is the covariance estimated by using the whole train set after learning is finished, and it is added to the covariance of the set of \(\Omega_{lst}\) with a user-defined coefficient \(\alpha(0\leq\alpha\leq 1)\). We should note that the estimated covariance can be near singular under the few-shot settings, especially when the dimension of the embedding vector is larger than a number of samples in \(\Omega\). In that case, we need to add a regularization term (e.g., identity matrix) to prevent a singular condition of its inverse matrix.