# Appendix A: Self-organising maps

A SOM (Kohonen 1982) is an unsupervised machine-learning algorithm trained to produce a low-dimensional (typically two-dimensional) representation of a multi-dimensional space. A two-dimensional SOM contains $N_x \times N_y$ cells with an associated vector of attributes ($w^k$), where $N_x(N_y)$ is the dimension of the SOM on the $x(y)$-axis, and $k$ corresponds to the $k$th SOM cell. Each of these vectors has the same length as the input data.

The SOM training phase is an iterative process during which the SOM cells compete amongst themselves to represent the training data. Initially, the cell vectors ($w^k$) are randomly sampled from a uniform distribution, and these are updated after each iteration step ($t$). In every training iteration, each galaxy vector of measured attributes $x$ (e.g. in our case the galaxy colours), is compared to all the SOM cells' vectors via a $\chi^2$ expression,

$$ \chi^2(w^k(t), x) = \sum_i \left[ \frac{x_i - w_i^k(t)}{\sigma_i} \right]^2, \qquad (A.1) $$

where $i$ sums over galaxy attributes and $\sigma_i$ is the uncertainty associated with $x_i$. The evaluated galaxy is assigned to the cell with the lowest $\chi^2$, which updates its associated vector of attributes $w^k(t)$ according to the matched galaxy features

Furthermore, in the SOM training procedure, the vector of features from cells neighbouring the best matching cell are also updated, clustering together galaxies with similar attributes. This is implemented with a neighbouring function $H(t, d)$, which depends on the distance ($d$) between the best matching cell and the updated one. The neighbouring function is commonly implemented as a Gaussian kernel with an iteration-dependent variance $\sigma^2_{\text{kernel}}(t)$. Therefore, the vector of attributes for a particular cell $k$ after iteration $t+1$ is

$$ w^k(t+1) = w^k(t) + \alpha(t) H(t, |w - x|) (x - w^k(t)), \qquad (A.2) $$

where $\alpha(t)$ is the learning rate.

After a few iterations over the training sample, the result is a map of ($N_x \times N_y$) vectors in a two-dimensional space grouping together cells with similar features while preserving the topology of the multi-dimensional space.

# Appendix B: Redshift distributions, N(z), and scatter plots

Unbiased redshift distributions, $N(z)$, are crucial for a variety of science applications, with the most stringent requirements being in weak lensing (e.g. Hildebrandt et al. 2012; Hoyle et al. 2018). broadband photo-zs commonly suffer from biases due to degeneracies between colours and redshift, (e.g. Newman et al. 2015; Masters et al. 2017).

Figure B.1 shows $N(z)$ in tomographic redshift bins for $0 < z_t < 1.5$ spaced by 0.2. The last tomographic bin is defined from $1.2 < z_t < 1.5$ so that the number of galaxies in the bin is increased. The ground-truth redshift defining the tomographic bins ($z_t$) is a combination of the spectroscopic redshift (when it is available) and the PAUS+COSMOS photo-z elsewhere. The vertical solid grey line indicates the ground-truth median redshift of the tomographic bin, while the dashed coloured lines represent the median redshifts of the predicted photo-zs assigned to the bins.

Multi-task learning with photo-z data augmentation ($z_s + z_{PAUS} + NB$) always provides equal or more accurate $N(z)$ than

the baseline network ($z_s$, black line). As expected from Fig. 4, the $N(z)$ values exhibiting the largest bias are those with $z_t > 1.2$, particularly the bin at $z_t > 1.2$. In this bin, MTL together with the photo-z data augmentation ($z_s+NB+z_{PAUS}$, green line), significantly shifts the median of the $N(z)$ towards the PAUS+COSMOS result.

Commonly, redshift distributions require a bias correction to reach the accuracy requirements of cosmological measurements. Techniques such as clustering redshifts are applied to correct such biases (Ménard et al. 2013; Schmidt et al. 2013; Gatti et al. 2018; van den Busch et al. 2020; Hildebrandt et al. 2021). MTL reduces the bias of the $N(z)$ already at the photo-z prediction stage. Even if the MTL photo-zs still require some correction, the final redshift distributions would benefit from initially having less biased redshift distributions (if these redshift distributions are used to fit the clustering-z data points).

Figure B.2 shows the density scatter between the predicted photo-zs and the true redshift. Here, we are plotting the complete COSMOS sample, and we therefore use a combination of spectroscopic redshift and PAUS+COSMOS photo-zs as true redshift. The top left panel corresponds to baseline network ($z_s$ method) and clearly shows higher photo-z scatter and more outliers in the high-redshift region with respect to the other methods. The MTL method (top right, $z_s+NB$) already reduces photo-z scatter and number of high-redshift outliers. The methods including additional PAUS+COSMOS photo-zs in the training sample (bottom panels) further improve the photo-z performance.
<figure><img src="image_15.png" /><figcaption>**Fig. B.1.** *N(z)* estimates of the full COSMOS sample divided into seven tomographic bins over the redshift range 0 < *z* < 1.5. Tomographic bins are defined using the spectroscopic redshifts and the PAUS+COSMOS high-precision photo-zs for galaxies without spectroscopy. The vertical solid black lines indicate the median ground-truth redshift, while the other vertical lines indicate the median redshifts of the *N(z)* estimates. Unseen lines are hidden by other overlapping lines.</figcaption></figure>
<figure><img src="image_16.png" /><figcaption>**Fig. B.1.** *N(z)* estimates of the full COSMOS sample divided into seven tomographic bins over the redshift range 0 < *z* < 1.5. Tomographic bins are defined using the spectroscopic redshifts and the PAUS+COSMOS high-precision photo-zs for galaxies without spectroscopy. The vertical solid black lines indicate the median ground-truth redshift, while the other vertical lines indicate the median redshifts of the *N(z)* estimates. Unseen lines are hidden by other overlapping lines.</figcaption></figure>
<figure><img src="image_16.png" /><figcaption>**Fig. B.2.** Scatter plot of the 1:1 relation between the predicted photo-z and the true redshift, which is a combination of spectroscopic redshift and PAUS+COSMOS photo-zs, in the complete COSMOS sample for the four methods in Sect. 3.</figcaption></figure>

**Appendix C: Effect of training with photo-zs as ground-truth targets**

In this work we have implemented and tested two training methodologies that rely on narrow-band photo-z estimates as ground-truth targets (see methods $z_s + z_{PAUS}$ and $NB+z_s + z_{PAUS}$ in Sect. 3.2). Even if such photo-zs are overall very accurate, its implementation in the training could harm the photo-z performance since these are less precise than spectroscopic redshifts and could potentially include outliers. In this section we explore the effect that less precise redshift labels (Sect. C.1) and the presence of outliers (Sect. C.2) have on the photo-z performance.

**Appendix C.1: Effect of the dispersion in the ground-truth photo-z**

Figure C.1 shows the photo-z precision of a set of 1000 spectroscopic galaxies for four independent broadband networks (simply mapping colours to redshift), each of them trained with different ground-truth redshifts. The redshifts used for training are the spectroscopic redshifts (see Sect. 2.4), the PAUS+COSMOS photo-zs (see Sect. 2.2), the COSMOS30 photo-zs (Laigle et al. 2016), which combine 30 photometric filters and estimates the photo-z with LePhare (Arnouts & Ilbert 2011), and a set of CFHT photo-zs from Hildebrandt et al. (2012) combining six broad bands (ugriz) with photo-z estimated with BPZ (Benítez

2011). The input data are, in all cases, the CFHT *u* band and the BVriz Subaru broadband filters from COSMOS2015.

The red points in Fig. C.1 show the redshift dispersion using a training sample of galaxies with spectroscopic redshift. We always keep the same training sample (which contains around 6000 galaxies) and change the labelled true redshifts in each independent training (spectroscopic catalogue, PAUS data, COSMOS30, and the CFHT catalogue). Using spectroscopic redshifts as ground-truth redshifts results in a dispersion of $\sigma_{68} = 0.016$. Replacing the spectroscopic redshift with the photo-z from PAUS+COSMOS, COSMOS30, or CFHT yields $\sigma_{68} = 0.017$, $\sigma_{68} = 0.018$, and $\sigma_{68} = 0.046$, respectively. As the ground-truth redshifts become less precise, the machine-learning photo-z performance degrades.

To obtain the green points (Fig. C.1), we extended the training sample to all galaxies in the COSMOS sample with a photo-z estimate, which results in approximately 15 000 galaxies when the four catalogues are merged. Then, three independent networks are trained using the PAUS+COSMOS, the COSMOS-30, and the CFHT photo-zs as true redshifts (the spectroscopic redshift is not used even if it is available). This provides a precision of $\sigma_{68} = 0.016$, $\sigma_{68} = 0.017$, and $\sigma_{68} = 0.045$ for the PAUS+COSMOS, the COSMOS30, and the CFHT photo-zs, respectively. The three networks improve the photo-z precision with respect to training with spectroscopic redshifts only. Indeed, with the PAUS+COSMOS photo-z labels we already reach the photo-z precision with spectroscopic labels.
<figure><img src="image_17.png" /><figcaption>**Fig. B.2.** Scatter plot of the 1:1 relation between the predicted photo-z and the true redshift, which is a combination of spectroscopic redshift and PAUS+COSMOS photo-zs, in the complete COSMOS sample for the four methods in Sect. 3.</figcaption></figure>

**Appendix C: Effect of training with photo-zs as ground-truth targets**

In this work we have implemented and tested two training methodologies that rely on narrow-band photo-z estimates as ground-truth targets (see methods $z_s + z_{PAUS}$ and $NB + z_s + z_{PAUS}$ in Sect. 3.2). Even if such photo-zs are overall very accurate, its implementation in the training could harm the photo-z performance since these are less precise than spectroscopic redshifts and could potentially include outliers. In this section we explore the effect that less precise redshift labels (Sect. C.1) and the presence of outliers (Sect. C.2) have on the photo-z performance.

**Appendix C.1: Effect of the dispersion in the ground-truth photo-z**

Figure C.1 shows the photo-z precision of a set of 1000 spectroscopic galaxies for four independent broadband networks (simply mapping colours to redshift), each of them trained with different ground-truth redshifts. The redshifts used for training are the spectroscopic redshifts (see Sect. 2.4), the PAUS+COSMOS photo-zs (see Sect. 2.2), the COSMOS30 photo-zs (Laigle et al. 2016), which combine 30 photometric filters and estimates the photo-z with LePhare (Arnouts & Ilbert 2011), and a set of CFHT photo-zs from Hildebrandt et al. (2012) combining six broad bands (ugriz) with photo-z estimated with BPZ (Benítez

2011). The input data are, in all cases, the CFHT *u* band and the BVriz Subaru broadband filters from COSMOS2015.

The red points in Fig. C.1 show the redshift dispersion using a training sample of galaxies with spectroscopic redshift. We always keep the same training sample (which contains around 6000 galaxies) and change the labelled true redshifts in each independent training (spectroscopic catalogue, PAUS data, COSMOS30, and the CFHT catalogue). Using spectroscopic redshifts as ground-truth redshifts results in a dispersion of $\sigma_{68} = 0.016$. Replacing the spectroscopic redshift with the photo-z from PAUS+COSMOS, COSMOS30, or CFHT yields $\sigma_{68} = 0.017$, $\sigma_{68} = 0.018$, and $\sigma_{68} = 0.046$, respectively. As the ground-truth redshifts become less precise, the machine-learning photo-z performance degrades.

To obtain the green points (Fig. C.1), we extended the training sample to all galaxies in the COSMOS sample with a photo-z estimate, which results in approximately 15 000 galaxies when the four catalogues are merged. Then, three independent networks are trained using the PAUS+COSMOS, the COSMOS-30, and the CFHT photo-zs as true redshifts (the spectroscopic redshift is not used even if it is available). This provides a precision of $\sigma_{68} = 0.016$, $\sigma_{68} = 0.017$, and $\sigma_{68} = 0.045$ for the PAUS+COSMOS, the COSMOS30, and the CFHT photo-zs, respectively. The three networks improve the photo-z precision with respect to training with spectroscopic redshifts only. Indeed, with the PAUS+COSMOS photo-z labels we already reach the photo-z precision with spectroscopic labels.
<figure><img src="image_17.png" /><figcaption>Fig. C.1. Photo-z performance as a function of the ground-truth redshift precision used for training the networks. The training redshifts are the spectroscopic redshifts, the PAUS+COSMOS photo-zs, COSMOS30, and a set of CFHT photo-zs in COSMOS. Red points correspond to training on the spectroscopic sample (around 6000 galaxies). The green and red points show the training sample extended to COSMOS galaxies with photo-zs (around 15 000 galaxies). The blue lines show the expected photo-z performance as a function of target redshift precision. The true redshifts, the spectroscopic redshift in the COSMOS2015 catalogue (solid blue line), and the simulated redshift in the PAUS mock (blue dashed line) are scattered with precision in 0.001 bins. The top inset zooms into the framed area in the main plot (lower-left corner)</figcaption></figure>

Finally, the blue points in the figure correspond to the networks trained with the same 15 000 photo-z galaxies as in the green points, but combining spectroscopic redshifts (if available) and photo-zs as ground-truth training redshifts. Combining spectroscopic redshifts with PAUS+COSMOS photo-zs yields $\sigma_{68} = 0.015$, which improves upon the precision obtained with spectroscopic redshifts only.

The light blue lines in Fig. C.1 show the expected performance as a function of the ground-truth redshift precision. The solid line uses the COSMOS2015 uBVriz broad bands and the dashed one uses simulated data from the PAUS mock described in Sect. 5. In both cases, true redshifts (spectroscopic or simulated) are scattered with the corresponding dispersion in the abscissa.

Both networks (solid and dashed lines) are trained with 15 000 galaxies to have a direct comparison with the previous results. We always use the scattered redshifts as ground-truth targets, in such a way that the lines should be compared with the green points since these are trained using only photometric redshifts. The results obtained with the PAUS+COSMOS and COSMOS30 match the expectation curves, but there is a significant mismatch with the CFHT photo-zs. This is potentially triggered by systematic errors or outliers in the CFHT photo-z not represented in the blue curves.

## Appendix C.2: Effect of photo-z outliers in the training redshifts

In Fig. C.1 showed a mismatch between the expected (solid blue curve) and photo-z performance training a network with the CFHT photo-zs as ground-truth redshifts (rightmost red point). However, the expectation assumes that the CFHT photo-zs are not affected by other effects such as systematic errors or catastrophic outliers.

Figure C.2 shows the effect of outliers in the ground-truth targets of the training sample. The network is trained 20 independent times with 5000 COSMOS2015 spectroscopic galaxies

including a fraction (monotonically increasing in each iteration) of labelled photo-z outliers. This procedure is repeated for the spectroscopic redshifts (black line), the PAUS+COSMOS photo-zs (red line), the COSMOS30 photo-zs (blue line), and the CFHT photo-zs (green line).

In the left panel, the artificial outlier redshifts are swapped with a random value sampled from a uniform distribution $U(0, 1.5)$ to simulate catastrophic outliers. The predicted photo-z precision degrades as the fraction of target redshift outliers increases. This also affects the predicted $p(z)$, which become noisier and broader (not shown). However, and unexpectedly, the network can provide reasonable photo-z estimates with up to 80% of catastrophic outliers in the training sample. Furthermore, the network is able to make reliable photo-z predictions of galaxies that have been used in the training sample with wrong target redshift values. This result holds when either spectroscopic redshifts or any of the photo-zs are used for training.

The middle panel shows the effect of a systematic multiplicative shift in the training sample redshifts, where the selected targets are shifted to 20% higher redshifts. In this scenario, the predicted photo-z precision degrades faster than when outliers are random (left panel) but the network does never completely break. For an outlier fraction higher than 60%, the precision sets at $\sigma_{68} = 0.03$, but the bias rapidly increases. Finally, the rightmost panel presents the effect of a systematic shifting the redshift ($z_{\text{mod}}$) so that $O_{\text{III}}$ is confused with $H\alpha$ in the training redshifts:

$$z_{\text{mod}} = \lambda_{O_{\text{III}}}/\lambda_{H\alpha} (1 + z_t) - 1, \quad (C.1)$$

where $z_t$ is the galaxy redshift.

The training degrades and breaks much faster than in the two previous cases, where with around 40% of wrong target redshifts the network is not able to provide reliable predictions. As the fraction of affected target redshifts increases, the predicted $p(z)$ become more doubly peaked. Moreover, a plot of photo-z versus spec-z scatter displays two clear lines, one with the correct mapping and another shifted upwards (not shown), which is triggered by the training objects with the photo-z artificially shifted to confuse the emission lines. Again, the effect of outliers is similar regardless of the redshifts used for training (spectroscopic or different-precision photo-z).

Contrary to expectations, the left panel of Fig. C.2 indicates that the network can learn the mapping between the galaxy photometry and redshifts with up to 80% of catastrophic outliers in the training sample. Given that the training sample is composed of 5000 galaxies, this means that the network can effectively learn the colour-redshift relations from 1000 galaxies, learning to ignore the remaining 4000 spurious galaxies.

Figure C.3 shows the cost function evolution of a network trained with wrong target redshifts for half of the training while keeping the rest to the correct redshift values. The cost function is split in two; one for those objects with correct redshift (red) and another for those with wrong redshifts (blue). In the left panel, the modified target redshifts are switched to a random value from a uniform distribution $U(0, 1.5)$, as in the left panel of Fig. C.2. The cost function of galaxies with the correct target redshift decreases, which indicates that the network is learning from them. In contrast, the cost function of incorrectly labelled galaxies remains constant along the training, showing that the network is not learning anything from them. Therefore, the network is effectively only learning from galaxies with correct target redshifts. Randomly swapping redshifts to different values breaks any correlation between the photometry and the redshifts. Hence, the network is only learning the colour-redshift
<figure><img src="image_18.png" /><figcaption>Fig. C.1. Photo-z performance as a function of the ground-truth redshift precision used for training the networks. The training redshifts are the spectroscopic redshifts, the PAUS+COSMOS photo-zs, COSMOS30, and a set of CFHT photo-zs in COSMOS. Red points correspond to training on the spectroscopic sample (around 6000 galaxies). The green and red points show the training sample extended to COSMOS galaxies with photo-zs (around 15 000 galaxies). The blue lines show the expected photo-z performance as a function of target redshift precision. The true redshifts, the spectroscopic redshift in the COSMOS2015 catalogue (solid blue line), and the simulated redshift in the PAUS mock (blue dashed line) are scattered with precision in 0.001 bins. The top inset zooms into the framed area in the main plot (lower-left corner)</figcaption></figure>

Finally, the blue points in the figure correspond to the networks trained with the same 15 000 photo-z galaxies as in the green points, but combining spectroscopic redshifts (if available) and photo-zs as ground-truth training redshifts. Combining spectroscopic redshifts with PAUS+COSMOS photo-zs yields $\sigma_{68} = 0.015$, which improves upon the precision obtained with spectroscopic redshifts only.

The light blue lines in Fig. C.1 show the expected performance as a function of the ground-truth redshift precision. The solid line uses the COSMOS2015 uBVriz broad bands and the dashed one uses simulated data from the PAUS mock described in Sect. 5. In both cases, true redshifts (spectroscopic or simulated) are scattered with the corresponding dispersion in the abscissa.

Both networks (solid and dashed lines) are trained with 15 000 galaxies to have a direct comparison with the previous results. We always use the scattered redshifts as ground-truth targets, in such a way that the lines should be compared with the green points since these are trained using only photometric redshifts. The results obtained with the PAUS+COSMOS and COSMOS30 match the expectation curves, but there is a significant mismatch with the CFHT photo-zs. This is potentially triggered by systematic errors or outliers in the CFHT photo-z not represented in the blue curves.

## Appendix C.2: Effect of photo-z outliers in the training redshifts

In Fig. C.1 showed a mismatch between the expected (solid blue curve) and photo-z performance training a network with the CFHT photo-zs as ground-truth redshifts (rightmost red point). However, the expectation assumes that the CFHT photo-zs are not affected by other effects such as systematic errors or catastrophic outliers.

Figure C.2 shows the effect of outliers in the ground-truth targets of the training sample. The network is trained 20 independent times with 5000 COSMOS2015 spectroscopic galaxies

including a fraction (monotonically increasing in each iteration) of labelled photo-z outliers. This procedure is repeated for the spectroscopic redshifts (black line), the PAUS+COSMOS photo-zs (red line), the COSMOS30 photo-zs (blue line), and the CFHT photo-zs (green line).

In the left panel, the artificial outlier redshifts are swapped with a random value sampled from a uniform distribution $U(0, 1.5)$ to simulate catastrophic outliers. The predicted photo-z precision degrades as the fraction of target redshift outliers increases. This also affects the predicted $p(z)$, which become noisier and broader (not shown). However, and unexpectedly, the network can provide reasonable photo-z estimates with up to 80% of catastrophic outliers in the training sample. Furthermore, the network is able to make reliable photo-z predictions of galaxies that have been used in the training sample with wrong target redshift values. This result holds when either spectroscopic redshifts or any of the photo-zs are used for training.

The middle panel shows the effect of a systematic multiplicative shift in the training sample redshifts, where the selected targets are shifted to 20% higher redshifts. In this scenario, the predicted photo-z precision degrades faster than when outliers are random (left panel) but the network does never completely break. For an outlier fraction higher than 60%, the precision sets at $\sigma_{68} = 0.03$, but the bias rapidly increases. Finally, the rightmost panel presents the effect of a systematic shifting the redshift ($z_{\text{mod}}$) so that $O_{\text{III}}$ is confused with $H\alpha$ in the training redshifts:

$$z_{\text{mod}} = \lambda_{O_{\text{III}}}/\lambda_{H\alpha} (1 + z_t) - 1, \qquad (C.1)$$

where $z_t$ is the galaxy redshift.

The training degrades and breaks much faster than in the two previous cases, where with around 40% of wrong target redshifts the network is not able to provide reliable predictions. As the fraction of affected target redshifts increases, the predicted $p(z)$ become more doubly peaked. Moreover, a plot of photo-z versus spec-z scatter displays two clear lines, one with the correct mapping and another shifted upwards (not shown), which is triggered by the training objects with the photo-z artificially shifted to confuse the emission lines. Again, the effect of outliers is similar regardless of the redshifts used for training (spectroscopic or different-precision photo-z).

Contrary to expectations, the left panel of Fig. C.2 indicates that the network can learn the mapping between the galaxy photometry and redshifts with up to 80% of catastrophic outliers in the training sample. Given that the training sample is composed of 5000 galaxies, this means that the network can effectively learn the colour-redshift relations from 1000 galaxies, learning to ignore the remaining 4000 spurious galaxies.

Figure C.3 shows the cost function evolution of a network trained with wrong target redshifts for half of the training while keeping the rest to the correct redshift values. The cost function is split in two; one for those objects with correct redshift (red) and another for those with wrong redshifts (blue). In the left panel, the modified target redshifts are switched to a random value from a uniform distribution $U(0, 1.5)$, as in the left panel of Fig. C.2. The cost function of galaxies with the correct target redshift decreases, which indicates that the network is learning from them. In contrast, the cost function of incorrectly labelled galaxies remains constant along the training, showing that the network is not learning anything from them. Therefore, the network is effectively only learning from galaxies with correct target redshifts. Randomly swapping redshifts to different values breaks any correlation between the photometry and the redshifts. Hence, the network is only learning the colour-redshift
<figure><img src="image_18.png" /><figcaption>**Fig. C.2.** Effect of outliers and systematic errors on the ground-truth redshift sample used during training. The training sample consists of 5000 spectroscopic galaxies with photometry from COSMOS2015. Each coloured line uses a different sample of redshifts as true redshifts, i.e. spectroscopic redshifts (black), PAUS+COSMOS photo-zs (red), COSMOS30 photo-zs (blue), and CFHT photo-zs (green). The ground-truth redshift of the selected fraction of training galaxies is replaced by a random redshift value sampled from $U(0, 1.5)$ (left), a 20% higher redshift (centre), and redshifts modified with Eq. (C.1) (right).</figcaption></figure>

<figure><img src="image_19.png" /><figcaption>**Fig. C.3.** Training loss function for galaxies with a wrong (blue) and a corrected (red) target redshift. The training sample consists of 5000 spectroscopic galaxies with photometry from COSMOS2015. In the left panel, the modified target redshifts are randomly switched to a value drawn from $U(0, 1.5)$, while in the right panel the wrong redshift labels are generated with Eq. (C.1).</figcaption></figure>

mapping from galaxies with the correct target redshift. Nevertheless, having a large fraction of wrong labels adds noise to the training, broadening the predicted $p(z)$.

The right panel of Fig. C.3 shows the loss function for the correct and the wrongly labelled training galaxies separately when the incorrect redshift labels are generated with Eq. (C.1). This introduces a new colour-redshift relation that forces the network to learn both from galaxies with wrong and correct target redshifts. This can also be noted in the $p(z)$ behaviour, which presents a double-peaked distribution (not shown). Hence, Figs. C.2 and C.3 indicate that having catastrophic outliers in the training sample labels effectively adds noise to the photo-z predictions. In contrast, a systematic bias in the training sample targets produces a bias in such predictions.

## Appendix D: Robustness of the methods to outliers in the target redshifts

In this appendix we study the robustness of our training methodologies to outliers in the redshifts used as ground-truth to train the network. In Sect. 5, in order to simulate the PAUS+COSMOS photo-zs used to train the $z_S+z_{PAUS}$ and the $z_S+z_{PAUS}+NB$ meth-

ods, we scatter the true redshift from the simulations to a similar precision of PAUS+COSMOS photometric redshifts. This process assumes that photometric redshift errors are purely Gaussian; however, real data also have non-Gaussian errors and photo-z outliers, which can be caused by, for example, noisy photometry, emission-line confusions, and other artefacts in the data.

Systematic outliers in the ground-truth target redshifts have a much stronger impact than random catastrophic outliers (Figs. C.3 and C.2). Therefore, we assume the most adverse scenario where all outliers are systematically shifted according to Eq. (C.1).

Figure D.1 shows the impact that outliers in the target redshifts have in the performance of the methods. We studied four different cases: a sample without outliers in the training sample (black solid line), with a 5% of outliers in the spectroscopic redshifts and 1% of outliers in the photo-zs (red dashed line), 5% of spectroscopic redshift outliers and 5% photo-zs outliers (blue dashed line), and 5% of spectroscopic redshift outliers and 10% photo-zs outliers (green dashed line).

Adding the 5% of spectroscopic redshift outliers already has an impact on the predicted photo-z bias of the baseline method ($z_S$, top left panel). The effect of spectroscopic redshift outliers
<figure><img src="image_19.png" /><figcaption>**Fig. C.2.** Effect of outliers and systematic errors on the ground-truth redshift sample used during training. The training sample consists of 5000 spectroscopic galaxies with photometry from COSMOS2015. Each coloured line uses a different sample of redshifts as true redshifts, i.e. spectroscopic redshifts (black), PAUS+COSMOS photo-zs (red), COSMOS30 photo-zs (blue), and CFHT photo-zs (green). The ground-truth redshift of the selected fraction of training galaxies is replaced by a random redshift value sampled from $U(0, 1.5)$ (left), a 20% higher redshift (centre), and redshifts modified with Eq. (C.1) (right).</figcaption></figure>

<figure><img src="image_20.png" /><figcaption>**Fig. C.3.** Training loss function for galaxies with a wrong (blue) and a corrected (red) target redshift. The training sample consists of 5000 spectroscopic galaxies with photometry from COSMOS2015. In the left panel, the modified target redshifts are randomly switched to a value drawn from $U(0, 1.5)$, while in the right panel the wrong redshift labels are generated with Eq. (C.1).</figcaption></figure>

mapping from galaxies with the correct target redshift. Nevertheless, having a large fraction of wrong labels adds noise to the training, broadening the predicted $p(z)$.

The right panel of Fig. C.3 shows the loss function for the correct and the wrongly labelled training galaxies separately when the incorrect redshift labels are generated with Eq. (C.1). This introduces a new colour-redshift relation that forces the network to learn both from galaxies with wrong and correct target redshifts. This can also be noted in the $p(z)$ behaviour, which presents a double-peaked distribution (not shown). Hence, Figs. C.2 and C.3 indicate that having catastrophic outliers in the training sample labels effectively adds noise to the photo-z predictions. In contrast, a systematic bias in the training sample targets produces a bias in such predictions.

## Appendix D: Robustness of the methods to outliers in the target redshifts

In this appendix we study the robustness of our training methodologies to outliers in the redshifts used as ground-truth to train the network. In Sect. 5, in order to simulate the PAUS+COSMOS photo-zs used to train the $z_S+z_{PAUS}$ and the $z_S+z_{PAUS}+NB$ meth-

ods, we scatter the true redshift from the simulations to a similar precision of PAUS+COSMOS photometric redshifts. This process assumes that photometric redshift errors are purely Gaussian; however, real data also have non-Gaussian errors and photo-z outliers, which can be caused by, for example, noisy photometry, emission-line confusions, and other artefacts in the data.

Systematic outliers in the ground-truth target redshifts have a much stronger impact than random catastrophic outliers (Figs. C.3 and C.2). Therefore, we assume the most adverse scenario where all outliers are systematically shifted according to Eq. (C.1).

Figure D.1 shows the impact that outliers in the target redshifts have in the performance of the methods. We studied four different cases: a sample without outliers in the training sample (black solid line), with a 5% of outliers in the spectroscopic redshifts and 1% of outliers in the photo-zs (red dashed line), 5% of spectroscopic redshift outliers and 5% photo-zs outliers (blue dashed line), and 5% of spectroscopic redshift outliers and 10% photo-zs outliers (green dashed line).

Adding the 5% of spectroscopic redshift outliers already has an impact on the predicted photo-z bias of the baseline method ($z_S$, top left panel). The effect of spectroscopic redshift outliers
<figure><img src="image_20.png" /><figcaption>**Fig. D.1.** Effect on the photo-z predictions of different outlier rates in the target spectroscopic and high-precision photometric redshifts used as ground-truth targets to train the methods in Sect. 3. In all cases, outliers have been included following Eq. (C.1).</figcaption></figure>

in the training sample is mitigated by the MTL network (top right panel), which is not affected by training-photo-z outliers since these are not used during the training (method $z_s$ + NB, Sect. 3.2). We also observe that training with photo-z samples with up to ~5% of outliers also mitigates the effect of outliers in the spectroscopic sample. This is expected since adding more training data reduces the relative importance of an outlier in the training sample. However, the bottom plots also show that training samples with more than 10% of systematic photo-z outliers degrade the photo-z performance.

We also studied the robustness of the dispersion and the outlier rate to the target-redshift outliers and these two metrics are much less affected by the presence of target-redshift outliers.

## Appendix E: Further studies of multi-task training

In this section we aim to give a more technical view of the network functioning. In Fig. E.1 we show the evolution of the photo-z prediction loss function (Eq. 1) with time for the baseline method ($z_s$, black line) and the MTL method ($z_s$+NB, red line). In both cases, the solid line corresponds to the training loss, while the dashed line is the validation loss. The networks have been trained for 100 epochs with an initial learning rate of $10^{-3}$, which decreases to $10^{-4}$ after 50 epochs. In this test, unlike previous tests, we initialise the two networks with the same weights. Still we observe training with the two different losses leads to a lower photo-z loss ($L_z$). We also find adding the narrow-band loss stabilises the photo-z loss in the validation sample, meaning the network better generalise with the additional narrow-band loss.

<figure><img src="image_21.png" /><figcaption>**Fig. E.1.** Training (solid lines) and validation (dashed lines) loss for the $z_s$ (black) and $z_s$+NB (red) methods. All methods are trained for 100 epochs with an initial learning rate of $10^{-3}$ and the same initial conditions.</figcaption></figure>
<figure><img src="image_21.png" /><figcaption>**Fig. D.1.** Effect on the photo-z predictions of different outlier rates in the target spectroscopic and high-precision photometric redshifts used as ground-truth targets to train the methods in Sect. 3. In all cases, outliers have been included following Eq. (C.1).</figcaption></figure>

in the training sample is mitigated by the MTL network (top right panel), which is not affected by training-photo-z outliers since these are not used during the training (method $z_s$ + NB, Sect. 3.2). We also observe that training with photo-z samples with up to ~5% of outliers also mitigates the effect of outliers in the spectroscopic sample. This is expected since adding more training data reduces the relative importance of an outlier in the training sample. However, the bottom plots also show that training samples with more than 10% of systematic photo-z outliers degrade the photo-z performance.

We also studied the robustness of the dispersion and the outlier rate to the target-redshift outliers and these two metrics are much less affected by the presence of target-redshift outliers.

## Appendix E: Further studies of multi-task training

In this section we aim to give a more technical view of the network functioning. In Fig. E.1 we show the evolution of the photo-z prediction loss function (Eq. 1) with time for the baseline method ($z_s$, black line) and the MTL method ($z_s$+NB, red line). In both cases, the solid line corresponds to the training loss, while the dashed line is the validation loss. The networks have been trained for 100 epochs with an initial learning rate of $10^{-3}$, which decreases to $10^{-4}$ after 50 epochs. In this test, unlike previous tests, we initialise the two networks with the same weights. Still we observe training with the two different losses leads to a lower photo-z loss ($L_z$). We also find adding the narrow-band loss stabilises the photo-z loss in the validation sample, meaning the network better generalise with the additional narrow-band loss.

<figure><img src="image_22.png" /><figcaption>**Fig. E.1.** Training (solid lines) and validation (dashed lines) loss for the $z_s$ (black) and $z_s$+NB (red) methods. All methods are trained for 100 epochs with an initial learning rate of $10^{-3}$ and the same initial conditions.</figcaption></figure>