# The Three Hundred Project: Mapping The Matter Distribution in Galaxy
Clusters Via Deep Learning from Multiview Mock Observations

Daniel de Andres1,2, Weiguang Cui3,1,2, Gustavo Yepes1,2, Marco De Petris4,
Antonio Ferragamo4,5, Federico De Luca4, Gianmarco Aversano6, Douglas
Rennehan7.

1 Departamento de Física Teórica, M-8, Universidad Autónoma de Madrid,
Cantoblanco 28049, Madrid, Spain
2 Centro de Investigación Avanzada en Física Fundamental,(CIAFF), Universidad
Autónoma de Madrid, Cantoblanco, 28049 Madrid, Spain
3 Institute for Astronomy, University of Edinburgh, Royal Observatory,
Edinburgh EH9 3HJ, UK
4 Dipartimento di Fisica, Sapienza Universitá di Roma, Piazzale Aldo Moro,
5-00185 Roma, Italy
5 Instituto de Astrofísica de Canarias (IAC) La Laguna, 38205, Spain
6 EURANOVA, Mont-Saint-Guibert, Belgium
7 Center for Computational Astrophysics, Flatiron Institute, 162 Fifth Avenue,
New York, NY, 10010, USA<EMAIL_ADDRESS>
(Accepted XXX. Received YYY; in original form ZZZ)

###### Abstract

A galaxy cluster as the most massive gravitationally-bound object in the
Universe, is dominated by Dark Matter, which unfortunately can only be
investigated through its interaction with the luminous baryons with some
simplified assumptions that introduce an un-preferred bias. In this work, we,
for the first time, propose a deep learning method based on the U-Net
architecture, to directly infer the projected total mass density map from mock
observations of simulated galaxy clusters at multi-wavelengths. The model is
trained with a large dataset of idealised mock images from simulated clusters
of The Three Hundred Project. Through different metrics to assess the fidelity
of the inferred density map, we show that the predicted total mass
distribution is in very good agreement with the true simulated cluster.
Therefore, it is not surprising to see the integrated halo mass is almost
unbiased, around 1 per cent for the best result from multiview, and the
scatter is also very small, basically within 3 per cent. This result suggests
that this ML method provides an alternative and easier way to reconstruct the
overall matter distribution in galaxy clusters than the traditional lensing
method.

###### keywords:

cosmology: theory – cosmology:dark matter – cosmology:large-scale structure of
Universe – methods: numerical – galaxies: clusters: general – galaxies: halos

††pubyear: 2015††pagerange: The Three Hundred Project: Mapping The Matter
Distribution in Galaxy Clusters Via Deep Learning from Multiview Mock
Observations–A

##  1 Introduction

Estimating the matter content in galaxy clusters (see Kravtsov & Borgani,
2012, for a review) is crucial for cosmological studies due to the fact that
they are the biggest gravitationally bound objects originating from small
density fluctuations in the early universe. Thus cosmological parameters can
be constrained by studying the abundance of galaxy clusters as a function of
the mass and redshift (e.g. Allen et al., 2011; Planck Collaboration et al.,
2016b; Pratt et al., 2019; Salvati et al., 2022). Galaxy clusters are mainly
composed of Dark Matter (DM), which is about 80% of their total mass, diffused
hot gas (about 12%), i.e., intra-cluster medium (ICM), and stars, mainly in
galaxies (the remaining $8\%$).

While optical surveys explore galaxy members, the ICM is targeted through
X-ray emission and the inverse-Compton scattering of the cosmic microwave
background (CMB) photons, i.e. the Sunyaev-Zel’dovich (SZ) effect (Sunyaev &
Zeldovich, 1972). The SZ effect can be observed at millimetre wavelengths and
different instruments have managed to detect more than a thousand clusters
through it, such as the Planck satellite (PSZ2; Planck Collaboration et al.,
2016c), the Atacama Cosmology Telescope (ACT; Hilton et al., 2018) and the
South Pole Telescope (SPT; Bleem et al., 2020). Nevertheless, Planck is the
only all-sky survey for SZ clusters. On the contrary, clusters X-ray
observations are more recently explored by eROSITA (Liu et al., 2022) and
targeted XMM-Newton observations, such as the CHEX-MATE project (CHEX-MATE
Collaboration et al., 2021).

Although the total mass of a cluster of galaxies is not observable, it can be
inferred by observing its baryonic components. It can be estimated from the
dynamics (e.g. Biviano et al., 2006) or the abundance/richness (e.g. Rozo et
al., 2009) of the member galaxies, or from the ICM radial profiles in X-ray
and SZ observations with the assumption of the diffused gas is distributed
following the hydrostatic equilibrium (HE) hypothesis (e.g. Gianfagna et al.,
2021, 2023). Alternatively, their physical quantities, which are integrated
inside a fixed aperture in the sky, strictly related to the mass of the object
can be selected under the self-similarity assumption (Bryan & Norman, 1998) as
suitable observational proxies. However, these estimated masses rely upon
theoretical assumptions, such as HE, and are therefore possibly affected by
bias. Nevertheless, only weak gravitational lensing (WL) is sensitive to all
matter along the line of sight and measures the total projected matter (Becker
& Kravtsov, 2011; Herbonnet et al., 2022). However, gravitational lensing
observations are not numerous, with tens of images, in comparison to the
hundreds or few thousands of observations of galaxy clusters available for SZ,
X-ray and stars. In addition, weak lensing measurements suffer from
systematics, such as halo shape, redshift accuracy and background galaxy
selection. (see Pratt et al., 2019; Herbonnet et al., 2022; Euclid
Collaboration et al., 2023, for example), as such, the WL mass is very
uncertain.

Machine Learning (ML) has been applied in astronomy since quite a long ago
(e.g Odewahn et al., 1992), but only in past years we have witnessed an
unprecedented increase of Deep Learning (DL) methods (for a review, see e.g.
Huertas-Company & Lanusse, 2023; Smith & Geach, 2023), which implies a change
in the paradigm from applying specific algorithms to fully data-driven
science. In our interests, recent studies have shown that galaxy cluster
masses can be estimated using deep learning methods from catalogues of
simulated galaxy clusters (Ntampaka et al., 2019; Ho et al., 2019; Gupta &
Reichardt, 2020; Kodi Ramanah et al., 2020; Yan et al., 2020; Gupta &
Reichardt, 2021; Ho et al., 2021; de Andres et al., 2022; Ferragamo et al.,
2023; Ho et al., 2023), which outperform these classical methods. Fortunately,
only recently these methods have also been applied to infer the mass of galaxy
clusters of real surveys at different wavelengths, Kodi Ramanah et al. (2021)
applied deep learning to infer galaxy clusters masses from the SDSS Legacy
Survey (Strauss et al., 2002), de Andres et al. (2022) estimated the masses of
the full-sky Planck satellite PSZ2 catalogue and Krippendorf et al. (2023)
followed a machine learning approach to infer galaxy cluster masses from
eROSITA X-ray images. Notwithstanding, all these previous works focus on
inferring the masses inside a sphere of a certain radius (i.e.
$R_{200}$111$R_{200}$ stands for the radius of the sphere at which the density
is 200 times the critical density of the Universe at the corresponding
redshift or $R_{500}$). Recently, Ferragamo et al. (2023) pushed these ML
applications even further by showing that ML can predict the full mass radial
profile using SZ mock images and thus, being able to obtain valuable
information on internal properties of galaxy clusters as the concentration. As
a general remark, all these studies suggest that the estimated masses are not
affected by observational biases and assumptions due to the fact that they do
not rely on hypotheses about the dynamics or the hydrostatic equilibrium with
spherical symmetry of the ICM, but rather on the quality of dataset provided
by cosmological simulations.

In this work, for the first time, we explore Deep Learning models to infer the
projected matter density fields from mock baryonic observations. To this end,
we utilise the The Three Hundred (The300; Cui et al., 2018): a set of “zoom-
in” hydrodynamical and cosmological simulations to generate the input mock
observations: SZ, X-ray and star maps, and the output maps, mass maps. The
dataset created for this purpose corresponds to a set of idealised
observations free from the observational impacts typical of real instruments,
such as noise and point sources. Therefore, this work represents the needed
theoretical proof-of-concept study where the limitations of deep learning are
tested. For further details regarding our dataset, we refer the reader to
section 2.

The manuscript is organised as follows: in section 2 the creation of the
dataset is discussed, The Three Hundred set of hydrodynamical simulations and
the particular selection of halo-sized objects that are optimal for training
ML models and the characteristics of our input maps, Compton-$y$ parameters
maps (SZ), X-ray surface brightness (X-ray) and star density maps, and output
mass density maps. In section 3 we discuss the Deep learning model and
architectures considered for this project as well as how the models are
trained. In section 4, the results of the model applied to the test set are
shown. To this end, we design a set of test metrics to assess the fidelity of
the predicted mass density maps: pixel-wise statistics, cylindrical radial
profiles, power spectra and Maximum Mean Discrepancy. Finally, in section 5
the main conclusions of the work are drawn.

##  2 Dataset

###  2.1 The Three Hundred Simulations

In order to create the dataset used for training our DL model, we use
The300222https://the300-project.org simulations (Cui et al., 2018). The300
simulation project focuses on a set of 324 “zoom-in” hydrodynamical
simulations centred on the most massive halos of the MultiDark simulation
(MDPL2; Klypin et al., 2016) utilising the cosmological parameters inferred by
Planck (Planck Collaboration et al., 2016a). The full MDPL2 simulation
contains $3840^{3}$ particles whose mass is $1.5\times
10^{9}{{\;h^{-1}{\rm{M_{\odot}}}}}$. Moreover, each cluster region covers
15$h^{-1}$Mpc and they have been simulated with different baryonic models:
Gadget-MUSIC (Sembolini et al., 2013), Gadget-X (Murante et al., 2010; Rasia
et al., 2015), Gizmo-SIMBA, Davé et al. (2019); Cui et al. (2022)). However,
in this work, we only make use of Gadget-X (Cui et al., 2018) and Gizmo-SIMBA
Cui et al. (2022) runs.

In The300 simulations halos are identified by the Amiga’s Halo Finder package
(AHF; Knollmann & Knebe, 2009) and only halos with
$M_{200}>10^{13.5}h^{-1}M_{\odot}$, at redshift $z\simeq 0$ and free from
contamination are selected. Note that $M_{200}$ stands for the mass inside a
sphere of density 200 times the critical density of the Universe at the
corresponding redshift. Bear in mind that for The300 simulations, the scaling
relations do not depend on redshift at least up to $z\simeq 1$ (de Andres et
al., 2023). Free from contamination means that heavy (or low resolution) dark-
matter particles entering from outside the re-simulated volume are not present
inside our selected halos. The selection is first done for Gadget-X, the
counterpart halos from Gizmo-SIMBA are selected to have the same number of
objects and mass distribution as in Gadget-X.

Furthermore, to increase the statistics of underrepresented objects we added
objects from other snapshots (close to $z=0$) to account for a flat mass
distribution as in Ferragamo et al. (2023), which is presented in Figure 1. In
that figure, the number of galaxy clusters as a function of mass is shown, and
the whole sample is equally split into 3 bins with two vertical lines.
Moreover, the The300 simulations contain a rich variety of massive galaxy
clusters with different dynamical states (De Luca et al., 2021).

Figure 1: Mass distribution of the selected galaxy clusters sample. Note that
the selected objects follow an approximately flat distribution in the
logarithm of the mass. Dashed black vertical lines correspond to mass
thresholds that divide the sample in 3 mass bins containing an equal number of
clusters and they are at $\log(M_{200}/(h^{-1}M_{\odot}))=14.05$ and
$\log(M_{200}/(h^{-1}M_{\odot}))=14.65$.

###  2.2 Mock multiview images

From the selected halos, we further compute the Compton-$y$ parameter – a
dimensionless measure of the SZ effect, X-ray surface brightness, star mass
density and total mass density maps. Per each halo in our dataset, 29
different line-of-sight projections are considered to create 146,189 maps in
total, a large enough dataset for training our ML model. To test the
effectiveness of machine learning models and avoid observational biases, the
generated images correspond to a set of idealised maps in which the angular
resolution is sufficiently high for all of them regardless of their masses. As
such, we have created a dataset in which the size of each map is $2\times
R_{200}$, all sampled with the same number of pixels $N_{\text{pix}}=640$ and
therefore all maps are equally resolved.

Although all maps are initially created with a resolution of $640\times 640$
pixels, they are smoothed with a kernel of $~{}0.015R_{200}$ and they are re-
gridded to a lower resolution of $80\times 80$ pixels, which is needed for
computational efficiency. Nevertheless, these “low-resolution” final maps are
still very well resolved, and the angular resolution for all maps is below 1
arcmin. The idea that we desire to convey is that this dataset corresponds to
an ideal theoretical dataset from hydro-simulations which can be easily
applied to the ML models for testing their performance. In detail, the SZ
maps, X-ray surface brightness maps, star mass density maps and total mass
density maps are computed as follows:

Compton-y parameter maps ($y$) correspond to the integrated pressure along the
observer’s line of sight (l.o.s.) $dl$.

$y=\frac{\sigma_{\text{T}}k_{\text{B}}}{m_{\text{e}}c^{2}}\int
n_{\text{e}}T_{\text{e}}dl\text{ ,}$ (1)

where $\sigma_{\text{T}}$ is the Thomson cross section, $k_{\text{B}}$ is the
Boltzmann constant, $c$ the speed of light, $m_{\text{e}}$ the electron rest-
mass, $n_{\text{e}}$ the electron number density and $T_{\text{e}}$ the
electron temperature. These maps are computed using the publicly available
package PYMSZ333https://github.com/weiguangcui/pymsz (Cui et al., 2018).

X-ray surface brightness maps (X-ray) are estimated by computing the X-ray
emission by thermal bremsstrahlung in the hot intracluster medium using a
wrapper of PyAtomDB444https://atomdb.readthedocs.io/en/master/ package to
compute X-ray luminosity555https://github.com/rennehan/xraylum. First, using
the atomic database, we estimated the bolometric X-ray luminosity of gas
particles in the simulation. Then we projected the sum of the luminosity
values along the observer’s l.o.s. The projected luminosity $L_{ij}$, is then
divided by the surface area $\Sigma$ of the pixel $i,j$:

$\text{X-ray}_{ij}=L_{ij}/\Sigma\text{ ,}$ (2)

which is

$\Sigma=(R_{200}/40)^{2}\text{ .}$ (3)

Stellar density maps are generated by simply projecting the sum of the masses
of the star particles along the observer’s line of sight. This value is then
divided by $\Sigma$.

Mass density maps are generated by projecting the sum of the masses of all
particles, i.e. gas, star, dark matter and black hole particles in the
observer’s line of sight. Similarly, this value is divided by the surface area
of a pixel.

In Figure 2, examples of our simulated maps are displayed for different
cluster masses. With Compton-y maps, X-ray surface brightness maps and star
density maps, we aim to infer total mass density maps shown at the bottom by
using a deep learning model that is able to capture the non-linear relations
between input (SZ, X-ray, star) and output (total mass) maps. This model can
end-to-end translate one input map into mass density. The choice of the
particular model used and the training of that model are described in the next
section.

Map | Short name | Units
---|---|---
Compton-y parameter | SZ | $\text{ kpcs}^{-2}$
Bolometric X-ray surface brightness | X-ray | $\text{erg}\text{ s}^{-1}\text{kpcs}^{-2}$
Star density maps | star | ${{\;h^{-1}{\rm{M_{\odot}}}}}\text{ kpcs}^{-2}$
Mass density maps | mass | ${{\;h^{-1}{\rm{M_{\odot}}}}}\text{ kpcs}^{-2}$
Table 1: Dataset of simulated maps from The Three Hundred simulations. Figure
2: From top to bottom, we show some examples of maps used for training the
U-Net model: SZ, X-ray, star and mass. The mass $M_{200}$ of the examples is
shown at the top of each column. The size of all maps is $2\times R_{200}$
regardless of the mass.

##  3 Methods

###  3.1 The Deep Learning Model

The chosen model and its architecture used for the generator of mass density
maps is based on convolutional neural networks following a U-Net architecture.
This model was originally developed for image segmentation in the field of
biological imaging (Ronneberger et al., 2015). In astronomy, some applications
followed the original purpose of segmentation such as removing radio frequency
interference (Akeret et al., 2017), but also the U-Net has been successfully
considered for various and different tasks (Milletari et al., 2016; Aragon-
Calvo, 2019; Berger & Stein, 2019; Hausen & Robertson, 2020; Lauritsen et al.,
2021; Hong et al., 2021). The U-Net is characterised by a set of two paths:
the down-sampling path (or encoder) and the up-sampling path (or decoder). For
our application, the considered U-Net is described below and represented in
Figure 3.

  * •

The down-sampling path consists of a succession of convolutional blocks, each
of these applies two $\text{K}\times\text{K}$ convolutions with $F$ filters
($C_{\text{K}\times{\text{K}}}^{F}$), being K the size of the receptive field
or the kernel size. After the convolutions, a rectified linear unit operation
is applied (ReLU; Nair & Hinton, 2010) to ensure nonlinearity, and a batch
normalisation operation (BatchNorm; Ioffe & Szegedy, 2015) is applied after
each of the convolutions to improve the stability and performance of the
network. Later, a 2x2 max-pooling (e.g., Scherer et al., 2010) operation down-
samples the tensor shape so that this is reduced by a factor of $1/2$. The
subsequent convolutional blocks are built with the same architecture,
maintaining the kernel size of the convolutions but increasing the number of
filters by a factor of 2, i.e., for the $n$ layer, the filters are $F\times
2^{n-1}$, where $n=1,...,N$ is the layer and $N$ is the maximum number of
layers. After down-sampling $N$ times, a final convolution
$C_{\text{K}\times{\text{K}}}^{F\times{2^{N-1}}}$ is applied. Therefore, the
down-sampling path can be written as a series of convolutions as follows.

$\text{Encoder}=C_{\text{K}\times{\text{K}}}^{F}C_{\text{K}\times{\text{K}}}^{F}\xrightarrow[\text{sampling}]{\text{down}}C_{\text{K}\times{\text{K}}}^{F\times
2}C_{\text{K}\times{\text{K}}}^{F\times
2}\xrightarrow[\text{sampling}]{\text{down}}\text{...}\\\
\text{...}\xrightarrow[\text{sampling}]{\text{down}}C_{\text{K}\times{\text{K}}}^{F\times{2^{N-1}}}C_{\text{K}\times{\text{K}}}^{F\times{2^{N-1}}}\xrightarrow[\text{sampling}]{\text{down}}C_{\text{K}\times{\text{K}}}^{F\times{2^{N-1}}}$
(4)

  * •

The up-sampling path consists of a succession of similar convolutional blocks
to infer the output mass density map from the latent (central layer)
representation given by the down-sampling path. From this encoded reduced
representation, which is a tensor whose shape has been decreased by a factor
of $1/2^{N}$ times and has $F\times 2^{N-1}$ channels, up-sampling operations
are applied until the shape of the output mass density map is recovered. This
up-sampling operation consists of repeating the nearest points to increase the
shape of the data by a factor of 2. Then, skip connections are used for the
same row layers, and thus, information is not bottlenecked in the latent
representation. At the final decoder step, $1\times 1$ convolutions are
applied to recover the filter dimensions of the output mass density
$\text{F}=1$. For preventing overfitting, random “dropout” (Hinton et al.,
2012) is considered only in the convolutional blocks of the decoder.

$\text{Decoder}=\xrightarrow[\text{sampling}]{\text{up}}C_{\text{K}\times{\text{K}}}^{F\times
2^{N-2}}C_{\text{K}\times{\text{K}}}^{F\times
2^{N-2}}\xrightarrow[\text{sampling}]{\text{up}}C_{\text{K}\times{\text{K}}}^{F\times
2^{N-3}}C_{\text{K}\times{\text{K}}}^{F\times 2^{N-3}}\\\
\xrightarrow[\text{sampling}]{\text{up}}\text{...}\xrightarrow[\text{sampling}]{\text{up}}C_{\text{K}\times{\text{K}}}^{F}C_{\text{K}\times{\text{K}}}^{F}C_{\text{1}\times{\text{1}}}^{F/2}C_{\text{1}\times{\text{1}}}^{1}$
(5)

####  3.1.1 Multiview approaches

This model has the advantage that it can be easily generalised to extract
information simultaneously from multiple input views. To do that two
approaches are studied:

  1. 1.

The three different views are combined in a single input tensor whose shape is
increased as if it were an RGB image. This approach is labelled as “multi-1”;
and

  2. 2.

Three different encoders are used, one encoder for each input view.
Subsequently, the three latent vectors are concatenated in the internal latent
space. One decoder, the generator, is devoted to creating mass density maps
from the information of this concatenated latent space. This approach is
labelled as “multi-3” (see Figure 4).

A summary of all the models used in this work can be found in Table 2.

Model name | input maps | number of encoders
---|---|---
star | star | 1
SZ | SZ | 1
X-ray | X-ray | 1
multi-1 | star, SZ and X-ray | 1
multi-3 | star, SZ and X-ray | 3
Table 2: Models considered in this work. Each is a variation of the U-Net
architecture presented in Figure 3 to account for different inputs. Figure 3:
U-Net general architecture. The input image (star, SZ or X-ray) is downsampled
N times, once per layer through a set of convolution of kernel size
$\text{K}\times\text{K}$, and whose output layer has $F$ filters of channels.
At the very bottom, the downsampled representation is upsampled using a
similar convolutional block to generate the output mass map. Skip connections
are used to ensure that the information is not totally lost during the
downsampling operations.

###  3.2 Training and validation

According to the description given in the previous section, we consider the
following hyperparameters for our model: the number of channels or filters
$(F)$, the size of the kernel in the convolutions (K), the number of layers in
both the encoder and decoder architectures $(N)$, and the fraction of neurons
that are randomly omitted, i.e. the “dropout”. The considered possible values
of these hyperparameters are shown in Table 3 and the optimal set of
hyperparameters is found by Tree of Parzen Estimators  algorithm (TPE;
Bergstra et al., 2011). This algorithm is implemented and freely available at
Hyperopt666http://hyperopt.github.io/hyperopt/: Distributed Asynchronous
Hyper-parameter Optimisation (Bergstra et al., 2013). The targeted loss
function is the mean absolute error $L_{1}$ between the predicted pixel values
and the ground-truth pixels.

Furthermore, the data is randomly split into 3 subsets: the training dataset
composed of $80\%$ of the sample, the validation dataset with $10\%$ of data
and the remaining $10\%$ belongs to the test dataset. The training dataset is
used for tuning the U-Net parameters, the Tree of Parzen Estimators  algorithm
is fed with validation data, and the test set is only used for displaying the
final results.

We have taken 100 evaluations when performing the Hyperopt optimisation, which
means that the U-Net needs to be fitted 100 times for each of the 5 different
U-Nets. The models are trained using the Adam optimiser (Kingma & Ba, 2014)
with a learning rate of $10^{-4}$, which is reduced to $10^{-5}$ after 50
epochs. The training stops if the validation loss does not improve after 5
epochs, a process commonly known as “early stopping”, or if a model has
trained 100 epochs. The hardware used for training is an NVIDIA A100 GPU,
which translates that 1 epoch takes about 2 minutes to be completed.

hyperparameter | values
---|---
Filters $(F)$ | 8, 9, …, 32
Kernel (K) | 1, 2, …, 6
Number of layers $(N)$ | 1, …, 4
dropout | [0, 0.5]
Table 3: The considered possible values of hyperparameters of our U-Net model.
Figure 4: Multiview 3 approach. 3 different encoders are considered, with one
down-sampling path per each input view. Then this information is concatenated
in the internal layer. From this concatenated latent vector, one decoder is in
charge of the inference of the output mass density map.

##  4 Results

Figure 5: The first column on the left corresponds to the input maps (SZ,
X-ray and stars) and the ground-truth mass density map. In the second column
from top to bottom, we show the mass map predictions of our U-Net when
training with SZ, X-ray, star or multiview (multi-3). The residuals are
defined as the difference between the prediction and the ground-truth maps.
The size of all maps is $2\times R_{200}$.

In this section, our aim is to assess the quality of predicted density maps by
our model. To do that, we compare the ground-truth density maps with their
corresponding predicted maps in the test set with simple visualisation as the
first metric for assessing the quality of the predictions. Firstly, we show
one example of our predicted maps in Figure 5 for our different U-Nets
accounting for different input views. The first column on the left shows the
three input views corresponding to the same galaxy cluster and the ground-
truth density map is located at the top left. The second column shows the
predictions for several input bands: SZ, X-ray, star and multiview. The last
column corresponds to the residuals, i.e., the difference between the
prediction and the ground truth.

As a general result, we observe that the predicted mass density maps from SZ
and X-ray inputs are smoother and do not contain most of the substructures
that can be appreciated in the ground-truth map. This is clear in the last
column where the residuals mostly contain all the missing substructures and
they are underestimated as shown in the figure in blue colour. Conversely,
predictions from stars and from the multiview models contain most of the
substructures. Their residuals are generally closer to zero than the others.
We only show here the multi-3 approach, given the similarity among multi-1 and
multi-3 predictions in a human eye test.

This visualisation of density-map residuals in Figure 5 apparently is not
sufficient to numerical quantify the similarity between predict and true maps.
Therefore, we are compelled to utilise a set of additional metrics to measure
the discrepancies between the two. The considered metrics are the pixel-wise
statistics, cylindrical radial mass profiles, power spectrum and maximum mean
discrepancy which are studied in the following subsections.

###  4.1 Pixel-wise statistics

Figure 6: Pixel-wise relative difference $D_{ij,k}$ (see Eq.(6)) between the
predicted mass density maps $\hat{I}_{ij,k}$ and the ground-truth mass density
maps $I_{ij,k}$. Different lines represent the use of different input views to
predict the mass density map: star, SZ, X-ray, multi-1 and multi-3. The legend
also shows the median value of the distributions with the $16^{\text{th}}$ and
$84^{\text{th}}$ percentiles as
$\text{median}^{+|84^{\text{th}}-\text{median}|}_{-|\text{median}-16^{\text{th}}|}$.
From left to right, $D_{ij,k}$ is computed for pixels inside various circular
apertures: the whole map, inside $R_{500}$ and inside $R_{500}/2$.

One interesting metric is considering the pixel-value differences between
ground truth and predicted maps. We calculate the relative difference $D_{ij}$
between predicted maps $\hat{I}_{ij}$ and true maps $I_{ij}$ as

$D_{ij,k}=\frac{\hat{I}_{ij,k}-I_{ij,k}}{I_{ij,k}}\text{ .}$ (6)

Therefore, the tensor $D_{ij,k}$ computes the pixel-wise similarity between
true images and predicted images. The index $k$ here runs over maps, i.e., all
the maps in the test set. Subsequently, the tensor $D_{ij,k}$ is flattening to
a vector of dimensions $i\times j\times k$ and its histogram as a probability
density is represented in Figure 6. We drop the values of the tensor
$D_{ij,k}$ where the ground-truth signal $I_{ij,k}$ equals 0 unless
$\hat{I}_{ij,k}-I_{ij,k}=0$.

The particular values of the median, $16^{\text{th}}$ and $84^{\text{th}}$
percentiles of the distributions are also displayed in the legend of Figure 6
as:

$\text{value}^{+\text{error}}_{-\text{error}}=\text{median}^{+|84^{\text{th}}-\text{median}|}_{-|\text{median}-16^{\text{th}}|}.$
(7)

In this part, we also study the performance of each input map to infer the
predicted mass map at different apertures around the cluster. In the left
panel, pixel values inside the whole map are considered, in the middle only
the values $D_{ij,k}$ inside $R_{500}$ are displayed and in the right panel
only values inside $R_{500}/2$. Firstly, for the three panels in Figure 6, the
same trend is observed: the multiview-3 is the most accurate, followed very
closely by the multiview-1, using star density maps as input corresponds to
the third most accurate model while considering X-ray and SZ as inputs results
in a higher relative error, which is consistent to the expectation from Figure
5. Furthermore, this can be appreciated in the legend of Figure 6 that all the
models are slightly biased mostly towards negative values, besides the
multiview-3 with $\text{median}\simeq 0.00$ in all three panels. While the
model trained with only X-ray images yields the worst with
$\text{median}=-0.03$ for all three panels. Moreover, the scatter is smaller
for the two multiview approaches, i.e., $+0.23,-0.18$ with only slightly
larger in multiview-1 than in multiview-3. In contrast, that scatter from the
model trained with only SZ images is the largest, $+0.44,-0.29$, followed by
the X-ray model, $+0.36,-0.28$, which is also closer to the values from the
star model, $+0.38,-0.21$. As it is depicted in Figure 5, models whose input
is either SZ or X-ray fail at predicting small-scale substructures and the
signal vanishes in the outskirts of the clusters. Therefore, all those not
predicted substructures contribute to negative values in the $D_{ij,k}$
distribution. Subsequently, these substructures in the density mass maps are,
allegedly, wrongly estimated. This will be quantified in the subsequent
sections.

By comparing with the middle and right panels of Figure 6, we aim to test
whether the asymmetry in the distributions of the relative difference tensor
$D_{ij,k}$ is mainly affected by pixels outside the central region of the maps
and whether the model behaves worse in the cluster centre or not. As depicted
in that figure, the distributions progressively become less spread and more
symmetrical when considering only pixels inside a smaller aperture, $R_{500}$
and $R_{500}/2$. This means that the central regions, which we care the most,
actually have the best result. Nevertheless, the multiview models provide the
most accurate result in all cases, albeit a slight improvement with
multiview-3 than multiview-1.

###  4.2 Cylindrical radial profiles

Figure 7: Radial profiles of the mass bias, see Eq.(9). From left to right, we
show the bias corresponding to different mass intervals as indicated in Figure
1: Interval 1 corresponds to $13.5\leq\log
M/{{\;h^{-1}{\rm{M_{\odot}}}}}<14.02$, the interval 2 range is $14.02\leq\log
M/{{\;h^{-1}{\rm{M_{\odot}}}}}<14.63$ and the interval 3 is $14.63\leq\log
M/{{\;h^{-1}{\rm{M_{\odot}}}}}\leq 15.38$. The top panels show the single-
input view models (star, SZ, X-ray) and the bottom panels the multiview-1 and
-3 models. The lines represent the median values per bin and the shaded
regions cover the $16^{\text{th}}$ and $84^{\text{th}}$ percentiles.
Furthermore, the particular enclosure mass bias at $R_{200}$ is presented in
Table 4.

.

One can assess the quality of the predictions by comparing the mass radial
profiles of the predicted and the ground-truth mass density maps. The mass
profiles $M_{\rho}$ are defined by integrating the mass density, or pixel
values, of the maps in different circular regions $\Omega_{\rho}$ with radius
$\rho$:

$M_{\rho}=\sum_{i,j\in\Omega_{\rho}}I_{ij}\Sigma\text{ .}$ (8)

Here, $I_{ij}$ are the pixel values and $\Sigma$ is the pixel size –
$\Sigma=\left(R_{200}/40\right)^{2}$ –. Note that Eq.(8) provides the total 3D
mass of a galaxy cluster integrated over a cylindrical volume of $2\times
R_{200}\times\Omega_{\rho}$. We then have computed $M_{\rho}$ for ten equally-
spaced circular regions of radii $R_{\rho}=R_{200}/10,\text{ }R_{200}/9,\text{
}...,\text{ }R_{200}$. Nevertheless, the difference between the ground-truth
profile $M_{\rho}$ and the predicted profile $\hat{M}_{\rho}$ can be estimated
as the mass bias $b_{\rho}$ as it is computed also in de Andres et al. (2022)
and Ferragamo et al. (2023):

$b_{\rho}=\frac{\hat{M}_{\rho}-M_{\rho}}{M_{\rho}}\text{ .}$ (9)

In Figure 7, we show the bias $b_{\rho}$ as a function of the normalised
radius $R/R_{200}$. From left to right, we show the bias that corresponds to
three different mass intervals, which divide the dataset in a manner that each
interval contains roughly the same number of galaxy clusters, see Figure 1.
Therefore, Interval 1 corresponds to $13.5\leq\log
M/{{\;h^{-1}{\rm{M_{\odot}}}}}<14.02$, the interval 2 range is $14.02\leq\log
M/{{\;h^{-1}{\rm{M_{\odot}}}}}<14.63$ and the interval 3 is $14.63\leq\log
M/{{\;h^{-1}{\rm{M_{\odot}}}}}\leq 15.38$. Moreover, in the top panels, we
show the 3 single-view approaches (star, SZ, X-ray) and the 2 multiview models
are shown in the bottom panels. From Figure 7, we see that all models have
negative biases, apart from the low mass interval in which the biases for SZ
and Xray models generally are negative, but positive for star and multi-1
models. For the single view result in the top panels of Figure 7, negative
biases for the results from SZ and X-ray inputs are possibly caused by the
fact that they can not provide any information of substructures, especially
relatively low mass ones. The biases for the stellar inputs decrease from
positive at the low halo mass bin to negative at the high mass bin. We suspect
that is because the contribution of substructures is more significant in halos
with higher mass. Since we train the model regardless of the sample’s halo
mass, there is also a possibility that ML has to balance the predictions due
to different contributions of the sample’s halo mass. Nevertheless, it is
surprising to see the improvements from multiview inputs shown at the bottom
panels of Figure 7: the median bias is reduced by roughly a factor of $\sim
1/3$, while the scatter significantly shirked by almost $\sim 1/2$ in all
three mass bins. For the reader’s interest, the particular values for the bias
at $R_{200}$ for different models and mass intervals are shown in Table 4.

The data in Figure 7 and Table 4 show a general trend that the scatter of the
bias decreases with mass regardless of the input images. As can be seen in the
Table, for interval 1 considering the multiview-3 model, the results are
$b_{200}=0.001^{+0.078}_{0.066}$ and for interval 3 is
$0.024^{+0.019}_{-0.017}$, that is, the width is reduced by a factor of $4$.
This translates into the effect that the predictions for massive clusters are
more precise than those predictions for less massive clusters with smaller
scatter. This problem could be caused by different factors:

  * •

The loss function utilised during training, which is the mean absolute error
$L_{1}$, could be inducing the weights of the neural network to be updated to
fit only massive clusters. This can be understood by noticing that the
gradients of the loss function could be higher for massive clusters. According
to this hypothesis, the presence of high-mass clusters in our dataset hinders
the predictions at low masses. We claim here that this is false as
demonstrated in the Appendix Appendix A, in which the deep learning model is
trained with a different configuration where there is only data corresponding
to low masses in the training set.

  * •

ICM and stars follow gravity at higher masses, but at lower masses
astrophysical effects are relevant and ICM and star components differ between
Gadget-X and Gizmo-SIMBA simulations, increasing the irreducible scatter in
the observable-mass relation. Since the training uses both simulation halos
together, this larger difference at lower halo mass introduced such a large
scatter. Furthermore, even with a single simulation, the scatter in halo
baryon fractions increases as halo mass decreases which is caused by their
intrinsic evolution history (see Cui et al., 2021, for example). This is the
most relevant source that induces a mass-dependent scatter, as it is discussed
in further detail in the Appendix A.

model | Interval 1 | Interval 2 | Interval 3
---|---|---|---
star | $-0.061^{+0.222}_{-0.158}$ | $-0.033^{+0.069}_{-0.066}$ | $-0.041^{+0.033}_{-0.030}$
SZ | $-0.036^{+0.166}_{-0.132}$ | $-0.063^{+0.060}_{-0.069}$ | $-0.059^{+0.042}_{-0.040}$
X-ray | $0.085^{+0.125}_{-0.098}$ | $-0.089^{+0.050}_{-0.060}$ | $-0.071^{+0.039}_{-0.038}$
multiview 1 | $0.051^{+0.098}_{-0.073}$ | $-0.009^{+0.034}_{0.028}$ | $-0.025^{+0.019}_{-0.018}$
multiview 3 | $0.001^{+0.078}_{-0.066}$ | $-0.015^{+0.028}_{-0.026}$ | $-0.024^{+0.019}_{-0.017}$
Table 4: Values for the bias $b_{200}$ defined in of Eq.(9) at $R_{200}$ for
our different models. These values are also displayed in Figure 7 and the
intervals 1, 2 and 3 are defined to separate the dataset in roughly equal
number of clusters, as shown in Figure 1. Consequently, Interval 1 corresponds
to $13.5\leq\log M/{{\;h^{-1}{\rm{M_{\odot}}}}}<14.02$, the interval 2 range
is $14.02\leq\log M/{{\;h^{-1}{\rm{M_{\odot}}}}}<14.63$ and the interval 3 is
$14.63\leq\log M/{{\;h^{-1}{\rm{M_{\odot}}}}}\leq 15.38$.

###  4.3 Power spectrum

Quantifying the information contained in our maps at different spatial
frequencies is of great interest because the empirical evidence suggests that
substructures tend to be underestimated as observed in Figure 5, especially
for the X-ray and SZ input images. This can be clearly viewed by investigating
the power spectrum of the density mass map at small scales. Therefore, we
further calculate the power spectra of the ground-truth maps and of the
predicted maps for comparison, using the Pylians library (Python libraries for
the analysis of numerical simulations, Villaescusa-Navarro, 2018), and
highlight the difference in Figure 8.

Figure 8: Top: Power spectrum corresponding to our ground-truth (red) and the
predicted (blue) mass density maps as a function of the spatial length
$L=2\pi/k$ for our different inputs: star, SZ, X-ray, multi-1 and multi-3, are
displayed in different columns. Bottom: We show the relative difference
$(P_{\text{pred}}-P_{\text{true}})/P_{\text{true}}$ of the predicted power
spectrum $P_{\text{pred}}$ and the ground-truth power spectrum
$P_{\text{true}}$ of our mass density maps. The dashed black line depicts the
perfect prediction where the difference is zero. The solid lines correspond to
the median values while the shaded regions represent the $16^{\text{th}}$ and
$84^{\text{th}}$ percentiles.

In Figure 8, the power spectra of the predicted maps and the ground-truth maps
are shown in the top panels as a function of the spatial length which is
normalised to $R_{200}$. In the lower panels, we show the relative difference
of the spectrum defined as
$(P_{\text{pred}}-P_{\text{true}})/P_{\text{true}}$. In this figure, several
things can be noted. Firstly, the power spectrum of the predicted mass density
maps from star maps is consistent within the errors to the ground truth, where
the median power spectrum starts deviating significantly at scales $0.1\times
R_{200}$. For ICM tracers, the mass density maps predicted from SZ and X-ray
observables indicate that their power spectrum differs on average from the
ground-truth one (lower by about 25 per cent at $\lambda\sim 0.5R_{200}$),
being only similar at high spatial wavelengths. In addition, in Figure 8 the
advantage of considering multiview models is appreciated, as shown in the
fourth and fifth columns in the figure, where the multiview models effectively
combine the information available from the different inputs. This means that
the median power spectrum is similar to the power spectrum of the predicted
mass density maps from stars, but with the clear advantage that the scatter is
much smaller. To this end, SZ and X-ray views do not, as expected, improve the
predictions of small structures but rather allow the model, when combined with
data from stars, to better calibrate the overall signal, reducing the scatter.

###  4.4 Maximum Mean Discrepancy

Figure 9: Maximum Mean Discrepancy, see Eq.(10), between predicted mass
density maps and the ground-truth mass density maps as a function of the
cluster mass $M_{200}$. Different colours represent the predictions when the
model is trained with only SZ data (blue), X-ray data (orange), stellar data
(green), multi-1 (red) and multi-2 (purple). Horizontal grey dashed lines
represent the calibration of the MMD values and numbers written in black
colour on the left of these lines correspond to the noise intensity $\sigma$
used for the calibration of the MMD values. The inset highlights the results
at higher halo mass where the multiview results are compatible with
$\sigma\sim 0.05$.

Given two distributions, maximum mean discrepancy (MMD) is a test that
assesses whether the two images are the same (Gretton et al., 2008). Although
MMD can be used for training generative adversarial neural networks (Karolina
Dziugaite et al., 2015), it is used here for simply assessing the quality of
the predicted mass maps.

The MMD can be defined by choosing a kernel function $k$ and a pair of random
variables of inputs $X$ and outputs $Y$, so that one can compute the MMD as

$\text{MMD}^{2}(X,Y)=\frac{1}{m(m-1)}\sum_{i}\sum_{j\neq
i}k(x_{i},x_{j})-2\frac{1}{m^{2}}\sum_{i}\sum_{j}k(x_{i},y_{j})\\\
+\frac{1}{m(m-1)}\sum_{i}\sum_{j\neq i}k(y_{i},y_{j})\text{ .}$ (10)

Here $x_{i}$’s are the ground-truth data points and $y_{i}$’s are the
predictions of our U-Net model. For our case, the kernel is Gaussian, and
therefore the estimation of $k(x,y)$ can be written as

$k(x,y)=\exp\left(\frac{-||x-y||}{2\sigma^{2}}\right).$ (11)

where $\sigma$ corresponds to the band-with range. Typically, one chooses a
range of values of $\sigma$ to evaluate the MMD. In our case, we have computed
the MMD as the maximum value estimated by Eq. (10) taking into consideration
the following values of
$\sigma=[0.01,0.1,0.25,0.5,0.75,1.0,2.5,5.0,7.5,10.0]$, defined in Eq. (11).

Though the MMD might be very useful, it has little physical meaning. To
overcome this issue, we have computed the MMD between the ground-truth mass
density map ${I}_{ij}$ and a perturbed map $P_{ij}$ that is created by adding
a random Gaussian noise such that

$P_{ij}=I_{ij}+\mathcal{N}(0,\max(I_{ij})\cdot\alpha)\text{ .}$ (12)

Subsequently, we have calculated the MMD between the ground-truth maps $I$ and
the predicted maps $\hat{I}$. In Figure 9, we show the median values of the
MMDs as a function of the mass of the cluster that corresponds to our
different models. As a general result, the MMD metric is in agreement with the
other previous investigations in the sense that the multi-3 model is the
closest to the ground truth. We also find a mass dependence of the MMDs values
with respect to the total mass of the galaxy clusters, which is coherent with
the results in subsection 4.2 and it is explained in detail in the Appendix A.
Moreover, the noise calibrations, which are represented in dashed grey lines,
show that for small groups of clusters, the discrepancy is equivalent to
having less than $30\%$ of noise in the maps. However, in the massive end of
our dataset around $10^{15}{{\;h^{-1}{\rm{M_{\odot}}}}}$, MMDs are below
$10\%$ for all the models (SZ, X-ray, star, multi-1 and multi-3) and very
close to $5\%$ in case of the multiview models. This result suggests the use
of multiview data to boost the statistical agreement of the pixel’s
distribution in the generated total mass density maps.

##  5 Conclusions

Deep Learning models have been used for generating images (see Rothschild et
al., 2022, for example for the application in astronomy). Building on the
success in the development of ML in this field, we propose, for the first
time, to expand its application to predicting the total matter density
distributions using multiview mock observational data: star, Sunyaev-Zeldovich
and bolometric X-ray. The deep learning architecture used on the project is
based upon the U-Net, which was introduced in the context of biomedical
imaging and it has been modified for accounting for multiview input as
described in subsection 3.1. As the first step along this research line, we
validated the applicability of this ML model using a dataset of simplified
mock maps, described in section 2, from The Three Hundred set of
hydrodynamical simulations. This dataset is free from instrumental and
observational effects so that noise, point sources and telescopes’ impact are
not considered. In this work, we tested different convolutional U-Net
architectures for both single-input and multi-input models and applied
different matrices to quantify the fidelity of the predicted matter density
maps from this DL model. From the results, we can conclude that, although the
ML output is much more complex – 2D vs 1D or a single data point ($M_{200}$) –
compared to previous ML models, its outcomes, for example the 1D mass bias
profile, are much better and very promising, especially for the multiview
inputs. In detail, we can summarise our results in the following:

  * •

The scatter in the estimation of the mass maps from multiview is reduced by a
factor of $\simeq 1/2$. As depicted in Figure 6, the pixel statistics show
that the scatter can be reduced from, e.g. $\pm\sim 16\%$ when inferring the
mass from SZ and $\pm\sim 10\%$ when using the combination of inputs maps
using the multiview-3 model. Note that the scatter is defined as the deviation
from the median value using the $16^{\text{th}}$ and $84^{\text{th}}$
percentiles as it is written in Eq.(7). This fact is also acknowledged when
examining the mass profiles in Figure 7 in which the scatter can be reduced
from $\pm\sim 4\%$ to $\pm\sim 2\%$, see Table 4 for further details.

  * •

Each input view (see Figure 5) distinctly correlates with the output mass map
and therefore, the capability of predicting different spatial frequencies is
supreme for the multi-input models, as it is manifested in Figure 8.

  * •

By computing the MMD values defined in Eq.(10), we have examined the
statistical similarity of the pixel distributions between the predicted maps
and the true maps. The results suggest again the multiview models are foremost
and they can be below $5\%$ noise level as shown in Figure 9.

  * •

Overall, the multiview models provide the best predictions in all the
matrices: very low bias with a small scatter, especially in the massive
regime. Multi-3 shows a little improvement compared with multi-1 because using
3 different encoders tends to better capture the important features of each
input image.

The results of this work hint that observations of galaxy clusters at
different spectral bands will translate into a better estimation of the
underlying mass distribution. We have limited ourselves, as a first work on
the topic, to 3 input tracers, but our deep learning approach can be
generalised to account for many available inputs at different wavelengths. The
accessible computational resources are the only limitation, such as GPU
memory.

Different Deep Learning could also be considered as an additional job. Though
not shown in this paper, we have considered modifying the loss function in the
framework of generative adversarial networks (Goodfellow et al., 2014) and
training the Wasserstein GAN (Arjovsky et al., 2017) with no improvement over
using only the MAE loss function. Therefore, at the moment, the U-Net model
presented in this work is, the most suitable for addressing the problem of the
inference of the mass map from multiview mock observations.

The results of this project represent the required proof-of-concept step
towards the estimation of mass density maps from real observational data. This
constitutes a challenge in the sense that our data considered here for
training the models could not completely match the characteristics of real
data due to several regards. Firstly, our models can be used in real data
training on mock observational data where the instrumental impacts are
considered in the framework of Simulation-Based Inference. As achieved in our
previous work, observational mock data was created by introducing directly the
instrumental effects on our simulated clean maps (de Andres et al., 2022).
Secondly, the physics implemented in our simulations could lead to biased
results. To address this problem, deep learning models could be trained with
data provided from simulations with various and plausible physical models
(Villaescusa-Navarro et al., 2021).

## Acknowledgements

D.d.A., W.C. and G.Y. would like to thank Ministerio de Ciencia e Innovación
for financial support under project grant PID2021-122603NB-C21. WC is
supported by the STFC AGP Grant ST/V000594/1 and the Atracción de Talento
Contract no. 2020-T1/TIC-19882 granted by the Comunidad de Madrid in Spain. He
also thanks the ERC: HORIZON-TMA-MSCA-SE for supporting the LACEGAL-III
project with grant number 101086388. MDP and AF acknowledge support from
Sapienza Università di Roma thanks to Progetti di Ricerca Medi 2022,
RM1221816758ED4E. The authors acknowledge The Red Española de Supercomputación
for granting computing time for running the hydrodynamical simulations of
The300 galaxy cluster project in the Marenostrum supercomputer at the
Barcelona Supercomputing Center.

## Data Availability

The results shown in this work use data from The Three Hundred galaxy clusters
sample. The data is freely available upon request following the guidelines of
The Three Hundred collaboration, at https://www.the300-project.org.

## References

  * Akeret et al. (2017) Akeret J., Chang C., Lucchi A., Refregier A., 2017, Astronomy and Computing, 18, 35
  * Allen et al. (2011) Allen S. W., Evrard A. E., Mantz A. B., 2011, ARA&A, 49, 409
  * de Andres et al. (2022) de Andres Andres D., et al., 2022, Nature Astronomy, 6, 1325
  * de Andres et al. (2023) de Andres Andres D., Yepes G., Sembolini F., Martínez-Muñoz G., Cui W., Robledo F., Chuang C.-H., Rasia E., 2023, MNRAS, 518, 111
  * Aragon-Calvo (2019) Aragon-Calvo M. A., 2019, MNRAS, 484, 5771
  * Arjovsky et al. (2017) Arjovsky M., Chintala S., Bottou L., 2017, arXiv e-prints, p. arXiv:1701.07875
  * Becker & Kravtsov (2011) Becker M. R., Kravtsov A. V., 2011, ApJ, 740, 25
  * Berger & Stein (2019) Berger P., Stein G., 2019, MNRAS, 482, 2861
  * Bergstra et al. (2011) Bergstra J., Bardenet R., Bengio Y., Kégl B., 2011, Advances in neural information processing systems, 24
  * Bergstra et al. (2013) Bergstra J., Yamins D., Cox D., 2013, in International conference on machine learning. pp 115–123
  * Biviano et al. (2006) Biviano A., Murante G., Borgani S., Diaferio A., Dolag K., Girardi M., 2006, A&A, 456, 23
  * Bleem et al. (2020) Bleem L. E., et al., 2020, ApJS, 247, 25
  * Bryan & Norman (1998) Bryan G. L., Norman M. L., 1998, ApJ, 495, 80
  * CHEX-MATE Collaboration et al. (2021) CHEX-MATE Collaboration et al., 2021, A&A, 650, A104
  * Cui et al. (2018) Cui W., et al., 2018, MNRAS, 480, 2898
  * Cui et al. (2021) Cui W., Davé R., Peacock J. A., Anglés-Alcázar D., Yang X., 2021, Nature Astronomy, 5, 1069
  * Cui et al. (2022) Cui W., et al., 2022, MNRAS, 514, 977
  * Davé et al. (2019) Davé R., Anglés-Alcázar D., Narayanan D., Li Q., Rafieferantsoa M. H., Appleby S., 2019, MNRAS, 486, 2827
  * De Luca et al. (2021) De Luca F., De Petris M., Yepes G., Cui W., Knebe A., Rasia E., 2021, MNRAS, 504, 5383
  * Euclid Collaboration et al. (2023) Euclid Collaboration et al., 2023, arXiv e-prints, p. arXiv:2302.00687
  * Ferragamo et al. (2023) Ferragamo A., et al., 2023, MNRAS, 520, 4000
  * Gianfagna et al. (2021) Gianfagna G., et al., 2021, MNRAS, 502, 5115
  * Gianfagna et al. (2023) Gianfagna G., Rasia E., Cui W., De Petris M., Yepes G., Contreras-Santos A., Knebe A., 2023, MNRAS, 518, 4238
  * Goodfellow et al. (2014) Goodfellow I. J., Pouget-Abadie J., Mirza M., Xu B., Warde-Farley D., Ozair S., Courville A., Bengio Y., 2014, arXiv e-prints, p. arXiv:1406.2661
  * Gretton et al. (2008) Gretton A., Borgwardt K., Rasch M. J., Scholkopf B., Smola A. J., 2008, arXiv e-prints, p. arXiv:0805.2368
  * Gupta & Reichardt (2020) Gupta N., Reichardt C. L., 2020, ApJ, 900, 110
  * Gupta & Reichardt (2021) Gupta N., Reichardt C. L., 2021, ApJ, 923, 96
  * Hausen & Robertson (2020) Hausen R., Robertson B. E., 2020, ApJS, 248, 20
  * Herbonnet et al. (2022) Herbonnet R., et al., 2022, MNRAS, 513, 2178
  * Hilton et al. (2018) Hilton M., et al., 2018, ApJS, 235, 20
  * Hinton et al. (2012) Hinton G. E., Srivastava N., Krizhevsky A., Sutskever I., Salakhutdinov R. R., 2012, arXiv e-prints, p. arXiv:1207.0580
  * Ho et al. (2019) Ho M., Rau M. M., Ntampaka M., Farahi A., Trac H., Póczos B., 2019, ApJ, 887, 25
  * Ho et al. (2021) Ho M., Farahi A., Rau M. M., Trac H., 2021, ApJ, 908, 204
  * Ho et al. (2023) Ho M., Soltis J., Farahi A., Nagai D., Evrard A., Ntampaka M., 2023, MNRAS, 524, 3289
  * Hong et al. (2021) Hong S. E., Jeong D., Hwang H. S., Kim J., 2021, ApJ, 913, 76
  * Huertas-Company & Lanusse (2023) Huertas-Company M., Lanusse F., 2023, Publ. Astron. Soc. Australia, 40, e001
  * Ioffe & Szegedy (2015) Ioffe S., Szegedy C., 2015, arXiv e-prints, p. arXiv:1502.03167
  * Karolina Dziugaite et al. (2015) Karolina Dziugaite G., Roy D. M., Ghahramani Z., 2015, arXiv e-prints, p. arXiv:1505.03906
  * Kingma & Ba (2014) Kingma D. P., Ba J., 2014, arXiv e-prints, p. arXiv:1412.6980
  * Klypin et al. (2016) Klypin A., Yepes G., Gottlöber S., Prada F., Heß S., 2016, MNRAS, 457, 4340
  * Knollmann & Knebe (2009) Knollmann S. R., Knebe A., 2009, ApJS, 182, 608
  * Kodi Ramanah et al. (2020) Kodi Ramanah D., Wojtak R., Ansari Z., Gall C., Hjorth J., 2020, MNRAS, 499, 1985
  * Kodi Ramanah et al. (2021) Kodi Ramanah D., Wojtak R., Arendse N., 2021, MNRAS, 501, 4080
  * Kravtsov & Borgani (2012) Kravtsov A. V., Borgani S., 2012, ARA&A, 50, 353
  * Krippendorf et al. (2023) Krippendorf S., et al., 2023, arXiv e-prints, p. arXiv:2305.00016
  * Lauritsen et al. (2021) Lauritsen L., Dickinson H., Bromley J., Serjeant S., Lim C.-F., Gao Z.-K., Wang W.-H., 2021, MNRAS, 507, 1546
  * Liu et al. (2022) Liu A., et al., 2022, A&A, 661, A2
  * Milletari et al. (2016) Milletari F., Navab N., Ahmadi S.-A., 2016, arXiv e-prints, p. arXiv:1606.04797
  * Murante et al. (2010) Murante G., Monaco P., Giovalli M., Borgani S., Diaferio A., 2010, MNRAS, 405, 1491
  * Nair & Hinton (2010) Nair V., Hinton G. E., 2010, in Proceedings of the 27th international conference on machine learning (ICML-10). pp 807–814
  * Ntampaka et al. (2019) Ntampaka M., et al., 2019, ApJ, 876, 82
  * Odewahn et al. (1992) Odewahn S. C., Stockwell E. B., Pennington R. L., Humphreys R. M., Zumach W. A., 1992, AJ, 103, 318
  * Planck Collaboration et al. (2016a) Planck Collaboration et al., 2016a, A&A, 594, A13
  * Planck Collaboration et al. (2016b) Planck Collaboration et al., 2016b, A&A, 594, A24
  * Planck Collaboration et al. (2016c) Planck Collaboration et al., 2016c, A&A, 594, A27
  * Pratt et al. (2019) Pratt G. W., Arnaud M., Biviano A., Eckert D., Ettori S., Nagai D., Okabe N., Reiprich T. H., 2019, Space Sci. Rev., 215, 25
  * Rasia et al. (2015) Rasia E., et al., 2015, ApJ, 813, L17
  * Ronneberger et al. (2015) Ronneberger O., Fischer P., Brox T., 2015, in Medical Image Computing and Computer-Assisted Intervention–MICCAI 2015: 18th International Conference, Munich, Germany, October 5-9, 2015, Proceedings, Part III 18. pp 234–241
  * Rothschild et al. (2022) Rothschild T., Nagai D., Aung H., Green S. B., Ntampaka M., ZuHone J., 2022, MNRAS, 513, 333
  * Rozo et al. (2009) Rozo E., et al., 2009, ApJ, 699, 768
  * Salvati et al. (2022) Salvati L., et al., 2022, ApJ, 934, 129
  * Scherer et al. (2010) Scherer D., Müller A., Behnke S., 2010, in Diamantaras K., Duch W., Iliadis L. S., eds, Artificial Neural Networks – ICANN 2010. Springer Berlin Heidelberg, Berlin, Heidelberg, pp 92–101
  * Sembolini et al. (2013) Sembolini F., Yepes G., De Petris M., Gottlöber S., Lamagna L., Comis B., 2013, MNRAS, 429, 323
  * Smith & Geach (2023) Smith M. J., Geach J. E., 2023, Royal Society Open Science, 10, 221454
  * Strauss et al. (2002) Strauss M. A., et al., 2002, AJ, 124, 1810
  * Sunyaev & Zeldovich (1972) Sunyaev R. A., Zeldovich Y. B., 1972, Comments on Astrophysics and Space Physics, 4, 173
  * Villaescusa-Navarro (2018) Villaescusa-Navarro F., 2018, Pylians: Python libraries for the analysis of numerical simulations, Astrophysics Source Code Library, record ascl:1811.008 (ascl:1811.008)
  * Villaescusa-Navarro et al. (2021) Villaescusa-Navarro F., et al., 2021, ApJ, 915, 71
  * Yan et al. (2020) Yan Z., Mead A. J., Van Waerbeke L., Hinshaw G., McCarthy I. G., 2020, MNRAS, 499, 3445

##  Appendix A The differences between GIZMO and Gadget-X

Figure 10: Median gas fraction as a function of the mass for the GIZMO and
GADGET-X simulations. The shaded regions correspond to the $16^{\text{th}}$
and $84^{\text{th}}$ percentiles. Figure 11: Median star fraction as a
function of the mass for the GIZMO and GADGET-X simulations. The shaded
regions correspond to the $16^{\text{th}}$ and $84^{\text{th}}$ percentiles.

Figure 12: Mass bias see Eq.(9) for the mass profiles as a function of the
radius $R/R_{200}$ for the experiments previously mentioned in this appendix.
From left to right, we show the bias corresponding to the different
experiments: Train with low-mass objects with data from both simulations,
train only with high-mass objects with data from both simulations, train low-
mass objects with data only from GIZMO and train with low-mass objects with
data only from Gadget-X. The lines represent the medium values per bin and the
shaded regions cover the $16^{\text{th}}$ and $84^{\text{th}}$ percentiles.

.

Throughout this work, we have shown that the difference between the ground-
truth maps from the predicted maps is dependent on the cluster mass $M_{200}$
(see Figure 7 and Figure 9). We have claimed that this trend is primarily due
to the fact that gravity is more relevant for massive galaxy clusters and
astrophysical effects implemented in The Three Hundred simulations, which are
different codes for star formation, supernovae and black hole feedbacks,
become more relevant in small groups and thus, the scatter of the predicted
mass density maps of these small objects increases.

Furthermore, as mentioned in section 2, we have trained with data from
Gadget-X and Gizmo-SIMBA simulations and the CNN model has managed to learn
from both simulations simultaneously. However, both codes generate very
different types of galaxy clusters as far as the ICM and star properties are
concerned. In Figure 10, the gas fraction of our data sample is shown for
GIZMO (blue) and Gadget-X (dashed orange). The figure implies that the gas
fraction for Gadget-X is more constant, while for GIZMO decays faster in small
groups. Nevertheless, the star fractions follow the opposite trend, as shown
in Figure 11. In summary, these two figures show that different astrophysical
implementations converge in the massive end and therefore, one might expect
that the ICM and star distributions follow gravity, and are more related to
the total mass density of the galaxy clusters for massive galaxy clusters.

To show that the scatter does not depend on the machine learning model, but
rather on the diversity of the data, we have run different experiments:

  1. 1.

Low mass: We have retrained the multi-3 model with galaxy clusters belonging
only to the first mass interval, i.e., $13.5\leq\log
M/{{\;h^{-1}{\rm{M_{\odot}}}}}<14.02$.

  2. 2.

High mass: We have also retrained the model with data belonging only to the
most massive interval ($14.63\leq\log M/{{\;h^{-1}{\rm{M_{\odot}}}}}\leq
15.38$).

  3. 3.

Low mass GIZMO: We have retrained the model multi-3 with data belonging only
to Gizmo-SIMBA only in the first mass interval.

  4. 4.

Low mass Gadget-X: We have also retrained the multi-3 model with data
belonging to Gadget-X only in the first mass interval.

The results of the experiments are shown in the Figure 12. From the first and
second experiments, we conclude that the scatter does not depend on the ML
model and training procedure. We acknowledge that although these could bias
the prediction to be more accurate at higher masses, that is not the case as
the experiments suggest. From the third and fourth experiments, the results on
GIZMO and GADGET-X simulations are similar and therefore, we conclude that the
performance should not vary significantly for different hydrodynamical
simulations.