$\#(\theta_g)\ll\#(\theta_{rgb})$.

Distance design. {#sec:distanceDesign}
----------------

Once different modules are set we can compute the facial embedding of test images following the procedure described in Algorithm \[alg:facial\_embedding\]. Let us define $x^a\in{\mathcal{X}}_n$ and $x^b\in{\mathcal{X}}_n$ the feature embedding of two facial images $I_a$ and $I_b$ respectively. Recall that the first $n/2$ elements of $x$ are associated to features extracted from (a recovered) RGB facial image while the remaining elements are associated to depth information, i.e., $x = (x_{rgb}[1],..., x_{rgb}[n/2], x_{\nabla z}[1], ..., x_{\nabla z}[n/2])^T$. We define the distance between two feature representations $x^a = (x_{rgb}^a, x_{\nabla z}^a)$, and $x^b = (x_{rgb}^b, x_{\nabla z}^b)$ as $$\label{eq:distance}
\begin{array}{l}
    \displaystyle d_{\alpha,\beta,\gamma}(x^a,x^b) \stackrel{def}{=}  (1-\gamma)\, d_c(x^a_{rgb},\,x^b_{rgb}) \vspace{2mm} \\
     \ \ +\ \gamma\, d_c(x^a_{\nabla z},\,x^b_{\nabla z}) \left(1 + \left(\frac{d_c(x^a_{\nabla z},\,x^b_{\nabla z})}{\beta}\right)^\alpha \right).
\end{array}$$ $d_c:{\mathcal{X}}_{n/2}\times{\mathcal{X}}_{n/2}\rightarrow[0, 1]$ denotes the cosine distance, $\gamma\in[0,1]$ sets the relative weight of RGB and depth features, and $\alpha,\beta \in {\mathbb{R}}$ define a non-linear response for the distance between depth features. As we will describe in the following, this provides robustness against common cases of spoofing attacks. Intuitively, $\gamma$ allows us to set the relative confidence associated to RGB and depth features, for example, $\gamma=1/2$ gives the same weight to RGB and depth features, while $\gamma=0$ ($\gamma=1$) 