SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Here,  $T$  and  $R$  denote the number of steps in an inner loop used to obtain the target and reference model respectively. In this paper, we used KL divergence  $(KL(s(f(\theta_t^T))|s(f(\theta_r^R)))$  as a distance metric  $D$ , but we also conducted experiments with other distance metrics such as  $L_2(||\theta_t^T - \theta_r^R||_2^2)$  and cross-entropy  $(- \sum_c s(f(\theta_t^T))_c \log s(f(\theta_r^R))_c$ , as shown in Table 6. We set  $T < R$  because our intention is to measure distortion caused by the Hessian in the inner loop. As we increase the number of optimization steps in the inner loop, the effect of distortion by the Hessian decreases. Therefore, we could use SHOT as a pseudo-measure of distortion in the inner loop caused by the Hessian. To match the scale of distribution between  $\theta_t^T$  and  $\theta_r^R$ , we set  $\alpha$  in Eq. 1 as  $\alpha_r = \frac{T}{R} \alpha_t$ .
Reducing the effect of Hessian along the optimization in the inner loop, as measured by Eq. 4, can lead to faster convergence and better performance. By minimizing the deviation from the ideal optimization trajectory, SHOT can effectively enforce the condition expressed in Eq. 3, which is critical for the success of GBML. As shot is the measure of distortion in the whole trajectory of an inner loop. We use SHOT at the outer loop, where scoring of each optimization trajectory is done.
Table 1 highlights the importance of distortion in GBML. We compared the performance of a randomly-initialized model with that of a lower-distortion-initialized model, where we only reduced the distortion introduced in Eq. 4 in the outer loop. As our SHOT loss is self-supervisory that can be applied without target class labels, no target labels are given here. The results demonstrate that the lower-distortion-initialized model outperforms the randomly-initialized model, indicating that distortion is a crucial factor in GBML. This also suggests that we can generally improve GBML by incorporating our loss term, SHOT.
4.3 SHOT can be used as a regularizer or meta-meta-initializer in the outer loop.
One potential approach to incorporating SHOT is to use it as a regularizer in GBML. This approach involves adding SHOT to the loss function of the outer loop during training, thereby leveraging it as a regularizer reducing the effect of the Hessian along the optimization trajectory. Alternatively, SHOT can be utilized as a meta-meta-initializer as is used to obtain Table 1. In this approach, the entire model is pre-trained with SHOT, i.e., The outer loss is substituted with  $L_{SHOT}$  without utilizing any labeling information. Then the model is trained with the original loss function. However, there is a vulnerability to homogeneous corruption, where the loss goes to zero only if  $\theta_t$  and  $\theta_r$  produce the same output of all inputs. As this phenomenon is trivial in the self-supervised learning area, we drew inspiration from BYOL Grill et al. [2020]. To address this issue, we added a projector to the reference model, while the target remained the same. We also augmented  $\mathcal{X}_t^\tau$ . After pre-training with SHOT, we started training by loading the best model with the highest validation accuracy. To differentiate between SHOT utilized as a regularizer and SHOT utilized as a meta-meta-initializer, we denote them as  $\mathrm{SHOT}_r$  and  $\mathrm{SHOT}_p$ , respectively.
4.4 SHOT does not require any computation burden
Several meta-learning algorithms have already assumed linearity in the inner loop. For example, FoMAML and Reptile Finn et al. [2017], Nichol et al. [2018] proposed Hessian-Free GBML algorithms that both assumed linearity in the inner loop. Additionally, ANIL Raghu et al. [2019] proposed a feature reuse concept that allows for translation to zero distortion in the inner loop. However, none of these studies explicitly argued that GBML implicitly suppresses the Hessian in the inner loop as an inductive prior, nor did they propose an algorithm that controls the Hessian. Our algorithm is similar to the 'SAM' optimizer Foret et al. [2020] or natural gradient descent Bonnabel [2013]. Like SAM and natural gradient descent, our algorithm searches for a good initialization point based on its curvature. However, SHOT finds it without much increasing the computational cost compared to normal gradient descent, which is a notable advantage over SAM or natural gradient descent. Although SAM uses a first-order computation term, it searches for flat minima by iteratively adding noise to each point. Natural gradient descent exploits the Fisher metric, which is a second-order computation cost.
On the other hand, we can make SHOT not give any computation burden. When we set the reference model  $\theta_r$  to exploit the same number of optimization steps in the inner loop as the baseline model and the target model  $\theta_t$  exploits one optimization step in the inner loop, because both models share the same initialization point  $\theta^0$ , i.e.,  $\theta_t^0 = \theta_r^0$ .  $\theta_t$  can be obtained by calculating the first optimization step of  $\theta_r$ . Therefore, SHOT does not require any additional backpropagation. What we require is only one more inference at the endpoint  $\theta_t^T$  for  $\mathrm{SHOT}_r$ . Also, even if we set  $\theta_r$  to have more optimization steps than the baseline model and set  $\theta_t$  to have the same number of optimization steps as the baseline model, the computation cost at test time is unchanged as it is only used in the training phase.
Datasets Our method is evaluated on miniImageNet [Vinyals et al., 2016], tieredImageNet Ren et al. [2018], Cars Krause et al. [2013], and CUB Welinder et al. [2010] datasets. miniImageNet and tieredImageNet are subsets of ImageNet Russakovsky et al. [2015] with 100 classes each and can be considered as general datasets. Cars and CUB are widely used benchmarks for fine-grained image classification tasks as they contain similar objects with subtle differences. By conducting experiments on these datasets, we can evaluate the performance of our method across a range of tasks.
Architectures We use 4-Conv from Finn et al. [2017] and ResNet-12 from Oreshkin et al. [2018] as our backbone architecture. We trained 4-Conv for 30k iterations and ResNet-12 for 10k iterations.
Experimental Setup To ensure a fair comparison, we fine-tuned MAML Finn et al. [2017] first, and our baselines outperformed the original paper. We used Adam Kingma and Ba [2014] as our optimizer and fixed the outer loop learning rate to  $10^{-3}$  and inner loop learning rate to 0.5 for 4-Conv, and  $10^{-5}$  and 0.01 for ResNet-12. We restricted the total number of steps in the inner loop to 3, as argued in Finn et al. [2017]. We set the number of steps to 1 for the target model  $\theta_t$  and 3 for the reference model  $\theta_r$  in our SHOT. With this setting, we can exploit SHOT without any additional computation burden as discussed in Sec 4.4. For  $\mathrm{SHOT}_r$ , we fixed  $\lambda$  to 0.1 when we set the original
Table 2: Test accuracy % of 4-conv network on benchmark data sets. The values in parentheses indicate the number of shots. The best accuracy among different methods is bold-faced.
Domain	General (Coarse-grained)	Specific (Fine-grained)
Dataset	minImageNet	tieredImageNet	Cars	Cub
MAML (1)	47.88 ± 0.55	46.93 ± 1.07	47.78 ± 0.99	57.04 ± 1.42
MAML + SHOTr (1)	47.97 ± 0.71	47.53 ± 0.59	50.44 ± 0.62	57.55 ± 0.64
MAML + SHOTp (1)	48.11 ± 0.26	47.53 ± 0.68	49.08 ± 0.88	58.23 ± 0.39
MAML (5)	64.81 ± 1.63	66.12 ± 1.10	62.24 ± 2.01	72.48 ± 0.86
MAML + SHOTr (5)	66.86 ± 0.58	69.08 ± 0.31	64.20 ± 1.58	73.38 ± 0.32
MAML + SHOTp (5)	66.35 ± 0.27	68.94 ± 0.87	64.84 ± 2.87	73.27 ± 0.40
Table 3: Test accuracy % of 4-conv network on cross-domain adaptation. The values in parentheses indicate the number of shots. The best accuracy among different methods is bold-faced.
adaptation	General to General	General to Specific	Specific to General	Specific to Specific
meta-train	tieredImageNet	miniImageNet	miniImageNet	miniImageNet	Cars	Cars	CUB	Cars
meta-test	miniImageNet	tieredImageNet	Cars	CUB	miniImageNet	tieredImageNet	Cars	CUB
MAML (1)	47.52 ± 1.66	51.84 ± 0.24	34.41 ± 0.47	40.91 ± 0.57	28.67 ± 1.17	30.79 ± 1.17	32.74 ± 1.12	30.95 ± 1.41
MAML + SHOTr(1)	48.20 ± 0.64	51.68 ± 0.68	34.03 ± 1.11	41.58 ± 0.56	30.19 ± 0.50	31.96 ± 0.50	33.11 ± 0.41	31.21 ± 0.64
MAML + SHOTp(1)	48.45 ± 0.13	51.97 ± 0.25	34.84 ± 0.16	41.65 ± 0.70	29.02 ± 0.73	31.26 ± 0.54	33.69 ± 0.45	31.65 ± 0.39
MAML (5)	66.86 ± 1.58	67.96 ± 1.22	46.57 ± 0.53	56.32 ± 1.17	37.23 ± 1.95	41.00 ± 1.86	44.02 ± 2.29	41.84 ± 1.25
MAML + SHOTr(5)	70.70 ± 0.29	69.48 ± 0.17	48.42 ± 0.72	58.40 ± 0.48	40.79 ± 0.93	42.73 ± 0.32	44.47 ± 0.25	43.46 ± 0.89
MAML + SHOTp(5)	69.88 ± 0.53	69.83 ± 0.34	47.99 ± 2.10	58.30 ± 0.44	37.96 ± 1.14	41.94 ± 0.23	43.83 ± 1.06	40.64 ± 1.25
model as  $\theta_r$ . For one-step algorithms, we set the number of optimization steps to 2 for  $\theta_r$  and 1 for  $\theta_t$ . So actual optimization step in inference time is 1, which is the same as the baseline. We set  $\lambda$  for  $10^{-6}$  in that case. For the Hessian-Free algorithm FoMAML, we fine-tuned  $\lambda$  to meet the best performance. We set the learning rate of the outer and inner loops to  $10^{-4}$  and 0.01, respectively, for 4-Conv. To maintain conciseness, we only report the results of  $\mathrm{SHOT}_r$  except for the comparison with MAML baseline. We conducted our experiments on a single A100 GPU. We implemented our method using torchmeta Deleu et al. [2019] library except for the implementation of LEO Rusu et al. [2018a], where we used the official implementation and embeddings.
5.1 Characteristics of SHOT
SHOT Outperforms the Baselines on Benchmarks and Cross-Benchmark Settings Our method, SHOT, outperforms the corresponding baseline on all benchmarks, as shown in Table 2. Both  $\mathrm{SHOT}_r$  and  $\mathrm{SHOT}_p$  outperform the baseline, regardless of whether the benchmark is general or fine-grained. Additionally, SHOT generalizes well to cross-benchmark settings, as demonstrated in Table 3, where it improves the performance of the baseline. Also, we can see that this result is independent of the backbone architecture, as shown in Table 4.
Table 4: Test accuracy % of ResNet-12. The values in parentheses indicate the number of shots. The better accuracy between the baseline and SHOT is bold-faced.
meta-train	miniImageNet
meta-test	miniImageNet	tieredImageNet	Cars
MAML (1)	49.47 ± 0.43	54.88 ± 1.07	32.74 ± 0.48
MAML + SHOTr (1)	51.11 ± 0.32	55.14 ± 0.63	32.66 ± 0.27
MAML (5)	69.12 ± 0.08	71.60 ± 0.08	51.99 ± 0.25
MAML + SHOTr (5)	69.74 ± 0.16	71.71 ± 0.39	52.16 ± 0.28
SHOT works with Hessian-Free and One-Step algorithms As many GBML algorithms are based on Hessian-Free algorithms which only exploit gradients and One-Step algorithms which only exploit one step in the inner loop Finn et al. [2017], Nichol et al. [2018], Oh et al. [2020], Raghu et al. [2019], it is important to show that our method also works with these algorithms. As shown in Table 5, our method improves the performance of the baseline on both Hessian-Free and One-Step algorithms. For One-Step algorithms, we set  $\theta_{t}$  as the original model and  $\theta_{r}$  as the 2-step optimized model. This is practically useful since many algorithms exploit only one step in the inner loop. Notably, our method is applied only in the training phase, so it has the same inference cost as the baseline. Also, we only used first-order optimization for the meta-optimizer to ensure a fair comparison when adding SHOT to FoMAML. For ANIL Raghu et al. [2019] and BOIL Oh et al. [2020], we conducted experiments with the same settings from each baseline paper, and we bring the results from Oh et al. [2020] for comparison.
SHOT enables faster convergence. Our method, SHOT, achieves faster convergence compared to the baseline, as demonstrated in Figure 3, where we plot the validation accuracy against the training
Table 5: Test accuracy (\%) of 4-conv network on benchmark data sets. The values in parentheses indicate the number of shots. The better accuracy between the baseline and SHOT is bold-faced. Baselines in the table correspond to either one-step algorithm (which uses one step optimization in the inner loop) or Hessian-Free algorithm (an algorithm which only uses gradients in the outer loop).
Domain	General(Coarse-grained)	Specific (Fine-grained)
Dataset	miniImageNet	tieredImageNet	Cars	Cub
FoMAML (1)	47.70 ± 0.56	47.72 ± 0.76	49.08 ± 1.46	60.18 ± 0.45
FoMAML + SHOTr, (1)	48.49 ± 0.29	47.91 ± 0.59	48.59 ± 0.72	60.54 ± 0.29
ANIL (1)	47.82 ± 0.20	49.35 ± 0.26	46.81 ± 0.24	57.03 ± 0.41
ANIL + SHOTr, (1)	48.02 ± 0.38	48.29 ± 0.93	47.82 ± 1.48	57.31 ± 0.89
BOIL (1)	49.61 ± 0.16	48.58 ± 0.27	56.82 ± 0.21	61.60 ± 0.57
BOIL + SHOTr, (1)	50.36 ± 0.42	50.36 ± 0.49	56.22 ± 1.96	62.43 ± 0.30
FoMAML (5)	64.49 ± 0.46	65.25 ± 0.64	67.99 ± 1.20	73.18 ± 0.18
FoMAML + SHOTr, (5)	64.58 ± 0.06	65.92 ± 0.22	68.02 ± 1.00	73.89 ± 0.18
ANIL (5)	63.04 ± 0.42	65.82 ± 0.12	61.95 ± 0.38	70.93 ± 0.28
ANIL + SHOTr, (5)	64.40 ± 0.75	66.19 ± 0.13	61.00 ± 0.90	71.71 ± 1.34
BOIL (5)	66.45 ± 0.37	69.37 ± 0.12	75.18 ± 0.21	75.96 ± 0.17
BOIL + SHOTr, (5)	66.34 ± 0.21	69.20 ± 0.25	75.25 ± 0.14	76.77 ± 0.51
epoch. To understand why this occurs, we plotted averaged cosine similarity between the overall parameter difference with each inner gradient step in the inner loop, as shown in Figure 3. We found that overall similarity increases in both cases of with and without SHOT, and the similarity is highly correlated with the validation accuracy. SHOT enforces high similarity from the beginning, resulting in faster convergence with better generalization ability.
Applying other distance metrics. We used KL divergence as a distance metric in SHOT, but it is possible to use other metrics as well. For example, we could use cross-entropy as a distance metric from a probability perspective, or we could use L2 distance between parameters as a distance metric. We conducted experiments with different distance metrics, and for L2 distance we divided the L2 distance by the square root of the number of parameters to account for the initialization scheme Kumar [2017]. For the cross-entropy loss, we used the same  $\lambda$  (balancing term for Eq. 4) settings as for KL divergence. The results are shown in Table 6. We observed that SHOT outperformed the baseline for every distance metric. This supports our hypothesis that we can improve performance and dynamics by suppressing the effect of the Hessian along the optimization trajectory.
In this paper, we claim that GBML implicitly suppresses the Hessian along the optimization path. We also demonstrate that we can improve the performance of GBML by explicitly enforcing this implicit prior. To achieve this, we propose a novel method, SHOT (Suppressing the Hessian along Optimization Trajectory). Although it deals with curvature of the loss surface, it has the same computational order compared to other GBML methods. More specifically, it adds a negligible computational overhead to the baseline and costs the same at inference time. We show that SHOT outperforms the baseline and is algorithm- and architecture-independent.
Table 6: Test accuracy % of 4-conv using SHOT with various distance metrics. The values in parentheses indicate the number of shots. The better accuracy between the baseline and SHOT is bold-faced.
meta-train	miniImageNet
meta-test	miniImageNet	tieredImageNet	Cars
Baseline (1)	47.88 ± 0.55	51.84 ± 0.24	34.41 ± 0.47
KL-Divergence (1)	47.97 ± 0.71	51.68 ± 0.68	34.03 ± 1.11
Cross-Entropy (1)	49.07 ± 0.14	53.83 ± 0.14	34.54 ± 0.31
L2 Distance (1)	50.89 ± 0.06	54.63 ± 0.25	35.75 ± 0.29
Baseline (5)	64.81 ± 1.63	67.96 ± 1.22	46.57 ± 0.53
KL-Divergence (5)	66.86 ± 0.58	71.77 ± 0.42	48.42 ± 0.72
Cross-Entropy (5)	66.34 ± 0.35	69.47 ± 0.35	48.86 ± 0.71
L2 Distance (5)	66.85 ± 0.44	69.96 ± 0.27	48.40 ± 0.12
We believe that our method can be applied to other GBML methods in a plug-and-play manner.
This work was supported by NRF grant (2021R1A2C3006659) and IITP grants (2021-0-01343, 2022-0-00953), all of which were funded by Korean Government (MSIT).
A Proof of (3)
Due to fundamental theorem of calculus,
$$
L \left(\theta^ {k + 1}\right) - L \left(\theta^ {k}\right) = \int_ {C} \nabla L (\theta) \cdot d \theta = \int_ {0} ^ {1} \nabla L (\theta (t)) \cdot v (t) d t, \tag {5}
$$
where  $C$  is a trajectory whose start and end points are  $\theta^k$  and  $\theta^{k + 1}$ . In GD setting, because  $\theta^{k + 1} = \theta^k -\alpha \nabla L(\theta^k)$  for some learning rate  $\alpha >0$ , we can think of the straight line trajectory joining  $\theta^k$  and  $\theta^{k + 1}$ . In this case, the velocity vector becomes  $v(t) = -\alpha \nabla L(\theta^k)$  and
$$
L \left(\theta^ {k + 1}\right) - L \left(\theta^ {k}\right) = - \alpha \int_ {0} ^ {1} \nabla L (\theta (t)) \cdot \nabla L \left(\theta^ {k}\right) d t \tag {6}
$$
where  $\theta (0) = \theta^k$ $\theta (1) = \theta^{k + 1}$  and  $\theta (t) = (1 - t)\theta (0) + t\theta (1)$
By Taylor series expansion it becomes
$$
\nabla L (\theta (t)) \approx \nabla L \left(\theta^ {k}\right) + H \left(\theta^ {k}\right) \left(\theta (t) - \theta^ {k}\right) = \left(I - \alpha t H \left(\theta^ {k}\right)\right) \nabla L \left(\theta^ {k}\right) \tag {7}
$$
and combining Eq.(6) and Eq.(7) proves Eq.(3).
B SHOT is robust to hyperparameter settings
Table 7: Test accuracy % of 4-conv using SHOT with different  $\lambda$  values. The values in parentheses indicate the number of shots. The better accuracy between the baseline and SHOT is bold-faced.
size of λ	miniImageNet (5)
0 (baseline, MAML)	64.81 ± 1.63
0.1 (SHOTr)	66.86 ± 0.58
10-2	65.97 ± 0.93
10-3	66.85 ± 0.47
10-4	66.08 ± 0.36
10-5	66.81 ± 0.28
Table 7 shows the performance of SHOT with various hyperparameter settings. We conducted experiments with different learning rates of  $\lambda$ , and in all cases, SHOT improved the performance of the baseline. This suggests that SHOT is robust to hyperparameter settings.
C Another viewpoint of ANIL and BOIL
In this section, we reconcile the opposite opinions of feature reuse versus feature adaptation in gradient-based meta-learning (GBML) with our hypothesis that reducing the impact of the Hessian in the inner loop can improve performance.
ANIL, proposed in Raghu et al. [2019], argues that feature reuse is key in the inner loop, where the feature remains invariant while only the decision boundary is adapted. On the other hand, BOIL, proposed in Oh et al. [2020], argues that feature adaptation is key in the inner loop, where the feature is adapted while the decision boundary remains invariant.
To test their arguments, ANIL and BOIL proposed two algorithms. ANIL freezes the encoder and only updates the head in the inner loop, while BOIL freezes the head and only updates the encoder in the inner loop. The problem is that both algorithm shown good performance thereby both arguments look persuasive despite they argue exactly in the opposite ways.
Our hypothesis, which suggests that the outer loop implicitly suppresses the Hessian along the optimization trajectory, can reconcile the arguments of both ANIL and BOIL. This is because our hypothesis implies that the model acts linearly in the inner loop. ANIL and BOIL can be interpreted as algorithms that enforce linearity in the inner loop by restricting parameters and reducing the number of non-linear components between layers.
ANIL freezes the encoder and only updates the head in the inner loop, reducing the number of nonlinear components in the inner loop. This enforces linearity in the inner loop, as the only non-linearity is the loss function. ANIL achieves better performance than MAML in 1-step optimization, as it is more powerful at 1-step optimization, which views the model as linear.
BOIL freezes the head and only updates the encoder in the inner loop, reducing the number of non-linear components in the inner loop. By applying BOIL, the gradient norm is predominant in the last layer of the encoder, making it a variant of ANIL that updates only the penultimate layer. This layer has much stronger performance, as it can change the feature while maintaining the linearity of the model. Table 14 of Oh et al. [2020] shows a boosted performance when all but the penultimate layer is not frozen. By explicitly enforcing linearity in the inner loop, BOIL achieves improved performance.
D GBML is a variant of Prototype Vector method
In this section, we provide a novel viewpoint of GBML, that GBML (Gradient-Based Meta Learning) is a variant of MBML (Metric-Based Meta Learning). This viewpoint relies on the linearity assumption. i.e., the effect of the Hessian along the optimization trajectory is zero, thereby the model act as linear in the inner loop.
Suppose there exists a meta-learning model that satisfies the linearity assumption in the inner loop, then classifying a new classification task with a task-specific function  $f(\cdot |\theta^{\star})$  after an inner loop is equivalent to creating a prototype vector for each class on a specific feature map and classifying the input as the class of the most similar prototype vector.
The proof starts by defining the prototype vector at first.
Prototype Vector We define a prototype vector  $V_{c}$  for class  $c$  in an  $N$ -way  $K$ -shot classification task formally as
$$
V _ {c} = \sum_ {i = 1} ^ {N} \sum_ {j = 1} ^ {K} \beta_ {i j} \varphi_ {c} \left(X _ {i j}\right), \quad c \in \{1, \dots , N \}, \tag {8}
$$
where  $X_{ij}$  is the  $j$ -th input sample for the  $i$ -th class,  $\varphi_c(\cdot)\in \mathcal{H}$  is a class-specific feature map and  $\beta_{ij}$  indicates the importance of  $X_{ij}$  for constituting the prototype vector  $V_{c}$ .
In other words, there exists a feature map  $\varphi_{c}$  for each class  $c$ , and the support set is mapped to the corresponding feature map and then weighted-averaged to constitute the prototype vector of the corresponding class. At inference time, the classification of a given query  $X$  is done by taking the class of the most similar prototype vector as follows:
$$
\hat {c} = \underset {c} {\arg \max } \left\langle V _ {c}, \varphi (X) \right\rangle . \tag {9}
$$
Here,  $\varphi : \mathcal{X} \to H$  is a non-class-specific mapping. We can also rewrite the prototype vector using  $\varphi$  and by defining a projection  $P_{c} : \mathcal{X} \to \mathcal{X}$  as
$$
P _ {c} (X) = \left\{ \begin{array}{l l} X & \text {i f} y (X) = c, \\ \nu \in \mathcal {N} (\varphi), & \text {i f} y (X) \neq c \end{array} \right. \tag {10}
$$
where  $y(X)$  is the ground truth class of  $X$  and  $\mathcal{N}$  is the null space of  $\varphi$  i.e.,  $\varphi (\nu) = 0$ .
Then by defining  $\varphi_{c} \triangleq \varphi \circ P_{c}$  and  $\beta_{ij} \triangleq \frac{1}{K}$ , it becomes
$$
V _ {c} = \frac {1}{K} \sum_ {j = 1} ^ {K} \varphi \left(X _ {c j}\right). \tag {11}
$$
SGD in the inner loop If GBML satisfies the hypothesis of linearity in the inner loop,  $f$  is locally linear in  $\theta$  in an inner loop. More specifically, there exists an equivalent feature map  $\varphi_c: \mathcal{X} \to \mathcal{H}$
which satisfies  $f_{c}(\cdot |\theta_{c}) = \langle \theta_{c},\varphi_{c}(\cdot)\rangle$  for every  $x\in \mathcal{X}$  where  $f(\cdot |\theta) = [f_1(\cdot |\theta_1),\dots ,f_N(\cdot |\theta_N)]^T$ . With the loss function  $L(x,y|\theta) = D(s(f(x|\theta)),y)$  for some distance measure  $D$  such as cross entropy, we can formulate the inner loop of  $N$ -way  $K$ -shot meta learning by SGD as
$$
\theta_ {c} ^ {k + 1} = \theta_ {c} ^ {k} - \alpha \sum_ {i = 1} ^ {N} \sum_ {j = 1} ^ {K} \frac {\partial L \left(X _ {i j} , y \left(X _ {i j}\right) \mid \theta\right)}{\partial \theta_ {c}} = \theta_ {c} ^ {k} - \alpha \sum_ {i = 1} ^ {N} \sum_ {j = 1} ^ {K} \frac {\partial D}{\partial f _ {c}} \varphi_ {c} \left(X _ {i j}\right), \tag {12}
$$
since all samples in the support set are inputted in a batch of an inner loop.
Because the model is linear in the inner loop, the batch gradient does not change. Let  $\beta_{ij} = -\frac{\partial D}{\partial f_c}\big|_{\theta_c^0,X_{ij}}$ . Then after  $t$  steps, by (8), the model becomes