# Dual-Branch Multi-Scale Relation Networks with Tutorial Learning for Few-Shot Learning
## 3 Methodology
### Relation Networks Module  
A relation network [9] is employed to supersede the predefined distance metric and learn a suitable approach to learn the similarity metric between support and query feature pairs. Therefore, the support feature of each class is concatenated with the query feature in the channel dimension after obtaining the output of the previous module, and then the support-query feature pairs are fed into this module to obtain the ultimate relation scores. Figure 3: Illustration of multi-scale feature generator. The proposed relation networks module is designed differently in the dual-branch structure. In Branch 1, there are 5 different scales. In each scale, the query feature is spliced with the support features of each category, and the feature pairs are fed into the weight-shared relation network. However, the common relation network [9] is known sensitive to the spatial location of the compared objects [10]. We employ an improved relation network [11] in Branch 1, which incorporates a Kronecker-product (\(KP\)) module [55; 56] to acquire positionwise correlation maps between feature pairs for more enhanced metric learning and improved generalization capability. Initially, we are given two original features to form a support-query feature pair from the identical scale., and the \(KP\) module is applied to generate spatial correlation maps: \(\hat{\beta}_{\left(\varphi_{s}^{z},\varphi_{s}^{z}\right)}=KP\Big{(}\Phi_{s} ^{z},\Phi_{q}^{z}\Big{)}\) and \(\hat{\beta}_{\left(\varphi_{q}^{z},\varphi_{s}^{z}\right)}=KP\Big{(}\Phi_{q} ^{z},\Phi_{s}^{z}\Big{)}\) by applying the feature maps. Next, the spatial encoding maps created are concatenated with the original feature maps at each scale, and we have a relation score as follows:  
\[r_{s,q}^{z}=R_{\varphi}\Big{(}Concate\Big{(}\Phi_{s}^{z},\hat{\beta}_{\left( \varphi_{s}^{z},\varphi_{s}^{z}\right)}^{z}\hat{\beta}_{\left(\varphi_{s}^{z },\varphi_{s}^{z}\right)},\Phi_{q}^{z}\Big{)}\Big{)},z\in\{1,...,5\} \tag{1}\]  
where \(z\) denotes the different scales, and \(Concate(\cdot)\) refers to the operation of splicing the features in the channel dimension. Therefore, for a C-way K-shot task, the total loss of Branch 1 is:  
\[\mathcal{L}_{Z}=\sum_{z=1}^{5}\sum_{i=1}^{n}\sum_{j=1}^{m}\ell^{CE}\Big{(}r_{i,j}^{z},\mathbf{1}\big{(}y_{i}=y_{j}\big{)}\Big{)} \tag{2}\]  
where \(\ell^{CE}\) denotes the cross-entropy loss, \(n=C\times K\) refers to the number of support images and \(m=C\times M\) refers to the number of query images in an episode. \(r_{i,j}^{z}\) is the relation score belonging to support image \(x_{si}\) and query image \(x_{qi}\). \(\mathbf{1}(\cdot)\) is equal to 1 when the condition is satisfied; otherwise, it equals 0. In the relation network module of Branch 2, the inputs consist of two sets of feature representations: \(\Phi_{s}^{d}=\left\{F_{\theta}^{d}(x_{s})\right\}_{d=1}^{2}\) and \(\Phi_{q}^{d}=\left\{F_{\theta}^{d}(x_{q})\right\}_{d=1}^{2}\) extracted by the feature extractor at different depths, as well as a set of feature representations \(\Phi_{s}^{5}\) and \(\Phi_{q}^{5}\) outputted by the fifth part of the multi-scale feature generator. The specific details are illustrated in Figure 4. At each layer, the query image features are concatenated with the support image features of each class and fed into the relation networks for similarity measurement. Due to the relatively large feature size at the low layer, we omit the introduction of the \(KP\) module here and solely adopt the relation networks proposed in [9]. Simultaneously, we transfer the relation information from shallow layers to deeper relation networks and concatenate it with deeper feature pairs.