# UNEM: UNrolled Generalized EM for Transductive Few-Shot Learning

Long Zhou, Fereshteh Shakeri, Aymen Sadraoui, Mounir Kaaniche, Jean-Christophe Pesquet, Ismail Ben Ayed

► To cite this version:

Long Zhou, Fereshteh Shakeri, Aymen Sadraoui, Mounir Kaaniche, Jean-Christophe Pesquet, et al. UNEM: UNrolled Generalized EM for Transductive Few-Shot Learning. CVPR 2025 - Computer Vision and Pattern Recognition Conference, Jun 2025, Nashville (Tennessee), United States. hal-05092880

HAL Id: hal-05092880

https://hal.science/hal-05092880v1

Submitted on 2 Jun 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# UNEM: UNrolled Generalized EM for Transductive Few-Shot Learning

Long Zhou¹,³, Fereshteh Shakeri², Aymen Sadraoui³,
Mounir Kaaniche³,⁴, Jean-Christophe Pesquet³, Ismail Ben Ayed²

¹Politecnico di Milano

²ÉTS Montréal

³Université Paris-Saclay, Inria, CentraleSupélec, CVN

⁴Université Sorbonne Paris Nord, L2TI, UR 3043

## Abstract

Transductive few-shot learning has recently triggered wide attention in computer vision. Yet, current methods introduce key hyper-parameters, which control the prediction statistics of the test batches, such as the level of class balance, affecting performances significantly. Such hyper-parameters are empirically grid-searched over validation data, and their configurations may vary substantially with the target dataset and pre-training model, making such empirical searches both sub-optimal and computationally intractable. In this work, we advocate and introduce the unrolling paradigm, also referred to as “learning to optimize”, in the context of few-shot learning, thereby learning efficiently and effectively a set of optimized hyper-parameters. Specifically, we unroll a generalization of the ubiquitous Expectation-Maximization (EM) optimizer into a neural network architecture, mapping each of its iterates to a layer and learning a set of key hyper-parameters over validation data. Our unrolling approach covers various statistical feature distributions and pre-training paradigms, including recent foundational vision-language models and standard vision-only classifiers. We report comprehensive experiments, which cover a breadth of fine-grained downstream image classification tasks, showing significant gains brought by the proposed unrolled EM algorithm over iterative variants. The achieved improvements reach up to 10% and 7.5% on vision-only and vision-language benchmarks, respectively. The source code and learned parameters are available at https://github.com/ZhouLong0/UNEM-Transductive.

<figure><img src="image_2.png" /><figcaption>Figure 1. Impact of the class-balance hyperparameter $\lambda$ on the accuracy of transductive few-shot classification. The accuracy results are obtained using the EM-Dirichlet algorithm [33] applied to vision-language models (with 4-shots). The plot shows that the choice of $\lambda$ has a strong impact on the performance, and that the optimal $\lambda$ (indicated with the star symbol) might vary by orders of magnitudes, depending on the target downstream dataset (e.g., the ten very different fine-grained classification datasets). Further comments on the optimal $\lambda$ values and the values chosen in [33] are provided in Section 4. The values of the learned hyper-parameters based on the proposed unrolled algorithm are illustrated and analyzed in Appendix D.</figcaption></figure>

## 1. Introduction

Deep learning has transfigured computer vision, driving substantial progress in tasks such as image classification, captioning, object detection and segmentation. However, these successes often come with a high cost: the requirement for large amounts of labeled data. Additionally, the generalization of these models is seriously challenged when evaluated on new classes (concepts), unseen during pre-
training, or when operating under distribution shifts [1, 53].

To address these challenges, Few-Shot Learning (FSL) has recently attracted wide attention within the computer vision community. In the standard few-shot image classification setting, a feature extractor is first pre-trained on a set of classes, often called the base classes. Then, the model is adapted and evaluated on new classes and tasks. Each evaluation task is performed on a set of unlabeled samples (referred to as the query set), and supervised by a support set composed of few labeled samples per new class. Earlier FSL methods have relied on various concepts, including meta-learning [11, 19, 40], transfer learning [13, 38, 43], and metric learning [20, 26, 51]. However, most of these works operate within the inductive setting, where, at inference time, the prediction for each sample is made independently from the other samples in the query set.

Recently, significant attention has shifted to the *transductive* scheme, in which inference is performed jointly on a batch of query samples. Transduction leverages the statistics of the unlabeled query samples, yielding notable performance gains, and have triggered a large body of recent works in few-shot learning, with various methods and mechanisms [4, 23–25, 29, 32, 59], as detailed in Section 2. Generally, transductive methods are built upon optimizing objective functions that integrate clustering terms, either discriminative as in information maximization [4, 50] or generative as in probabilistic K-means [32, 33]. However, many among these assume a perfectly balanced class distribution within the query set, and incorporate terms in the objective function or constraints that enforce a class-balance prior. The latter could limit the applicability of these methods, whose performances were shown to drop significantly when dealing with imbalanced query sets [27, 50].

Several recent attempts tackled this limitation, to handle more realistic scenarios [24, 32, 33, 48, 50]. Yet, these methods introduce key hyper-parameters, which control the prediction statistics of the unlabeled query set, such as the level of class balance. Such hyper-parameters are empirically grid-searched over pre-defined sets of values using validation data, and their optimal configurations may vary substantially with the target dataset and pre-training model [17]. To illustrate this, we depict in Fig. 1 the accuracy as a function of a class-balance hyper-parameter for the recent method in [33]. One may observe that this hyper-parameter has a crucial effect on the performance, and its optimal value might vary by orders of magnitude across the target datasets. The issue is further compounded by additional hyper-parameters, which makes intensive empirical grid searches for the hyper-parameters over validation data and pre-defined intervals of values both sub-optimal and computationally intractable. Therefore, we advocate and introduce the unrolling paradigm (also called “learning to optimize”) in the context of few-shot learning, which enables

to learn efficiently and effectively a set of optimized hyper-parameters. Specifically, our main contributions could be summarized as follows:

1. We study a generalization of the ubiquitous Expectation-Maximization (EM) algorithm, in which we make two hyper-parameters controlling prediction statistics – class balance and prediction entropy – explicit<fnref n="1" />. Our generalization encompasses several existing transductive few-shot methods as particular cases and, more importantly, enables to learn these crucial hyper-parameters through the proposed unrolling strategy.

2. We unroll the generalized EM optimizer into a neural network architecture, mapping each of its iterations to a layer and learning the introduced hyper-parameters over validation data. Our unrolling approach offers greater flexibility in optimizing the hyper-parameters, allowing them to vary across the network’s layers. To the best of our knowledge, this study is the first to investigate unrolling in transductive few-shot learning.

3. We design our unrolling architecture in way that covers various statistical assumptions and pre-training paradigms: (i) Gaussian for vision-only classifiers and (ii) Dirichlet for vision-language models.

4. We report comprehensive experiments, which cover a breadth of fine-grained downstream image classification tasks and different pre-training models, showing substantial gains over recent state-of-the-art methods.

## 2. Related works

**Few-shot classification with vision-only models:** Few-shot classification using vision models has been widely explored in the literature, leading to the development of various methods. The first category, inductive methods, predicts the class of each test sample (in the query set) independently from others [16, 30]. In contrast, the second category, transductive methods, which has gained increasing attention in recent years, involves jointly predicting classes for a batch of test samples in each few-shot task. Numerous research efforts in transductive methods have leveraged concepts like clustering [24, 32], label propagation [29, 59], information maximization [4, 50], optimal transport [23, 49], prototype estimation [28, 59], and variational networks [25, 44], among others. Studies have shown that transductive methods significantly outperform inductive approaches, achieving accuracy gains of up to 15% as reported in several evaluations [4, 32].

**Few-shot classification with vision-language models:** Contrastive Vision-Language Pre-training (CLIP) has recently emerged as an effective model for enhancing various vision tasks through visual-text pairs. By learning transferable visual models with natural language supervision, CLIP

<footnote n="1">¹Those hyper-parameters are implicit (hidden) in the standard EM formulation.</footnote>
demonstrates strong performance in zero-shot classification by matching the image features to text embeddings of novel classes [39]. To further enhance its classification capabilities, several studies have extended CLIP to the few-shot setting [6, 18, 55, 57, 58]. While the linear probe model [39] trains a logistic regression classifier using CLIP image features, the authors of [18] proposed a generalization of this baseline, modeling the classifier weights as learnable functions of the visual prototypes and text embeddings. Context Optimization (CoOp) [57] and its extended versions [6, 55, 58] have been developed based on the concept of prompt learning. While CoOp [57] aims to model context in prompts using continuous representations, a knowledge-guided CoOp is proposed in [55] to enhance the generalization ability by minimizing the discrepancy between the learnable prompts and the original ones. In [6], the authors learn multiple prompts, describing the characteristics of each class, through the minimization of an optimal-transport distance. Unlike prompt learning methods, which fine-tune the input text, another family of methods, referred to as *adapters*, aims to transform the visual or text encoders, such as [12, 56]. For instance, TIP-Adapter [56] adds a non-parametric adapter to the weight-frozen CLIP model, and updates the prior knowledge encoded in CLIP by feature retrieval. CLIP-Adapter [12] introduces a multi-layered perceptron to learn new features, and combine them with the original CLIP-encoded features via residual connections. It is worth noting that all the aforementioned methods belong to the inductive family. However, unlike vision-only models, the transductive few-shot setting is still not well investigated in the context of CLIP. To the best of our knowledge, the only transductive few-shot CLIP method is the one very recently proposed in [33], which, inspired by the Expectation Maximization algorithm, relies on the Dirichlet distribution to model the data. Moreover, as reported in [33], and unlike the behaviors observed with vision-only models, recent transductive few-shot methods do not always outperform their inductive counterparts with CLIP. This suggests that there is a need to further investigate transductive methods in the context of vision-language models, due to their aforementioned advantages with respect to inductive methods.

**Class-balance and hyperparameters setting:** Hyperparameter optimization has a large impact on the performance of a given iterative algorithm or learning model, and is generally tackled through greedy or gradient-based methods [34]. In the context of transductive few-shot learning, most of the existing methods have been designed for perfectly balanced query sets (i.e., uniform class distribution), and have shown drops in performances under class-imbalanced settings. To address this flaw, various methods have been developed in the last years [24, 32, 33, 48, 50]. For instance, in [48] the categorical probability of each query

sample is regularized to quantify the difference between the class marginal distribution and the uniform one. The works in [24, 32, 33, 50] explored various weighted terms, which are added to the objective functions, to mitigate the effect of the class-balance bias. To this end, some hyper-parameters are introduced, to weigh to contributions of such terms in the objective function. Unlike [32], where the introduced hyper-parameter has been theoretically chosen in order to compensate for the hidden class-balance bias in the used clustering objective, the hyper-parameters are often set in an empirical manner based on the validation classes of each dataset. Thus, a set of hyperparameter values (in a given range) are evaluated, and the ones yielding the highest accuracy are selected.

# 3. Proposed methodology

## 3.1. Generalized EM algorithm

**Preliminaries:** Let us first introduce the notations to formulate our transductive few-shot inference. Let {$z_n$}$_{1\le n\le N}$ denote the set of feature vectors extracted from a pre-training network, and which are to be classified, with $N$ the total number of samples within a given task. The whole dataset contains $K$ distinct classes, whereas the number of randomly sampled classes present in each mini-batch task might be much smaller than $K$. This subset of sampled classes may also vary across mini-batches, and the method does not assume any prior knowledge on the specific classes that may appear in each mini-batch.

Moreover, for a given few-shot task, let us denote by $\mathcal{S} \subset \{1, \dots, N\}$ and $\mathcal{Q} = \{1, \dots, N\} \setminus \mathcal{S}$ the indices of samples within the support (labeled) and query (unlabeled) mini-batch sets, respectively. For every $n \in \mathcal{S}$, $y_n = (y_{n,k})_{1\le k\le K} \in \{0, 1\}^K$ are the one-hot-encoded labels, such that, for every $k \in \{1, \dots, K\}$, $y_{n,k} = 1$ if the $n$-th sample belongs to class $k$, and $y_{n,k} = 0$ otherwise.

Finally, given the extracted feature vectors $z_n$, we assume that the data probability distribution knowing its class $k$ is modeled by a given law, whose probability density function (pdf) is denoted by $p(z_n | \theta_k)$ and characterized by a vector of parameters $\theta_k$. This means that the global distribution of $z_n$ is a mixture of these pdfs.

**Problem formulation:** Our goal is to identify the classes of the unlabeled samples in the query set by optimizing a general clustering objective function, while embedding supervision constraints from the few labeled samples within the support set. We do so by unrolling iterative block-coordinate optimizers of the objective functions over two sets of variables:

* Soft assignment vectors $\mathbf{u} = (\mathbf{u}_n)_{1\le n\le N} \in (\Delta_K)^N$, where $\Delta_K$ is the probability simplex of $\mathbb{R}^K$. For every $n \in \{1, \dots, N\}$, $\mathbf{u}_n = (u_{n,k})_{1\le k\le K}$ where, for every $k \in \{1, \dots, K\}$, $u_{n,k}$ can be interpreted as the probabil-
ity that the n-th sample belongs to class k. These probabilities have to be determined for the query set samples.

* Feature distribution parameters $\theta = (\theta_k)_{1 \le k \le K}$.

Consider the following general probabilistic clustering problem:

$$ \underset{\mathbf{u},\theta}{\text{minimize}} \mathcal{L}(\mathbf{u}, \theta) + \lambda \Psi(\mathbf{u}) + T \Phi(\mathbf{u}), \quad (1) $$

$$ \begin{array}{l} \text{subject to} \quad \mathbf{u}_n \in \Delta_K \quad \forall n \in \mathbb{Q}, \\ \phantom{\text{subject to} \quad \mathbf{u}_n \in \Delta_K \quad \forall n \in \mathbb{Q}} \mathbf{u}_{n,k} = y_{n,k} \quad \forall n \in \mathbb{S}, \forall k \in \{1, \dots, K\}. \end{array} $$

where weighing factor $\lambda$ and temperature scaling $T$ are learnable optimized hyper-parameters, which we will estimate through the proposed unrolling strategy (Section 3.2), and terms $\mathcal{L}$, $\Psi$ and $\Phi$ are detailed in the following.

* The first term in objective function (1) is the negative log-likelihood of the feature vectors:

$$ \mathcal{L}(\mathbf{u}, \theta) = - \sum_{n=1}^{N} \sum_{k=1}^{K} u_{n,k} \ln(p(z_n | \theta_k)) \quad (2) $$

This general log-likelihood model fitting term is well known in the context of clustering methods [5, 21]. In fact, it generalizes the standard $K$-means clustering objective to arbitrary distributions<fnref n="2" />. It is well-known that minimizing (2) has an inherent bias towards class-balanced clustering [5, 21, 32, 33].

* The second term in (1) controls the partition complexity of the model, penalizing the number of non-empty clusters in the solution. It corresponds to the Shannon entropy of class distribution $(\pi_k)_{1 \le k \le K}$, defined as

$$ \Psi(\mathbf{u}) = - \sum_{k=1}^{K} \pi_k \ln \pi_k, \quad (3) $$

where $\pi_k = \frac{1}{|\mathbb{Q}|} \sum_{n \in \mathbb{Q}} u_{n,k}$ is the proportion of query samples within class k, i.e., the empirical estimate of the marginal probability of class k.

**Class-balance hyper-parameter ($\lambda$):** The marginal entropy in (3) mitigates the class-balance bias of the log-likelihood clustering term in (2). It reaches its minimum for the extremely imbalanced solution in which all data samples are assigned to a single cluster, and its maximum for a perfectly balanced clustering. Hence, clearly, hyper-parameter $\lambda$ controls the level of class balance in the solution. As depicted in Fig. 1, this hyper-parameter has a crucial effect on the performance, and its optimal value might vary by orders of magnitude from one dataset to another. This makes exhaustive grid searches for optimal $\lambda$ over validation sets intractable computationally, which motivates learning this hyper-parameter through our unrolling strategy, as described in Section 3.2.

* The third term in (1) is an entropic barrier, enabling to soften assignments $u_{n,k}$, while imposing a non-negativity constraint on each of them. It is given by

$$ \Phi(\mathbf{u}) = \sum_{n=1}^{N} \sum_{k=1}^{K} u_{n,k} \ln u_{n,k}. \quad (4) $$

**Temperature scaling hyper-parameter ($T$):** Weighting factor $T$ in (1) controls the trade-off between the clustering term and the entropic barrier in (4), i.e., the level of softness of assignments $u_{n,k}$. Therefore, this hyper-parameter has an important effect on performances and on the marginal class probabilities appearing in the class-balance term in (3), which motivates learning it. As described in Section 3.2, our unrolling algorithm enables to cope with this extra parameter.

**Link to EM and other transductive few-shot methods:** We examine solving problem (1) with an iterative block-coordinate descent algorithm (see Algorithm 1), which alternates two steps, one updating distribution parameters $\theta_k^{(\ell)}$ and the other optimizing over class assignments $u_n^{(\ell)}$, at each iteration $\ell$. For the $u$-step, and due to the nonconvexity of $\Psi$, we proceed with a Majorization-Minimization (MM) strategy to minimize a surrogate convex function with respect to $u$ at each iteration. In addition, if $p(\cdot|\theta_k)$ is assumed to belong to the exponential family and $\theta_k$ are its canonical parameters, the estimation w.r.t. $\theta$, with $u$ fixed, is a convex problem. We provide further details on this general iterative optimization scheme in Appendix A. It is worth noting that, when $T=1$ and the data is modeled by the Dirichlet distribution, we recover the recent transductive few-shot learning algorithm in [33]. Interestingly, when $T=1$ and $\lambda = |\mathbb{Q}|$, we recover the well-known Expectation-Maximization (EM) algorithm for estimating the parameters of mixture of distributions; see Proposition 1 in [33]. Therefore, Algorithm 1 could be viewed as a generalized EM (GEM), in which hyper-parameters $\lambda$ and $T$ control the class balance as well as prediction softness, and could be made learnable.

**Examples of data models:** While a broad range of distribution models in the exponential family could be adopted, we focus in this paper on two popular ones.

* The first one is the Gaussian distribution, which is commonly used in standard clustering and transductive few-shot-methods applied to vision models [32, 46, 50]. By assuming a Gaussian distribution with mean $\theta_k$ and identity covariance matrix, the pdf $p(z_n|\theta_k)$ reads as follows

$$ p(z_n|\theta_k) \propto \exp\left(-\frac{1}{2}\|z_n - \theta_k\|^2\right). \quad (5) $$

* The second one is the Dirichlet distribution, which has recently shown good modelling performance in the context of transductive few-shot for vision-language mod-

<footnote n="2">²K-means corresponds to choosing the multivariate Gaussian distribution, with identity covariance matrix, for parametric density $p(z_n|\theta_k)$.</footnote>
**Algorithm 1 GEM based few-shot classification algorithm**

**Input:** Compute $z_n$ for the dataset samples, initialize $u_n^{(0)}$ and $\theta_k^{(0)}$, and fix the number of iterations $L$, for $\ell = 0, 1, \dots, L-1$ do

// Update Distribution parameters for each class using a given estimation algorithm (denoted here by “DP\_est”)

$$ \theta_k^{(\ell+1)} = \text{DP\_est}(u_{\cdot,k}^{(\ell)}, \theta_k^{(\ell)}), \quad \forall k \in \{1, \dots, K\}, $$

// Update class proportions

$$ \pi_k^{(\ell+1)} = \frac{1}{|\mathbb{Q}|} \sum_{n \in \mathbb{Q}} u_{n,k}^{(\ell)}, \quad \forall k \in \{1, \dots, K\}, $$

// Update assignment vectors for all query samples

$$ u_n^{(\ell+1)} = \text{softmax} \left( \frac{1}{T} \left( \ln p(z_n | \theta_k^{(\ell+1)}) + \frac{\lambda}{|\mathbb{Q}|} \ln(\pi_k^{(\ell+1)}) \right)_k \right), \quad \forall n \in \mathbb{Q}. $$

end for

<figure><img src="image_3.png" /><figcaption>Figure 2. An overview of the unrolled GEM algorithm for a given iteration. Each iteration $\ell$ corresponds to a network layer $\mathcal{L}^{(\ell)}$. Each layer depends on the vector of hyperparameters $(\lambda^{(\ell)}, T^{(\ell)})$.</figcaption></figure>

els such as CLIP [33]. For $z_n = (z_{n,i})_{1 \le i \le K}$ and $\theta_k = (\theta_{k,i})_{1 \le i \le K}$, the associated pdf is given by

$$ P(z_n | \theta_k) = \frac{1}{\mathcal{B}(\theta_k)} \prod_{i=1}^{K} z_{n,i}^{\theta_{k,i}-1} \mathbb{1}_{z_n \in \Delta_K}, \quad (6) $$

where the normalization factor $\mathcal{B}(\theta_k)$ is

$$ \mathcal{B}(\theta_k) = \frac{\prod_{i=1}^{K} \Gamma(\theta_{k,i})}{\Gamma\left(\sum_{i=1}^{K} \theta_{k,i}\right)}, \quad (7) $$

and $\Gamma$ denotes the Gamma function.

The necessary details related to feature representations in the cases of vision-only and vision-language models, distribution parameter estimation, and the resulting GEM algorithms for Gaussian and Dirichlet laws are provided in Appendices B and C, respectively.

## 3.2. UNrolled EM architecture (UNEM)

**Overview:** As discussed in Section 2, the choice of the optimal hyper-parameter, which controls the level of class balance, is a difficult task, often performed manually in the existing transductive few-shot classification methods. In addition to the class-balance parameter $\lambda$, Algorithm 1 involves an additional temperature parameter $T$, which makes hyper-parameter setting even more challenging. For this reason,

we propose in this paper to resort to the unrolling (called also learning to optimize) paradigm [35], which enables to learn efficiently a set of optimized hyper-parameters. It is important to note that unrolling iterative optimization algorithms has found successful applications in diverse signal and image processing tasks [2, 7, 35]. However, to the best of our knowledge, this work is the first to leverage the unrolling paradigm for hyper-parameter optimization in a few-shot learning context. The main idea behind the learning-to-optimize paradigm is to map each iteration of a given optimization algorithm to a network layer, stack all layers together, and view the hyper-parameters to be optimized as the network's learnable parameters. More precisely, to unroll our generalized EM algorithm, the number of iterations $L$ is used as the number of layers for the neural network architecture. Thus, each iteration $\ell \in \{0, 1, \dots, L-1\}$ is associated with a tailored layer $\mathcal{L}^{(\ell)}$, which performs the update rules defined in Algorithm 1:

$$ (\theta_k^{(\ell+1)}, \pi_k^{(\ell+1)}, u_n^{(\ell+1)}) = \mathcal{L}^{(\ell)} (\theta_k^{(\ell)}, \pi_k^{(\ell)}, u_n^{(\ell)}; \lambda^{(\ell)}, T^{(\ell)}) \quad (8) $$

where $(\lambda^{(\ell)}, T^{(\ell)})_{0 \le \ell \le L-1}$ is the vector of hyper-parameters to be learned. This leads to the UNrolled EM (UNEM) model shown in Fig. 2, which depicts the inputs and outputs of a given layer $\mathcal{L}^{(\ell)}$ as well as its three main blocks for the update rules.
<figure><img src="image_4.png" /><figcaption>Figure 3. Overall architecture of the designed UNEM.</figcaption></figure>

**Learned hyper-parameters:** Instead of a restricted number of handcrafted hyper-parameters (as often used in iterative algorithms), our unrolled algorithm offers more flexibility, enabling adaptation of the hyper-parameters along the processing workflow. This means that L vectors of hyper-parameters $(\lambda^{(\ell)}, T^{(\ell)})_{0 \le \ell \le L-1}$ could be learned and applied at each layer of the network. During the training of the unrolled model, we fulfill some design constraints, as described in more details in the following.

More specifically, to ensure the non-negativity of hyper-parameter $\lambda^{(\ell)}$, we propose to express it as a Softplus function, which could be seen as a smooth approximation of the RELU activation function, yielding

$$ \lambda^{(\ell)} = \text{Softplus}(a^{(\ell)}) = \log(1 + \exp(a^{(\ell)})) \quad (9) $$

where $a^{(\ell)}$ represents a learnable parameter for the unrolled architecture.

Regarding temperature scaling $T^{(\ell)}$, we observed in our experiments that imposing the non-negativity constraint alone might be a source of instability, resulting in values very close to zero and vanishing gradient issues during the training of the unrolled architecture. To circumvent this problem, we impose a lower bound equal to 1 on the temperature scaling:

$$ T^{(\ell)} = 1 + \text{Softplus}(b^{(\ell)}) = 1 + \log(1 + \exp(b^{(\ell)})) \quad (10) $$

where $b^{(\ell)}$ denotes a parameter that needs to be learned during the training of the unrolled model.

**Overall architecture and training approach:** Based on the previous considerations, the overall architecture of UNEM can be summarized as the composition of the L layers $\mathcal{L}^{(L-1)} \circ \dots \circ \mathcal{L}^{(0)}$. This architecture, depicted in Figure 3, illustrates: (i) the required inputs $\theta_k^{(0)}$ and $u_n^{(0)}$ as well as the feature vectors $z_n$ (which are fed in all layers), (ii) the cascaded layers with their associated vector of parameters $w = (\lambda^{(\ell)}, T^{(\ell)})_{0 \le \ell \le L-1}$ satisfying the aforementioned constraints, and (iii) the key output $u_n^{(L)}$ representing the class assignment vectors.

The resulting neural network architecture is trained by minimizing a standard cross-entropy loss on a validation

set:

$$ L_c(w) = \sum_{n \in \mathbb{Q}} \sum_{k=1}^{K} y_{n,k} \log(u_{n,k}^{(L)}). \quad (11) $$

# 4. Experiments

The effectiveness of the proposed approach is validated in both vision-only and vision-language transductive few-shot learning settings. We will designate our proposed unrolled methods by UNEM-Gaussian and UNEM-Dirichlet, respectively. After describing the experimental settings, this section is structured into two main sections discussing our experiments in both evaluation scenarios.

## 4.1. Experimental settings

**Task generation:** We adopt a realistic transductive few-shot evaluation protocol, which is in line with state-of-the-art protocols [29, 32, 33, 45, 50]. While K designates the total number of classes in the labeled support set $\mathcal{S}$, $K_{\text{eff}}$ (with $K_{\text{eff}} \ll K$) denotes the number of effective classes present in the unlabeled query set $\mathcal{Q}$. The classes in the query set remain undisclosed during inference, while randomly selecting $|\mathcal{Q}|$ samples. On the other hand, the support set is built by uniformly selecting $s$ images from each of the K classes. In this paper, the few-shot tasks are performed with (i) 5, 10, and 20 shots for vision-only models, and (ii) 4 shots for vision-language models. Moreover, in both of our evaluation scenarios, we used $K_{\text{eff}} = 5$ and $|\mathcal{Q}| = 75$.

**Training specifications:** For fair comparison and reproducibility purposes, the CLIP's pre-trained model has been directly used in the vision-language evaluation scenario, while for the vision-only scenario, the standard pre-trained ResNet-18 and WRN28-10 backbones have been fine-tuned. Their training is performed on the base classes set of each vision-only dataset, using cross-entropy loss with label smoothing set to 0.9 for 90 epochs. The learning rate is set to 0.1 and then decayed by a factor of 10.

On the other hand, the training of our unrolled architecture, composed of 10 layers (i.e., $L = 10$), is performed on several tasks sampled from the validation set of each dataset.
<table><caption>Table 1. Comparison of the proposed UNEM-Gaussian with respect to state-of-the-art methods on mini-Imagenet and tiered-Imagenet. The metric is accuracy (in percentage). Results are averaged across 1,000 tasks. Results marked with '-' were intractable to obtain.</caption><thead><tr><th rowspan="2">Method</th><th rowspan="2">Backbone</th><th colspan="3">mini-ImageNet (K = 20)</th><th colspan="3">tiered-ImageNet (K = 160)</th></tr><tr><th>5-shot</th><th>10-shot</th><th>20-shot</th><th>5-shot</th><th>10-shot</th><th>20-shot</th></tr></thead><tbody><tr><td>Baseline [8]</td><td></td><td>55.4</td><td>62.1</td><td>67.9</td><td>29.7</td><td>36.3</td><td>42.2</td></tr><tr><td>LR+ICI [52]</td><td></td><td>55.4</td><td>62.1</td><td>68.1</td><td>-</td><td>-</td><td>-</td></tr><tr><td>BD-CSPN [28]</td><td></td><td>49.8</td><td>54.6</td><td>56.5</td><td>11.4</td><td>11.0</td><td>11.7</td></tr><tr><td>PT-MAP [17]</td><td></td><td>25.7</td><td>27.2</td><td>28.4</td><td>5.2</td><td>6.0</td><td>6.6</td></tr><tr><td>LaplacianShot [60]</td><td>ResNet-18</td><td>57.9</td><td>64.2</td><td>68.3</td><td>29.6</td><td>35.4</td><td>39.1</td></tr><tr><td>TIM [4]</td><td></td><td><strong>66.8</strong></td><td>69.9</td><td>70.8</td><td>29.3</td><td>28.7</td><td>27.8</td></tr><tr><td>α-TIM [50]</td><td></td><td>66.7</td><td>71.0</td><td>73.9</td><td>43.8</td><td>48.3</td><td>51.9</td></tr><tr><td>α-AM [24]</td><td></td><td>64.4</td><td>67.8</td><td>70.1</td><td>-</td><td>-</td><td>-</td></tr><tr><td>PADDLE [32]</td><td></td><td>62.9</td><td>73.5</td><td>79.8</td><td>45.4</td><td>61.4</td><td>70.6</td></tr><tr><td><strong>UNEM-Gaussian</strong></td><td></td><td><strong>66.4</strong></td><td><strong>75.6</strong></td><td><strong>80.4</strong></td><td><strong>52.3</strong></td><td><strong>65.7</strong></td><td><strong>73.2</strong></td></tr><tr><td>Baseline [8]</td><td></td><td>59.0</td><td>65.7</td><td>72.1</td><td>31.9</td><td>39.0</td><td>45.6</td></tr><tr><td>LR+ICI [52]</td><td></td><td>58.8</td><td>65.7</td><td>72.0</td><td>-</td><td>-</td><td>-</td></tr><tr><td>BD-CSPN [28]</td><td></td><td>51.1</td><td>55.5</td><td>58.4</td><td>18.0</td><td>18.4</td><td>18.2</td></tr><tr><td>PT-MAP [17]</td><td></td><td>26.5</td><td>28.0</td><td>29.3</td><td>5.2</td><td>6.0</td><td>6.6</td></tr><tr><td>LaplacianShot [60]</td><td>WRN28-10</td><td>61.0</td><td>66.8</td><td>71.0</td><td>31.4</td><td>37.3</td><td>41.5</td></tr><tr><td>TIM [4]</td><td></td><td><strong>72.1</strong></td><td>74.9</td><td>76.2</td><td>36.1</td><td>39.0</td><td>38.5</td></tr><tr><td>α-TIM [50]</td><td></td><td>71.5</td><td>75.2</td><td>78.3</td><td>45.8</td><td>51.4</td><td>55.2</td></tr><tr><td>α-AM [24]</td><td></td><td>68.2</td><td>71.3</td><td>73.3</td><td>-</td><td>-</td><td>-</td></tr><tr><td>PADDLE [32]</td><td></td><td>62.6</td><td>73.0</td><td>79.2</td><td>43.9</td><td>59.4</td><td>69.9</td></tr><tr><td><strong>UNEM-Gaussian</strong></td><td></td><td><strong>71.6</strong></td><td><strong>79.2</strong></td><td><strong>83.7</strong></td><td><strong>54.1</strong></td><td><strong>66.8</strong></td><td><strong>74.7</strong></td></tr></tbody></table>

<table><caption>Table 2. Comparison of the proposed UNEM-Gaussian with respect to state-of-the-art methods on CUB. The metric is accuracy (in percentage). Results are averaged across 1,000 tasks.</caption><thead><tr><th rowspan="2">Method</th><th colspan="3">CUB (K = 50)</th></tr><tr><th>5-shot</th><th>10-shot</th><th>20-shot</th></tr></thead><tbody><tr><td>Baseline [8]</td><td>58.6</td><td>68.8</td><td>78.2</td></tr><tr><td>LR+ICI [52]</td><td>49.9</td><td>55.6</td><td>58.0</td></tr><tr><td>PT-MAP [17]</td><td>12.8</td><td>14.0</td><td>14.9</td></tr><tr><td>LaplacianShot [60]</td><td>58.8</td><td>66.5</td><td>71.0</td></tr><tr><td>TIM [4]</td><td>68.1</td><td>68.9</td><td>69.3</td></tr><tr><td>α-TIM [50]</td><td>74.3</td><td>79.3</td><td>83.6</td></tr><tr><td>α-AM [24]</td><td>66.2</td><td>68.9</td><td>69.8</td></tr><tr><td>PADDLE [32]</td><td>71.2</td><td>81.8</td><td>86.8</td></tr></tbody><tfoot><tr><td><strong>UNEM-Gaussian</strong></td><td><strong>78.5</strong></td><td><strong>85.3</strong></td><td><strong>88.6</strong></td></tr></tfoot></table>

This implies that the proposed solution is highly economical in terms of parameters, typically requiring only a few tenths, compared to standard neural network architectures. Let us recall that the validation set is often used to select the hyperparameters in recent state-of-the-art transductive methods as mentioned in Section 2. Specifically, for the vision-only (resp. vision-language) models, the training of the unrolled architecture is carried out on 1,000 (resp. 100) tasks, while using an initial learning rate of 0.1 (resp. 0.5) with a decay factor of 0.5, a number of epochs equals to 80, and ADAM as optimizer. The trainable hyper-parameters are initialized to the default values set in [32] (i.e., $\lambda = |Q|$ for the vision-only models) and [33] (i.e., $\lambda = \frac{K}{K_{eff}}$ for the vision-language models, with $T = 1$). Our architecture is

implemented in Pytorch (version 2.3.0) and run on NVIDIA QUADRO RTX8000 (with 48 GB of memory).

## 4.2. UNEM-Gaussian in vision-only few-shot setting

Let us recall that the Gaussian distribution is commonly used in standard clustering and transductive few-shot-methods applied to vision-only models [32, 46, 50]. For this reason, we will focus here on the proposed UNEM-Gaussian approach.

**Datasets:** The first UNEM-Gaussian architecture is evaluated on the following standard few-shot benchmark datasets: mini-ImageNet [51], tiered-ImageNet [41], CUB [14]. Mini-Imagenet has 100 classes split into 64 base classes, 16 validation classes and 20 test classes. The tiered-Imagenet has 608 classes instead, from which we follow a standard split with 351 for base training, 97 for validation and 160 for testing. For CUB, we followed the split proposed by [8] which consists of 100 base classes, 50 validation classes and 50 test classes. For each dataset, the feature vectors $z_n$ are extracted using the fine-tuned backbones, while applying a scaling parameter $T_z$ to the model's output as described in Appendix B. This parameter has also been learned through the unrolling approach.

**Results:** The UNEM-Gaussian architecture has been compared to its original version PADDLE [32] as well as several state-of-the-art methods. Tables 1 and 2 presents the results, averaged over 1,000 tasks with 5, 10, and 20 shots. Several observations can be made. First, the proposed UNEM-Gaussian outperforms the original PADDLE algorithm [32] and the other state-of-the-art methods. The achieved gains
<table><caption>Table 3. Comparison of the proposed UNEM-Dirichlet with respect to the state-of-the-art methods on 11 different datasets. The metric is accuracy (in percentage). Results are averaged across 1,000 tasks.</caption><thead><tr><th></th><th>Method</th><th>Food101</th><th>EuroSAT</th><th>DTD</th><th>OxfordPets</th><th>Flowers102</th><th>Caltech101</th><th>UCF101</th><th>FGVC Aircraft</th><th>Stanford Cars</th><th>SUN397</th><th>ImageNet</th><th>Average</th></tr></thead><tbody><tr><td rowspan="2">Ind.</td><td>Tip-Adapter [56]</td><td>76.7</td><td><strong>72.5</strong></td><td>54.7</td><td>86.4</td><td>83.2</td><td>88.8</td><td>72.1</td><td>23.7</td><td>63.9</td><td>66.7</td><td>62.7</td><td>68.3</td></tr><tr><td>CoOp [57]</td><td>76.3</td><td>63.2</td><td>52.2</td><td>86.2</td><td>81.0</td><td>87.7</td><td>67.0</td><td>22.2</td><td>61.3</td><td>63.4</td><td>59.9</td><td>65.5</td></tr><tr><td rowspan="5">Transd.</td><td>BDSCPN [28]</td><td>74.7</td><td>46.1</td><td>45.2</td><td>81.3</td><td>74.2</td><td>82.0</td><td>59.0</td><td>18.0</td><td>48.1</td><td>54.5</td><td>49.2</td><td>57.5</td></tr><tr><td>Laplacian Shot [60]</td><td>76.6</td><td>53.0</td><td>52.6</td><td>88.4</td><td>85.5</td><td>86.8</td><td>67.0</td><td>22.2</td><td>60.4</td><td>63.8</td><td>56.3</td><td>64.8</td></tr><tr><td>α-TIM [50]</td><td>66.1</td><td>46.1</td><td>45.3</td><td>87.1</td><td>79.1</td><td>83.3</td><td>59.4</td><td>20.4</td><td>53.4</td><td>53.4</td><td>42.7</td><td>57.8</td></tr><tr><td>PADDLE [32]</td><td>71.8</td><td>45.9</td><td>50.0</td><td>84.7</td><td>82.3</td><td>81.9</td><td>63.7</td><td>21.3</td><td>56.1</td><td>60.6</td><td>52.1</td><td>60.9</td></tr><tr><td>EM-Dirichlet [33]</td><td>88.7</td><td>50.8</td><td>62.6</td><td>92.5</td><td>91.3</td><td>90.1</td><td>76.1</td><td>24.9</td><td>73.5</td><td>80.9</td><td>78.4</td><td>73.6</td></tr><tr><td></td><td><strong>UNEM-Dirichlet</strong></td><td><strong>91.4</strong></td><td><strong>53.8</strong></td><td><strong>65.3</strong></td><td><strong>96.0</strong></td><td><strong>95.6</strong></td><td><strong>93.4</strong></td><td><strong>78.5</strong></td><td><strong>30.4</strong></td><td><strong>80.0</strong></td><td><strong>88.5</strong></td><td><strong>83.1</strong></td><td><strong>77.8</strong></td></tr></tbody></table>

are much higher with fewer number of shots and reach 3.5% with *mini*-ImageNet, 6.9% with *tiered*-ImageNet, and 7.3% with CUB, while using ResNet-18 as backbone. Moreover, when WRN28-10 is used as backbone, it can be noticed that the performance of all methods has been improved, except for PADDLE, which shows results similar to those obtained with ResNet-18 pre-training. This can be explained by the fact that the class-balance parameter $\lambda$ was set in [32] to $|Q|$ (i.e. 75), which becomes sub-optimal with WRN28-10 features. Most importantly, by learning efficiently the hyperparameters, our UNEM-Gaussian achieves higher gain with respect to its original version, yielding an accuracy gain reaching up to 10% in 5-shot scenario, when WRN28-10 is used as backbone.

### 4.3. UNEM-Dirichlet for few-shot CLIP

Dirichlet distribution has recently demonstrated good modelling performance in the context of transductive few-shot for vision-language models such as CLIP [33]. Thus, we will focus in this second round of experiments on UNEM-Dirichlet approach.

**Datasets:** The second unrolled architecture, designated by UNEM-Dirichlet, is assessed on 11 benchmark datasets that are commonly used for CLIP scenario: Caltech101 [10], OxfordPets [37], StanfordCars [22], Flowers102 [36], Food101 [3], FGVCAircraft [31], SUN397 [54], DTD [9], EuroSAT [15], UCF101 [47], and ImageNet [42]. These datasets cover diverse classification challenges, from object recognition (Caltech101, Food101) to fine-grained tasks (StanfordCars, FGVCAircraft) and scene understanding (SUN397, EuroSAT). For each dataset, the vision-text feature vectors $z_n$ are extracted using the CLIP's pre-trained model, while applying a temperature parameter $T_z$ as described in Appendix C. This temperature parameter has also been learned through the unrolling approach.

**Results:** The proposed UNEM-Dirichlet has also been compared to its original EM-Dirichlet version [33] as well as different few-shot classification methods. Table 3 depicts the accuracy results evaluated over 1,000 tasks with 4

shots. Thus, it can be noticed that UNEM-Dirichlet outperforms state-of-the-art methods for most datasets. In particular, unrolling the recent EM-Dirichlet algorithm yields further improvement of about 4.2% in average. The achieved gain is more significant (reaching up to 7.5%) with more challenging datasets having a large number of classes like FGVC Aircraft, Stanford Cars, and SUN397. This is due to the inappropriate choice of the hyperparameter $\lambda$ for these datasets. Indeed, the selected $\lambda$ parameter was set to $\frac{K}{K_{\text{eff}}} |Q|$ in EM-Dirichlet approach [33]. Thus, by computing the numerical values of the hyperparameter for each of the aforementioned datasets, it can be deduced from Figure 1 that the difference between the selected value (which is 3,000 for Stanford Cars) and the optimal one (which is around 5,500 for Stanford Cars) is more important and impacts significantly the accuracy performance. This problem is well addressed by resorting to the proposed unrolled model for hyperparameters optimization.

Appendix D includes additional results to illustrate, in both scenarios, the effects of the temperature parameter in this framework, and to show the benefits of learning variable hyperparameters across the architecture layers.

### 5. Conclusion

In this paper, we focus on transductive few-shot methods grounded on a generalized form of the EM algorithm. These methods include a parameter to control class balance. The proposed GEM algorithm, applicable to any mixture of distributions, incorporates also a temperature scaling parameter. The optimization process is then unrolled into a neural network architecture, enabling efficient learning of the introduced hyper-parameters. The results demonstrate the effectiveness of the proposed approach on both vision-only and vision-language models. In future work, it would be valuable to explore the potential of unrolling techniques across a broader range of computer vision tasks, especially with the recent rise of foundational vision-language models.
References

[1] Christina Baek, Yiding Jiang, Aditi Raghunathan, and Zico Kolter. Agreement-on-the-line: Predicting the performance of neural networks under distribution shift. In *Proceedings of the International Conference on Neural Information Processing Systems (NeurIPS)*, pages 19274–19289, 2022. 2

[2] C. Bertocchi, E. Chouzenoux, M.-C. Corbineau, J.-C. Pesquet, and M. Prato. Deep unfolding of a proximal interior point method for image restoration. *Inverse Problems, Special Issue on Variational Methods and Effective Algorithms for Imaging and Vision*, 36(3):1–27, 2020. 5

[3] Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101-mining discriminative components with random forests. In *European Conference on Computer Vision*, pages 446–461, Zurich, Switzerland, 2014. Springer. 8

[4] Malik Boudiaf, Ziko Imtiaz Masud, Jérôme Rony, José Dolz, Pablo Piantanida, and Ismail Ben Ayed. Transductive information maximization for few-shot learning. In *Proceedings of the International Conference on Neural Information Processing Systems (NeurIPS)*, pages 2445–2457, 2020. 2, 7

[5] Y. Boykov, H. N. Isack, C. Olsson, and I. Ben Ayed. Voluntary bias in segmentation and reconstruction: Secrets and solutions. In *IEEE/CVF International Conference on Computer Vision (ICCV)*, 2015. 4

[6] Guangyi Chen, Weiran Yao, Xiangchen Song, Xinyue Li, Yongming Rao, and Kun Zhang. Prompt learning with optimal transport for vision-language models. In *International Conference on Learning Representations (ICLR)*, 2023. 3

[7] Tianlong Chen, Xiaohan Chen, Wuyang Chen, and Zhangyang Wang. Learning to optimize: A primer and a benchmark. *Journal of Machine Learning Research (JMLR)*, 23:1–59, 2022. 5

[8] Wei-Yu Chen, Yen-Cheng Liu, Zsolt Kira, Yu-Chiang Frank Wang, and Jia-Bin Huang. A closer look at few-shot classification. In *International Conference on Learning Representations (ICLR)*, pages 1–19, 2019. 7

[9] M. Cimpoi, S. Maji, I. Kokkinos, S. Mohamed, and A. Vedaldi. Describing textures in the wild. In *IEEE Conference on Computer Vision and Pattern Recognition (CVPR)*, 2014. 8

[10] Li Fei-Fei, Robert Fergus, and Pietro Perona. One-shot learning of object categories. *IEEE Transactions on Pattern Analysis and Machine Intelligence*, 28(4):594–611, 2006. 8

[11] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In *International Conference on Machine Learning*, 2017. 2

[12] Peng Gao, Shijie Geng, Renrui Zhang, Teli Ma, Rongyao Fang, Yongfeng Zhang, Hongsheng Li, and Yu Qiao. CLIP-adapter: Better vision-language models with feature adapters. *International Journal of Computer Vision*, 32:581–595, 2023. 3

[13] Bharath Hariharan and Ross B. Girshick. Low-shot visual recognition by shrinking and hallucinating features. In *IEEE International Conference on Computer Vision (ICCV)*, pages 3018–3027, 2017. 2

[14] Xiangteng He and Yuxin Peng. Fine-grained visual-textual

representation learning. *IEEE Transactions on Circuits and Systems for Video Technology*, 30(2):520–531, 2020. 7

[15] Patrick Helber, Benjamin Bischke, Andreas Dengel, and Damian Borth. EuroSAT: A novel dataset and deep learning benchmark for land use and land cover classification. *IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing*, 12(7):2217–2226, 2019. 8

[16] Shell Xu Hu, Da Li, Jan Stuhmer, Minyoung Kim, and Timothy M Hospedales. Pushing the limits of simple pipelines for few-shot learning: External data and fine-tuning make a difference. In *IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)*, pages 9068–9077, 2022. 2

[17] Yuqing Hu, Vincent Gripon, and Stéphane Pateux. Leveraging the feature distribution in transfer-based few-shot learning. In *International Conference on Artificial Neural Networks*, pages 487–499, 2021. 2, 7

[18] Yunshi Huang, Fereshteh Shakeri, Jose Dolz, Malik Boudiaf, Houda Bahig, and Ismail Ben Ayed. LP++: A surprisingly strong linear probe for few-shot clip. In *IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)*, pages 23773–23782, 2024. 3

[19] Muhammad Abdullah Jamal and Guo-Jun Qi. Task agnostic meta-learning for few-shot learning. In *IEEE conference on Computer Vision and Pattern Recognition (CVPR)*, pages 11719–11727, 2019. 2

[20] Leonid Karlinsky, Joseph Shtok, Sivan Harary, Eli Schwartz, Amit Aides, and Rogerio Feris. Repmet: Representative-based metric learning for classification and few-shot object detection. In *IEEE conference on Computer Vision and Pattern Recognition (CVPR)*, pages 5197–5206, 2019. 2

[21] M. Kearns, Y. Mansour, and A. Ng. An information-theoretic analysis of hard and soft assignment methods for clustering. In *Conference on Uncertainty in Artificial Intelligence (UAI)*, 1997. 4

[22] Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In *Proceedings of the IEEE international conference on computer vision workshops*, pages 554–561, 2013. 8

[23] Michalis Lazarou, Tania Stathaki, and Yannis Avrithis. Iterative label cleaning for transductive and semi-supervised few-shot learning. In *IEEE/CVF International Conference on Computer Vision*, pages 8751–8760, 2021. 2

[24] Michalis Lazarou, Yannis Avrithis, and Tania Stathaki. Adaptive manifold for imbalanced transductive few-shot learning. In *IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)*, page 2297–2306, 2024. 2, 3, 7

[25] Gao Yu Lee, Tanmoy Dam, Daniel Puiu Poenar, Vu N. Duong, and Md Meftahul Ferdaus. HELA-VFA: A hellinger distance-attention-based feature aggregation network for few-shot classification. In *IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)*, pages 2173–2183, 2024. 2

[26] Xiaoxu Li, Xiaochen Yang, Zhanyu Ma, and Jing-Hao Xue. Deep metric learning for few-shot image classification: A review of recent developments. *Pattern Recognition*, 138: 109381, 2023. 2
[27] Moshe Lichtenstein, Prasanna Sattigeri, Rogerio Feris, Raja Giryes, and Leonid Karlinsky. TAFSSL: Task-adaptive feature sub-space learning for few-shot classification. In *European Conference on Computer Vision (ECCV)*, pages 22–539, 2020. 2

[28] Jinlu Liu, Liang Song, and Yongqiang Qin. Prototype rec- tification for few-shot learning. In *European Conference on Computer Vision (ECCV)*, pages 741–756, 2020. 2, 7, 8

[29] Yanbin Liu, Juho Lee, Minseop Park, Saehoon Kim, Eunho Yang, Sung Ju Hwang, and Yi Yang. Learning to propa- gate labels: Transductive propagation network for few-shot learning. In *International Conference on Learning Repre- sentations*, page 34677–34688, 2019. 2, 6

[30] Xu Luo, Hao Wu, Ji Zhang, Lianli Gao, Jing Xu, and Jingkuan Song. A closer look at few-shot classification again. In *International Conference on Machine Learning (ICML)*, pages 23103–23123, 2023. 2

[31] Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. Technical report, Oxford University, 2013. 8

[32] Ségolène Martin, Malik Boudiaf, Emilie Chouzenoux, Jean-Christophe Pesquet, and Ismail Ben Ayed. Towards practical few-shot query sets: Transductive minimum description length inference. In *Proceedings of the International Conference on Neural Information Processing Systems (NeurIPS)*, page 34677–34688, 2022. 2, 3, 4, 6, 7, 8, 5

[33] Ségolène Martin, Yunshi Huang, Fereshteh Shakeri, Jean-Christophe Pesquet, and Ismail Ben Ayed. Transductive zero-shot and few-shot clip. In *IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)*, pages 28816–28826, 2024. 1, 2, 3, 4, 5, 6, 7, 8

[34] Paul Micaelli and Amos J Storkey. Gradient-based hyper- parameter optimization over long horizons. In *Advances in Neural Information Processing Systems*, pages 10798–10809. Curran Associates, Inc., 2021. 3

[35] Vishal Monga, Yuelong Li, and Yonina C. Eldar. Algorithm unrolling: Interpretable, efficient deep learning for signal and image processing. *IEEE Signal Processing Magazine*, 38(2):18–44, 2021. 5

[36] Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In *2008 Sixth Indian Conference on Computer Vision, Graphics & Image Processing*, pages 722–729. IEEE, 2008. 8

[37] Omkar M. Parkhi, Andrea Vedaldi, Andrew Zisserman, and C. V. Jawahar. Cats and dogs. In *IEEE Conference on Computer Vision and Pattern Recognition (CVPR)*, 2012. 8

[38] Hang Qi, Matthew Brown, and David G Lowe. Low-shot learning with imprinted weights. In *IEEE conference on Computer Vision and Pattern Recognition (CVPR)*, pages 5822–5830, 2018. 2

[39] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, and et al. Jack Clark. Learning transferable visual models from natural language supervision. In *International Conference on Machine Learning (ICML)*, pages 8748–8763, 2021. 3

[40] Sachin Ravi and H. Larochelle. Optimization as a model for few-shot learning. In *International Conference on Learning Representations*, pages 1–11, 2017. 2

[41] Mengye Ren, Eleni Triantafillou, Sachin Ravi, Jake Snell, Kevin Swersky, Joshua B. Tenenbaum, Hugo Larochelle, and Richard S. Zemel. Meta-learning for semi-supervised few-shot classification. In *International Conference on Learning Representations (ICLR)*, pages 1–15, 2018. 7

[42] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, San-jeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. Imagenet large scale visual recognition challenge. *Int. J. Comput. Vision*, 115(3):211–252, 2015. 8

[43] Tyler Scott, Karl Ridgeway, and Michael C. Mozer. Adapted deep embeddings: A synthesis of methods for k-shot in-ductive transfer learning. In *Proceedings of the International Conference on Neural Information Processing Systems (NeurIPS)*, pages 76–85, 2018. 2

[44] Anuj Singh and Hadi Jamali-Rad. Transductive decoupled variational inference for few-shot classification. *Transactions on Machine Learning Research (TMLR)*, 2023. 2

[45] Jake Snell, Kevin Swersky, and Richard S. Zemel. Prototyp- ical networks for few-shot learning. In *Proceedings of the International Conference on Neural Information Processing Systems (NeurIPS)*, pages 4080–4090, 2017. 6

[46] Yu Song and Changsheng Chen. MPPCAnet: A feedforward learning strategy for few-shot image classification. *Pattern Recognition*, 113:107792, 2021. 4, 7

[47] Khurram Soomro, Amir Roshan Zamir, and Mubarak Shah. UCF101: A dataset of 101 human actions classes from videos in the wild. Technical report, Center for Research in Computer Vision, University of Central Florida, 2012. arXiv:1212.0402. 8

[48] Ran Tao, Hao Chen, and Marios Savvides. Boosting trans- ductive few-shot fine-tuning with margin-based uncertainty weighting and probability regularization. In *IEEE conference on Computer Vision and Pattern Recognition (CVPR)*, pages 15752–15761, 2023. 2, 3

[49] Long Tian, Jingyi Feng, Xiaoqiang Chai, Wenchao Chen, Liming Wang, Xiyang Liu, and Bo Chen. Prototypes- oriented transductive few-shot learning with conditional transport. In *International Conference on Computer Vision (ICCV)*, pages 16317–16326, 2023. 2

[50] Olivier Veilleux, Malik Boudiaf, Pablo Piantanida, and Is- mail Ben Ayed. Realistic evaluation of transductive few-shot learning. In *Proceedings of the International Conference on Neural Information Processing Systems (NeurIPS)*, pages 9290–9302, 2021. 2, 3, 4, 6, 7, 8

[51] Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Ko- ray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In *Proceedings of the International Conference on Neural Information Processing Systems (NeurIPS)*, pages 3637–3645, 2016. 2, 7

[52] Yikai Wang, Chengming Xu, Chen Liu, Li Zhang, and Yan- wei Fu. Instance credibility inference for few-shot learning. In *2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)*, pages 12833–12842, 2020. 7
[53] Yimu Wang, Yihan Wu, and Hongyang Zhang. Lost domain generalization is a natural consequence of lack of training domains. In *Proceedings of the AAAI Conference on Artificial Intelligence*, pages 15689–15697, 2024. 2

[54] Jianxiong Xiao, James Hays, Krista A Ehinger, Aude Oliva, and Antonio Torralba. Sun database: Large-scale scene recognition from abbey to zoo. In *2010 IEEE Computer Society Conference on Computer Vision and Pattern Recognition*, pages 3485–3492, 2010. 8

[55] Hantao Yao, Rui Zhang, and Changsheng Xu. Visual-language prompt tuning with knowledge-guided context optimization. In *IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)*, pages 6757–6767, 2023. 3

[56] Renrui Zhang, Wei Zhang, Rongyao Fang, Peng Gao, Kun-chang Li, Jifeng Dai, Yu Qiao, and Hongsheng Li. TIP-adapter: Training-free adaption of clip for few-shot classification. In *European Conference on Computer Vision (ECCV)*, pages 493–510, 2022. 3, 8

[57] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Zwei Liu. Conditional prompt learning for vision-language models. In *IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)*, pages 16816–16825, 2022. 3, 8

[58] Beier Zhu, Yulei Niu, Yucheng Han, Yue Wu, and Hanwang Zhang. Prompt-aligned gradient for prompt tuning. In *International Conference on Computer Vision (ICCV)*, pages 15659–15669, 2023. 3

[59] Hao Zhu and Piotr Koniusz. Transductive few-shot learning with prototype-based label propagation by iterative graph refinement. In *IEEE Conference on Computer Vision and Pattern Recognition (CVPR)*, pages 23996–24006, 2023. 2

[60] Imtiaz Masud Ziko, Jose Dolz, Eric Granger, and Ismail Ben Ayed. Laplacian regularized few-shot learning. In *International Conference on Machine Learning (ICML)*, 2020. 7, 8
# UNEM: UNrolled Generalized EM for Transductive Few-Shot Learning

## Supplementary Material

### A. Details on the minimization steps of the GEM optimization algorithm

The optimization algorithm alternates between a minimization step w.r.t. the distribution parameters and one w.r.t. the assignment variables. In the following, $\ell$ designates the current iteration.

#### ● Minimization step w.r.t. the distribution parameter

For every $k \in \{1, \dots, K\}$, the first estimation step w.r.t. $\theta_k$, with $u_n = (u_{n,k}^{(\ell)})_{1 \le k \le K}$ given, is performed by considering the following optimization problem:

$$ \underset{\boldsymbol{\theta}_k}{\text{minimize}} \quad -\sum_{n=1}^{N} u_{n,k}^{(\ell)} \ln p(\boldsymbol{z}_n | \boldsymbol{\theta}_k), \quad (12) $$

For a pdf belonging to the exponential family, this optimization problem is a convex. For instance, in the case of a Gaussian distribution whose pdf is defined in (5), the negative log-likelihood term, designated by function $F$, reduces to

$$ F(\boldsymbol{\theta}_k) = \frac{1}{2} \sum_{n=1}^{N} u_{n,k}^{(\ell)} \|\boldsymbol{z}_n - \boldsymbol{\theta}_k\|^2. \quad (13) $$

The minimization of the above function (13) w.r.t $\theta_k$ results in an explicit form of the estimated distribution parameter $\theta_k^{(\ell+1)}$ given by

$$ \boldsymbol{\theta}_k^{(\ell+1)} = \frac{\sum_{n=1}^{N} u_{n,k}^{(\ell)} \boldsymbol{z}_n}{\sum_{n=1}^{N} u_{n,k}^{(\ell)}}. \quad (14) $$

In turn, in the case of Dirichlet distribution whose pdf is defined in (6), the negative log-likelihood term reads

$$ F(\boldsymbol{\theta}_k) = \sum_{n=1}^{N} u_{n,k}^{(\ell)} \left( -\sum_{i=1}^{K} (\theta_{k,i} - 1) \ln z_{n,i} + \sum_{i=1}^{K} \ln \Gamma(\theta_{k,i}) - \ln \Gamma \left( \sum_{i=1}^{K} \theta_{k,i} \right) \right). \quad (15) $$

Unlike the Gaussian model, the minimization of Dirichlet negative log-likelihood (15) has no closed form solution. To circumvent this problem, we resort to the Majorization-Minorization (MM) strategy recently developed in [33]. Thus, the estimated distribution parameter $\theta_k^{(\ell+1)}$ can be expressed as follows

$$ \boldsymbol{\theta}_k^{(\ell+1)} = \text{MM}(\boldsymbol{u}_{\cdot,k}^{(\ell)}, \boldsymbol{\theta}_k^{(\ell)}). \quad (16) $$

#### ● Minimization step w.r.t. the assignment variable

For every $n \in \mathbb{Q}$, the second estimation step w.r.t. $u_n$ is achieved by minimizing the objective function (1), while keeping the distribution parameter set to the estimated vector $\boldsymbol{\theta}_k^{(\ell+1)}$. However, since the partition complexity term $\Psi$ is non convex, it is replaced by a linear tangent upper bound. More specifically, the following tangent inequality can be used:

$$ \pi_k \ln \pi_k \ge \pi_k^{(\ell+1)} \ln \pi_k^{(\ell+1)} + (1 + \ln \pi_k^{(\ell+1)})(\pi_k - \pi_k^{(\ell+1)}) \quad (17) $$

Knowing that $\pi_k = \frac{1}{|\mathbb{Q}|} \sum_{n \in \mathbb{Q}} u_{n,k}$, the optimization problem (1) can be rewritten as follows

$$ \underset{\boldsymbol{u}_n}{\text{minimize}} \quad G(\boldsymbol{u}_n) \quad (18) $$

with

$$ G(\boldsymbol{u}_n) = -\sum_{k=1}^{K} u_{n,k} \ln p \left( \boldsymbol{z}_n \mid \boldsymbol{\theta}_k^{(\ell+1)} \right) \\ - \lambda \sum_{k=1}^{K} \frac{(1 + \ln \pi_k^{(\ell+1)})}{|\mathbb{Q}|} (u_{n,k} - u_{n,k}^{(\ell)}) \\ + T \sum_{k=1}^{K} u_{n,k} \ln u_{n,k} + \gamma_n \left( \sum_{k=1}^{K} u_{n,k} - 1 \right) \quad (19) $$

where $\gamma_n$ is a Lagrange multiplier aiming to enforce the sum-to-one constraint. The nonnegativity constraint can be dropped since we will show next that it is satisfied by the minimizer of $G$ subject to the sum-to-one constraint.

The above optimization problem is convex. By cancelling the derivative of the above objective function (19) w.r.t. $u_{n,k}$, it can be checked that

$$ \ln u_{n,k} = -1 - \frac{\gamma_n}{T} + \frac{1}{T} \left( \ln p \left( \boldsymbol{z}_n \mid \boldsymbol{\theta}_k^{(\ell+1)} \right) + \frac{\lambda}{|\mathbb{Q}|} (1 + \ln \pi_k^{(\ell+1)}) \right). \quad (20) $$

By applying the exponential function to (20) and determining the multiplier $\gamma_n$ so that the sum-to-one constraint is satisfied, it can be deduced that the optimal class assignment vector $\boldsymbol{u}_n^{(\ell+1)}$ is obtained by applying the softmax function:
$$ \mathbf{u}_n^{(\ell+1)} = \mathrm{softmax} \left( \frac{1}{T} \left( \ln p \left( z_n \mid \boldsymbol{\theta}_k^{(\ell+1)} \right) + \frac{\lambda}{|\mathbb{Q}|} \ln(\pi_k^{(\ell+1)}) \right)_k \right). \quad (21) $$

## B. Generalized EM algorithm in the case of Gaussian distribution

### B.1. Feature representation in vision-only few-shot-setting

Let us consider a few-shot scenario for vision-only models. Thus, for all dataset samples $x_n$ with $n \in \{1, \dots, N\}$, the feature vectors $z_n$ are generated using a visual feature extractor $f^{(v)}$ as follows

$$ z_n = T_z f^{(v)}(x_n) \quad (22) $$

where $T_z$ is a positive scaling parameter.

### B.2. Optimization algorithm

Using (13), (14), and (21), the proposed GEM algorithm reduces to Algorithm 2 in the case of a Gaussian distribution model.

### Algorithm 2 GEM-Gaussian based few-shot classification algorithm

**Input:** Compute $z_n$ for the dataset samples and, for all $k \in \{1, \dots, K\}$, initialize $\theta_k^{(0)}$ as the means computed on the support set, and $\pi_k^{(0)} = 1$
**for** $\ell = 0, 1, \dots, L-1$ **do**

// Update assignment vectors for all query samples
$\mathbf{u}_n^{(\ell+1)} = \mathrm{softmax} \left( \frac{1}{T} \left( -\frac{1}{2} \|z_n - \boldsymbol{\theta}_k^{(\ell)}\|^2 + \frac{\lambda}{|\mathbb{Q}|} \ln(\pi_k^{(\ell)}) \right)_k \right)$

// Update the mean parameter for each class

// Update class proportions

$$ \boldsymbol{\theta}_k^{(\ell+1)} = \frac{\sum_{n=1}^{N} u_{n,k}^{(\ell+1)} z_n}{\sum_{n=1}^{N} u_{n,k}^{(\ell+1)}}, \quad \forall k \in \{1, \dots, K\}, $$

// Update class proportions

$$ \pi_k^{(\ell+1)} = \frac{1}{|\mathbb{Q}|} \sum_{n \in \mathbb{Q}} u_{n,k}^{(\ell+1)}, \quad \forall k \in \{1, \dots, K\}, $$

end for

## C. Generalized EM algorithm in the case of Dirichlet distribution

### C.1. Feature representation in few-shot CLIP

Our second few-shot scenario is devoted to vision-language models such as CLIP. Let us assume $f^{(v)}$ a vision-based feature extractor, and $f^{(l)}$ a language-based feature extractor. Thus, for a sample $x_n$ with $n \in \{1, \dots, N\}$ and a text

prompt $t_k$ of class $k \in \{1, \dots, K\}$ (for example $t_k = “a$ photo of a {class k}”), the visual and text features are given by $f^{(v)}(x_n)$ and $f^{(l)}(t_k)$, respectively. Then, the resulting feature embeddings of the data sample $x_n$ is defined as its probability vector of belonging to class k:

$$ z_n = \mathrm{softmax} \left\{ T_z \cos \left( f^{(v)}(x_n), f^{(l)}(t_k) \right) \right\}_{1 \le k \le K}, \quad (23) $$

where $T_z > 0$ is a temperature scaling parameter.

## C.2. Optimization algorithm

Using (16) and (21), and in the case of a Dirichlet data distribution model, the proposed GEM algorithm yields Algorithm 3.

### Algorithm 3 GEM-Dirichlet based few-shot classification algorithm

**Input:** Compute $z_n$ for the dataset samples, initialize $\mathbf{u}_n^{(0)} = z_n$, and $\boldsymbol{\theta}_k^{(0)} = \mathbf{1}_K$
**for** $\ell = 0, 1, \dots, L-1$ **do**

// Update the Dirichlet parameter for each class

$$ \boldsymbol{\theta}_k^{(\ell+1)} = \mathrm{MM}(\mathbf{u}_{\cdot,k}^{(\ell)}, \boldsymbol{\theta}_k^{(\ell)}), \quad \forall k \in \{1, \dots, K\}, $$

// Update class proportions

$$ \pi_k^{(\ell+1)} = \frac{1}{|\mathbb{Q}|} \sum_{n \in \mathbb{Q}} u_{n,k}^{(\ell)}, \quad \forall k \in \{1, \dots, K\}, $$

// Update assignment vectors for all query samples

$$ \mathcal{L}_{n,k}^{(\ell)} = \sum_{i=1}^{K} (\theta_{k,i}^{(\ell+1)} - 1) \ln z_{n,i} - \sum_{i=1}^{K} \ln \Gamma(\theta_{k,i}^{(\ell+1)}) + \ln \Gamma \left( \sum_{i=1}^{K} \theta_{k,i}^{(\ell+1)} \right) $$

$$ \mathbf{u}_n^{(\ell+1)} = \mathrm{softmax} \left( \frac{1}{T} \left( \mathcal{L}_{n,k}^{(\ell)} + \frac{\lambda}{|\mathbb{Q}|} \ln(\pi_k^{(\ell+1)}) \right)_k \right) $$

end for

## D. Additional results

### D.1. Ablation studies

In this part, we perform ablation studies to illustrate the impact of the network depth, the effects of the introduced temperature scaling parameter and the benefits of learning adaptive hyper-parameters across the unrolled architecture layers.

#### Impact of the unrolled architecture depth

First, we propose to analyze the impact of the number $L$ of layers of our unrolled architecture on the model accuracy, model size, and computational time. Table 4 reports the results. Thus, one of the main advantages of our UNEM model is that a few layers (about 7 or 10) are enough to achieve good performance. In what follows, the
experiments are conducted using $L = 10$.

<table><caption>Table 4. Impact of the number of layers (L) on UNEM-Gaussian performance using *mini-ImageNet*, 5-shot and ResNet18.</caption><thead><tr><th>#Layers (L)</th><th>#Params</th><th>Acc.</th><th>Train Time (s)</th><th>Inference Time/task (s)</th></tr></thead><tbody><tr><td>3</td><td>7</td><td>65.6</td><td>2.80</td><td>3.04 × 10<sup>-2</sup></td></tr><tr><td>5</td><td>11</td><td>65.9</td><td>3.22</td><td>3.09 × 10<sup>-2</sup></td></tr><tr><td>7</td><td>15</td><td>66.3</td><td>3.46</td><td>3.21 × 10<sup>-2</sup></td></tr><tr><td>10</td><td>21</td><td>66.4</td><td>3.61</td><td>3.36 × 10<sup>-2</sup></td></tr><tr><td>12</td><td>25</td><td>66.2</td><td>4.06</td><td>3.45 × 10<sup>-2</sup></td></tr><tr><td>15</td><td>31</td><td>66.1</td><td>4.29</td><td>3.48 × 10<sup>-2</sup></td></tr><tr><td>18</td><td>37</td><td>66.2</td><td>5.74</td><td>3.68 × 10<sup>-2</sup></td></tr></tbody></table>

## Effects of temperature scaling

To perform this study, we compare our unrolled architectures (UNEM-Gaussian as well as UNEM-Dirichlet) in both cases: (i) without introducing the temperature scaling parameter (as considered in the original algorithms PADDLE [32] and EM-Dirichlet [33]); (ii) while incorporating the temperature scaling (as proposed in our GEM algorithm).

Tables 5 and 6 depict the accuracy results in vision-only few-shot setting. Thus, it can be noticed that including the temperature scaling yields an accuracy improvement, which may vary from 1% to 3%. Moreover, in the context of vision-language models whose accuracy results are shown in Table 7, similar gains (reaching up to 3%), depending on the target downstream dataset, are also achieved. This confirms again the advantage of incorporating the temperature scaling in our generalized algorithm.

## Fixed vs adaptive hyper-parameters across layers

One of the key advantages of unrolling algorithms is their flexibility in optimizing hyper-parameters, while allowing them to vary across the architecture layers. To show the potential of such hyper-parameter optimization approach, we propose to compare the proposed unrolled architectures (UNEM-Gaussian and UNEM-Dirichlet) in the following two cases: (i) the hyper-parameters are set fixed across the layers (as it is generally considered in original iterative algorithms), (ii) a set of hyper-parameters, adapted to the different layers, is learned.

Tables 8 and 9 provide the accuracy results for fixed and adaptive hyper-parameters optimization with vision-only models. It can be seen that learning adaptive hyper-parameters yields an accuracy gain of about 2-4% compared to the case when the hyper-parameters are kept fixed across layers. Similar comparisons are also performed with vision-language models as shown in Table 10. In this context, the improvement achieved by learning adaptive hyper-parameters often ranges from 1 to 2%.

## D.2. Performance under distribution shifts

In Table 11, we include the accuracy of the original PADDLE algorithm [32] and its unrolled version, with *tiered-ImageNet* used for pre-training, and a fine-grained classification dataset (CUB) as well as *mini-ImageNet* used for inference. One could observe similar improvements (about 4-7%) brought by UNEM.

## D.3. Backbone effect in CLIP

The performance of EM-Dirichlet and UNEM-Dirichlet using ViT-B/32 as backbone are shown in Table 12. Thus, in comparison to CLIP with ResNet50 (see Table 3), one may observe a similar or slightly better accuracy performance with most datasets. Moreover, the gains brought by UNEM over the iterative variant are consistent with those observed with ResNet50 backbone.

## E. Illustration and analysis of the learned hyperparameters

In this part, we propose to illustrate the variations of the learned hyper-parameters and analyze their orders-of-magnitude.

### Illustration of the learned hyper-parameters

The evolutions of the learned hyper-parameters $\lambda^{(\ell)}$ and $T^{(\ell)}$ with respect to the layer index are illustrated in Figures 4 and 5 for some downstream image classification tasks. While Figure 4 shows that the learned hyper-parameters with CUB (ResNet18), *mini-ImageNet* (ResNet18), and *mini-ImageNet* (WRN28-10) have similar amplitudes, much different orders-of-magnitude are observed with vision-language models as shown in Figure 5 for some test datasets. Let us recall that the different learned hyper-parameters, for all datasets, are available at https://github.com/ZhouLong0/UNEM-Transductive.

### Analysis of the learned hyper-parameters

Different observations could be made from the previous illustrations. On the one hand, in the case of vision-only models, it can be seen that the learned hyper-parameters $\lambda^{(\ell)}$ appear quite similar. However, the evolution of $T^{(\ell)}$ values shows different behaviors. Moreover, it is important to note that the optimal hyper-parameters also depend on the pre-training model as observed with *mini-ImageNet* (ResNet18) and *mini-ImageNet* (WRN28-10). On the other hand, with vision-language models, it can be observed that both hyper-parameter values $\lambda^{(\ell)}$ and $T^{(\ell)}$ strongly depend on the target dataset. Indeed, unlike the vision-only models where the feature vectors have a fixed size (which is equal to the dimension of the pre-trained model's output), the feature vectors $z_n$ in the context of few-shot CLIP have different sizes, depending on the number of classes of each target
<table><caption>Table 5. Effects of the temperature scaling on the accuracy performance of UNEM-Gaussian approach applied to *mini-ImageNet* and *tiered-ImageNet* datasets.</caption><thead><tr><th rowspan="2">Temperature scaling</th><th rowspan="2">Backbone</th><th colspan="3">mini-ImageNet (K = 20)</th><th colspan="3">tiered-ImageNet (K = 160)</th></tr><tr><th>5-shot</th><th>10-shot</th><th>20-shot</th><th>5-shot</th><th>10-shot</th><th>20-shot</th></tr></thead><tbody><tr><td>×</td><td rowspan="2">ResNet-18</td><td>66.1</td><td>75.4</td><td>80.3</td><td>49.7</td><td>63.2</td><td>70.0</td></tr><tr><td>✓</td><td><strong>66.4</strong></td><td><strong>75.6</strong></td><td><strong>80.4</strong></td><td><strong>52.3</strong></td><td><strong>65.7</strong></td><td><strong>73.2</strong></td></tr><tr><td>×</td><td rowspan="2">WRN28-10</td><td><strong>71.9</strong></td><td>78.9</td><td>82.8</td><td>52.0</td><td>65.8</td><td>73.0</td></tr><tr><td>✓</td><td>71.6</td><td><strong>79.2</strong></td><td><strong>83.7</strong></td><td><strong>54.1</strong></td><td><strong>66.8</strong></td><td><strong>74.7</strong></td></tr></tbody></table>

<table><caption>Table 6. Effects of the temperature scaling on the accuracy performance of UNEM-Gaussian approach applied to CUB dataset.</caption><thead><tr><th rowspan="2">Temperature scaling</th><th colspan="3">CUB (K = 50)</th></tr><tr><th>5-shot</th><th>10-shot</th><th>20-shot</th></tr></thead><tbody><tr><td>×</td><td>78.1</td><td>85.2</td><td>88.6</td></tr><tr><td>✓</td><td><strong>78.5</strong></td><td><strong>85.3</strong></td><td><strong>88.6</strong></td></tr></tbody></table>

<table><caption>Table 7. Effects of the temperature scaling on the accuracy performance of UNEM-Dirichlet approach applied to the vision-language models.</caption><thead><tr><th rowspan="2">Temperature scaling</th><th>Food101</th><th>EuroSAT</th><th>DTD</th><th>OxfordPets</th><th>Flowers102</th><th>Caltech101</th><th>UCF101</th><th>FGVC Aircraft</th><th>Stanford Cars</th><th>SUN397</th></tr></thead><tbody><tr><td>×</td><td>90.6</td><td>51.9</td><td><strong>65.4</strong></td><td>95.4</td><td>92.0</td><td>92.4</td><td><strong>79.1</strong></td><td>27.5</td><td>78.2</td><td>88.4</td></tr><tr><td>✓</td><td><strong>91.4</strong></td><td><strong>53.8</strong></td><td>65.3</td><td><strong>96.0</strong></td><td><strong>95.6</strong></td><td><strong>93.4</strong></td><td>78.5</td><td><strong>30.4</strong></td><td><strong>80.0</strong></td><td><strong>88.5</strong></td></tr></tbody></table>

<table><caption>Table 8. Fixed vs adaptive hyper-parameters setting in the UNEM-Gaussian approach, using *mini-ImageNet* and *tiered-ImageNet* datasets.</caption><thead><tr><th rowspan="2">Params across the layers</th><th rowspan="2">Backbone</th><th colspan="3">mini-ImageNet (K = 20)</th><th colspan="3">tiered-ImageNet (K = 160)</th></tr><tr><th>5-shot</th><th>10-shot</th><th>20-shot</th><th>5-shot</th><th>10-shot</th><th>20-shot</th></tr></thead><tbody><tr><td>Fixed</td><td rowspan="2">ResNet-18</td><td>62.5</td><td>72.5</td><td>78.0</td><td>49.8</td><td>63.6</td><td>70.4</td></tr><tr><td>Adaptive</td><td><strong>66.4</strong></td><td><strong>75.6</strong></td><td><strong>80.4</strong></td><td><strong>52.3</strong></td><td><strong>65.7</strong></td><td><strong>73.2</strong></td></tr><tr><td>Fixed</td><td rowspan="2">WRN28-10</td><td>68.7</td><td>77.0</td><td>82.0</td><td>51.6</td><td>64.6</td><td>72.1</td></tr><tr><td>Adaptive</td><td><strong>71.6</strong></td><td><strong>79.2</strong></td><td><strong>83.7</strong></td><td><strong>54.1</strong></td><td><strong>66.8</strong></td><td><strong>74.7</strong></td></tr></tbody></table>

<table><caption>Table 9. Fixed vs adaptive hyper-parameters setting in the UNEM-Gaussian approach, using CUB dataset.</caption><thead><tr><th rowspan="2">Params across layers</th><th colspan="3">CUB (K = 50)</th></tr><tr><th>5-shot</th><th>10-shot</th><th>20-shot</th></tr></thead><tbody><tr><td>Fixed</td><td>75.2</td><td>82.9</td><td>87.1</td></tr><tr><td>Adaptive</td><td><strong>78.5</strong></td><td><strong>85.3</strong></td><td><strong>88.6</strong></td></tr></tbody></table>

dataset. For instance, knowing that EuroSAT, Flowers102 and Stanford Cars have 10, 102, and 196 classes, respectively; it can be observed that the smallest (resp. largest) values of $\lambda^{(l)}$ are obtained with EuroSAT (resp. Stanford Cars). These results are expected since, by increasing the dimension of $z_n$, the magnitude of the log-likelihood term may increase, and so, a higher value of $\lambda^{(l)}$ is needed to mitigate the class-balance bias.

This study shows the dependence of the introduced hyper-parameters on the target downstream dataset as well as the pre-training model, and confirms the importance of optimizing hyper-parameters in both evaluation scenarios.
<table><caption>Table 10. Fixed vs adaptive hyper-parameters setting in the UNEM-Dirichlet approach, using the vision-language models.</caption><thead><tr><th>Params across layers</th><th>Food101</th><th>EuroSAT</th><th>DTD</th><th>OxfordPets</th><th>Flowers102</th><th>Caltech101</th><th>UCF101</th><th>FGVC Aircraft</th><th>Stanford Cars</th><th>SUN397</th></tr></thead><tbody><tr><th>Fixed</th><td>89.6</td><td>52.2</td><td>64.8</td><td>95.3</td><td>95.3</td><td>92.3</td><td><strong>79.2</strong></td><td><strong>31.6</strong></td><td>78.0</td><td>87.6</td></tr><tr><th>Adaptive</th><td><strong>91.4</strong></td><td><strong>53.8</strong></td><td><strong>65.3</strong></td><td><strong>96.0</strong></td><td><strong>95.6</strong></td><td><strong>93.4</strong></td><td>78.5</td><td>30.4</td><td><strong>80.0</strong></td><td><strong>88.5</strong></td></tr></tbody></table>

<table><caption>Table 11. Cross-domain evaluation: Accuracy performance on mini-ImageNet and CUB using a model trained on tiered-ImageNet, with a 5-shot setting and a ResNet18 backbone.</caption><thead><tr><th>Method</th><th>CUB</th><th>mini-ImageNet</th></tr></thead><tbody><tr><td>PADDLE [32]</td><td>66.0</td><td>82.9</td></tr><tr><td>UNEM-Gaussian</td><td>72.9</td><td>87.0</td></tr></tbody></table>

<table><caption>Table 12. Accuracy performance of iterative EM-Dirichlet [33] and our UNEM variant using CLIP ViT-B/32 for feature extraction.</caption><thead><tr><th>Method</th><th>Food101</th><th>EuroSAT</th><th>DTD</th><th>OxfordPets</th><th>Flowers102</th><th>Caltech101</th><th>UCF101</th><th>FGVC Aircraft</th><th>Stanford Cars</th><th>SUN397</th></tr></thead><tbody><tr><th>EM-Dirichlet [33]</th><td>89.3</td><td>54.8</td><td>63.9</td><td>92.5</td><td>92.7</td><td>92.8</td><td>77.2</td><td>27.3</td><td>73.9</td><td>81.7</td></tr><tr><th>UNEM-Dirichlet</th><td><strong>91.4</strong></td><td><strong>57.5</strong></td><td><strong>67.4</strong></td><td><strong>95.7</strong></td><td><strong>95.2</strong></td><td><strong>94.0</strong></td><td><strong>80.4</strong></td><td><strong>33.8</strong></td><td><strong>77.8</strong></td><td><strong>88.4</strong></td></tr></tbody></table>

<figure><img src="image_5.png" /><figcaption>Figure 4. Illustration of the learned hyper-parameters $\lambda^{(\ell)}$ and $T^{(\ell)}$ across layers for CUB (with ResNet18 model), mini-ImageNet (with ResNet18 model) and mini-ImageNet (with WRN28-10 model).</figcaption></figure>
<figure><img src="image_6.png" /><figcaption>Figure 5. Illustration of the learned hyper-parameters $\lambda^{(\ell)}$ and $T^{(\ell)}$ across layers for some datasets with vision-language models.</figcaption></figure>