# Cosmological multifield emulator

Sambatra Andrianomena,11footnotetext: Corresponding author. Sultan Hassan
Francisco Villaescusa-Navarro

###### Abstract

We demonstrate the use of deep network to learn the distribution of data from
state-of-the-art hydrodynamic simulations of the CAMELS project. To this end,
we train a generative adversarial network to generate images composed of three
different channels that represent gas density (Mgas), neutral hydrogen density
(HI), and magnetic field amplitudes (B). We consider an unconstrained model
and another scenario where the model is conditioned on the matter density
$\Omega_{\rm m}$ and the amplitude of density fluctuations $\sigma_{8}$. We
find that the generated images exhibit great quality which is on a par with
that of data, visually. Quantitatively, we find that our model generates maps
whose statistical properties, quantified by probability distribution function
of pixel values and auto-power spectra, agree reasonably well with those of
the real maps. Moreover, the cross-correlations between fields in all maps
produced by the emulator are in good agreement with those of the real images,
which indicates that our model generates instances whose maps in all three
channels describe the same physical region. Furthermore, a CNN regressor,
which has been trained to extract $\Omega_{\rm m}$ and $\sigma_{8}$ from
CAMELS multifield dataset, recovers the cosmology from the maps generated by
our conditional model, achieving $R^{2}$ = 0.96 and 0.83 corresponding to
$\Omega_{\rm m}$ and $\sigma_{8}$ respectively. This further demonstrates the
great capability of the model to mimic CAMELS data. Our model can be useful
for generating data that are required to analyze the information from upcoming
multi-wavelength cosmological surveys.

##  1 Introduction

Multiwavelength astronomy has been identified as a priority in the 2020
decadal survey [1]. Current and upcoming missions will survey the Universe at
different wavelengths, from X-rays to radio: e.g. e-Rosita [2], SKA [3, 4],
Euclid [5], DESI [6], CMB-S4 [7], Rubin [8] and Roman [9] Observatories, HIRAX
[10], CHIME [11], Spherex [12]. The data from these missions is expected to
help us improve our knowledge of both galaxy evolution and cosmology. In order
to maximize the scientific outcome of these missions, accurate theoretical
predictions are needed for different physical fields. Hydrodynamic simulations
are the most sophisticated tools that can be used to study and model this.
Their main drawback is their computational cost that, being very large, limits
the volume and resolution of these simulations [13]. Being able to speed up
these simulations is critical in order to perform a large variety of tasks
such as parameter inference. Previous studies aimed at accelerating various
cosmological simulations of different fields using generative models. The
generative adversarial networks (GAN) model in [14] was trained to speed up 2D
cosmic web simulations. The GANs in [15] learned to reproduce high resolution
($1024\times 1024$ pixels2) weak lensing convergence maps. The Wasserstein
Generative Adversarial Networks (WGANs), which were built in [16], were
capable of generating 3D HI maps of $64\times 64\times 64$ pixels at $z=5$.
[17] prescribed a scalable GAN method to emulate 3D $N$-body simulations
cubes. Similarly, [18] trained GANs to generate 3D cosmic web using dataset
from GADGET-2 $N$-body simulations [19]. [20] built a conditional GANs to
learn 2D dark matter maps conditioned on $\Omega_{\rm m}$ and $\sigma_{8}$.
[21] investigated the void properties from maps of large scale structure which
were generated by GANs.

In this work, based on the success of GANs, we make use of its variant to
produce multifield images – 2D maps whose each channel corresponds to a
different physical field – that have the desired statistical properties for
each field individually but also their cross-correlations. This is crucial in
order to extract most of the information from different large-scale surveys.
We note that while the generation of multifield images has been performed in
the past [see e.g. 22] this work contributes to that direction by using a more
sophisticated model and a richer and more complex dataset.

The paper is structured as follows: we provide a quick overview of generative
adversarial networks and the model that is used in this work in § 2. The
dataset considered in our analyses is discussed in § 3, and the results are
presented in § 4. We finally conclude in § 5.

##  2 Generative adversarial networks

To build a generative model, [23] prescribed a novel approach that leverages
the concept of a zero-sum non-cooperative game, i.e. one wins to the detriment
of the other. The method consists of two competing network models in which a
generator $G$ approximates the distribution $p_{g}$ over the real data
${\bm{x}}$ by trying to fool a discriminator $D$ which learns to estimate the
probability $D({\bm{x}})$ that a given example ${\bm{x}}_{i}$ is real. During
training, the generator learns to map a prior noise distribution $p_{z}$ to
data space $G({\bm{z}})$. The discriminator attempts to differentiate the real
from the fake examples. The parameters of $D({\bm{x}})$ and $G({\bm{z}})$ are
updated by maximising ${\rm log}(D({\bm{x}}))$ and minimising ${\rm
log}(1-D(G({\bm{z}})))$ respectively, similar to optimizing a value function
$V(D,G)$ of a two-player min-max game according to [23]

$\displaystyle\underset{G}{min}\ \underset{D}{max}\
V(D,G)=\mathbb{E}_{{\bm{x}}\sim p_{\rm{data}}({\bm{x}})}[{\rm
log}(D({\bm{x}}))]\ +\mathbb{E}_{{\bm{z}}\sim p_{\bm{z}}({\bm{z}})}[{\rm
log}(1-D(G({\bm{z}})))].$ (2.1)

A solution is optimal when the generator is capable of producing samples
$G({\bm{z}})$ with features similar to those of real data such that the
discriminator $D$ acts like a classifier with a random guess when identifying
real and fake images from the training data and generator respectively. In
other words, as the training converges, the discriminator [23]

$D^{*}_{G}=\frac{p_{\rm data}({\bm{x}})}{p_{\rm
data}({\bm{x}})+p_{g}({\bm{x}})}$

tends to $D^{*}({\bm{x}})\sim\frac{1}{2}$ as $p_{g}$ approaches $p_{\rm
data}$.

Figure 1: The schematic diagram of a Skip-layer excitation (SE) is shown on
the left, whereas that of the generator is presented on the right. Two feature
maps of different resolutions are fed into SE, and the one with a lower
resolution goes through an average pooling and two convolutional layers before
being channel-wise multiplied by the one with a higher resolution. The
generator outputs a fake instance with the same dimensions as the data, i.e.
$256\times 256\times 3$, and the same fake instance but with lower dimensions,
$128\times 128\times 3$.

Figure 2: Schematic diagram of the discriminator which also uses SE. The
discriminator takes both a lower and higher resolution instances as inputs.

It is claimed in [23] that the training is straightforward when both models
are multilayer perceptrons (MLP), i.e. mainly composed of dense layers.
However, when local information is important and the number of features is
large, such as in the case of an image, a convolution layer-based network is
better suited for the task. To address this, for example, [24] prescribed a
GAN model in which both $D$ and $G$ use convolution layers and convolutional-
transpose222Sometimes known as deconvolution layer layers respectively.
We consider a variant of GANs described in [25] who introduced some novelties
such that the generative model is capable of synthesizing high-resolution
images while being trained with a relatively small number of examples. They
prescribed a modified version of skip-layer connection [26], named Skip-Layer
Excitation (SLE) (see left panel in Figure 1), which, like the original skip-
layer, allows the gradient flow to be preserved through the layers. However,
unlike the skip connection in [26], SLE does not require the two inputs to
have the same dimension as the output results from channel-wise
multiplications between the two inputs, according to [25]

${\bm{y}}=\mathcal{F}({\bm{x}}_{\rm low},{\bm{W}})\cdot{\bm{x}}_{\rm high},$
(2.2)

where ${\bm{x}}_{\rm low}$ and ${\bm{x}}_{\rm high}$ are two input feature
maps with lower and higher resolutions respectively. $\mathcal{F}$ denotes a
module with learnable weights ${\bm{W}}$ that operates on ${\bm{x}}_{\rm
low}$. The generator G in our model contains three SLE modules that perform
channel-wise multiplications of maps at $4\times 4$, $8\times 8$ and $16\times
16$ resolutions with those of $64\times 64$, $128\times 128$, and $256\times
256$ resolutions respectively (see Figure 1). It is noted that, and as shown
in Figure 1, G outputs low ($128\times 128\times 3$) and high resolution
($256\times 256\times 3$) instances which are passed through the
discriminator. Following the prescription in [25], the discriminator D,
treated as an encoder, is trained with three decoders in order to enhance its
ability to extract the salient features from the input maps (Figure 2). The
auto-encoder, which comprises D and the decoders, is optimized using only real
images by minimizing the reconstruction loss [25]

$\mathcal{L}_{\rm recons}=\mathbb{E}_{{\bm{f}}\sim
D({\bm{x}})}[||\mathcal{G}({\bm{f}})-\mathcal{T}(x)||],$ (2.3)

where ${\bm{f}}$ denotes intermediate feature maps with resolutions $8\times
8$ and $16\times 16$ from D (see Figure 2), $\mathcal{G}$ is the decoding
process and $\mathcal{T}$ represents a transformation on the real images
$\bm{x}$, namely cropping and downsampling. As already mentioned, D expects
two inputs which are the same image with two different dimensions as shown in
Figure 2. In the case of generated instances, the discriminator processes the
two outputs of dimensions $128\times 128\times 3$ and $256\times 256\times 3$
from the generator to compute the generator loss. In the case of real data,
both the lower resolution ($128\times 128\times 3$), which is obtained from
downsampling the data via interpolation, and the higher resolution ($256\times
256\times 3$) are used to calculate both the discriminator and the
reconstruction losses (Equation 2.3). For the adversarial training, we have
that [25]

$\displaystyle\mathcal{L}_{D}=-\mathbb{E}_{{\bm{x}}\sim p_{\rm
data}({\bm{x}})}[{\rm min}(0,-1+D({\bm{x}}))]-\mathbb{E}_{{\bm{z}}\sim p_{\rm
z}({\bm{z}})}[{\rm min}(0,-1-D(G({\bm{z}})))]+\mathcal{L}_{\rm recons}$ (2.4)

as the loss function for D and

$\mathcal{L}_{G}=-\mathbb{E}_{{\bm{z}}\sim p_{\rm
z}({\bm{z}})}[D(G({\bm{z}}))],$ (2.5)

the loss for G. It is worth noting that $\bm{z}$, which is a vector from
latent space, is drawn from a normal distribution.

Figure 3: Comparison between CAMELS images (top row) and the generated images
(bottom row) using unconditional GANs for randomly selected set of fields. The
top row shows images of gas mass density (left), neutral hydrogen mass density
(middle), and magnetic field strength (right) from a state-of-the hydrodynamic
simulation from the CAMELS project. Note that the three images represent the
same region in space. The bottom row shows each field of an instance output by
our GAN model. From visual inspection, we can see that the model very well
reproduces the morphological features of the different fields.

Figure 4: Comparison between CAMELS and unconditional GAN in terms of the
average (top) and standard deviation (bottom) of the probability distribution
function of pixel values (PDF) over 1,500 different realizations. We have
computed the PDF for 1,500 unseen real images (red) and 1,500 generated images
(blue) for each channel (or field). This plot shows the mean (top) and
standard deviation (bottom) of the PDF for the three different fields. The
agreement between the results of the simulated and generated images is good
overall, however some statistical differences at the tails of the
distributions can be noticed.

Figure 5: Similar to Figure 4 but for the cross-power spectrum (top row) and
auto-power spectrum (bottom row). Relative error between the two power spectra
(fake and real), denoted by solid green, is presented at the bottom part of
each panel. As can be seen, the statistical agreement between the data and
generated images is relatively good for this statistics. The title of each
panel displays the considered field(s).

##  3 Data

We make use of images from the CAMELS Multifield Dataset (CMD) [27]. CMD
contains hundreds of thousands of 2D maps generated from the output of state-
of-the art hydrodynamic simulations of CAMELS [28] for 13 different physical
fields, e.g. dark matter, magnetic fields. Every image represents a region of
dimensions $25\times 25\times 5~{}(h^{-1}{\rm Mpc})^{3}$ at $z=0$. In our
analyses, we consider images comprising three different fields – gas mass
density (`Mgas`), neutral hydrogen density (`HI`), and magnetic fields
magnitude (`B`) – generated from the IllustrisTNG LH set [see 28, 29, for
details]. Each field contains 15,000 maps which were produced from varying the
cosmology ($\Omega_{\rm m}$ and $\sigma_{8}$), the astrophysics ($A_{\rm
SN1}$, $A_{\rm SN1}$, $A_{\rm AGN1}$, $A_{\rm AGN2}$), and the initial seed
number. It is worth noting that the supernova feedback process is
characterized by $A_{\rm SN1}$ and $A_{\rm SN1}$ which control the energy
transfer and the wind speed respectively. $A_{\rm AGN1}$ and $A_{\rm AGN2}$,
which encode the power injected and jet speed respectively, characterize the
AGN feedback process. The multifields are produced by stacking 3 field images
that show the same physical region: `Mgas`, `HI`, and `B`. Thus, each instance
in our training data has $256\times 256$ pixels2 and contains three
channels333Tensors of dimensions $256\times 256\times 3$. For training, we set
the learning rate to 0.0002 and employ Adam optimizer. The model is trained
with 10,000 multifield images for 700 epochs444Each epoch takes about 12
minutes. in batches of 8 examples on a NVIDIA GeForce GTX 1080 Ti.

Figure 6: Left panel presents samples from the test data whose cosmology is
known ($\Omega_{\rm m}=0.33$, $\sigma_{8}=0.68$). Conditioned by the same set
of cosmological parameters, the images on the right panel have been generated
by the conditional GAN. The color coding for the fields in each instance is
the same as in Figure 3, i.e. red, green and blue refer to ``Mgas—, ``HI— and
``B— respectively.

Figure 7: The mean and standard deviation of PDF of the generated maps
conditioned by the cosmology ($\Omega_{\rm m}$ and $\sigma_{8}$) are shown at
the top row and bottom row respectively. Each column correspond to a field.

Figure 8: Similar to Figure 5 but the results are obtained from conditioning
the image generations on the two cosmological parameters ($\Omega_{\rm m}$ and
$\sigma_{8}$).

##  4 Results

We now present the results obtained from the two scenarios in our analyses,
i.e. unconditional and conditional GANs. The model performance is evaluated
using probability distribution function (PDF) of the pixel values and power
spectrum $P(k)$.

###  4.1 Unconditional GAN

In Figure 3, we compare an instance output by our model with a randomly drawn
image from our test set which comprises 1,500 examples that are unseen by the
model during training. The top row corresponds to real images555Which is also
used to denote images from IllustrisTNG dataset. and the bottom one shows the
generated images666Which are images generated by the model.. Each column in
Figure 3 is related to one field. Visually, the quality of the field maps in
the generated instance is comparable with that of the real images from the
test data. Morever, similar to the real instance, the morphological features –
voids, filaments, halos, and bubbles – in each field map of the new
example777In other words, the generated example. correspond well with those of
the other two channels (see bottom row in Figure 3). This is expected since
all channels are supposed to represent the same physical region and indicates
the ability of our model to produce images that mimic those of the training
data.

To assess the statistical properties of the maps generated by the model, we
first use the PDF of the pixel intensities. By flattening each field map of an
instance to an array, we compute the mean $\mu_{\rm PDF}$ and standard
deviation $\sigma_{\rm PDF}$ of each channel of the 1,500 test data and
generated instances. Figure 4 shows the comparison between the distributions
of both real and new images. The top row shows the mean of the pixel value
distribution, whereas the standard deviation is presented in the bottom row
(see Figure 4). Each column corresponds to results related to one field. We
find that the generator is able to encode the salient features of each field,
as evidenced by the overall agreement between the $\mu_{\rm PDF}$ of generated
instances and that of CAMELS, despite the statistical differences at the tails
of the distributions. The latter can be explained by the fact that high-valued
pixels are rare in the maps, hence the induced bias. The consistency between
the variability of the pixel distribution of both new and real examples (see
$\sigma_{\rm PDF}$ at the bottom row of Figure 4) implies that the model has
learned a robust lower dimension representation of the data.

The metric we use to evaluate the clustering properties of the new images is
the power spectrum $P(k)$ which is computed using
Pylians888https://pylians3.readthedocs.io [30]. There are two aspects of this
evaluation: assessing if the clustering properties of the generated images of
each field are consistent with their real counterparts by computing the
average auto-power spectra ($\bar{P}^{\rm auto}(k)$) of both generated and
real examples; and investigating the consistency between the three channels of
the new instances and comparing it with that of the data, by computing the
average cross-power spectra between channels ($\bar{P}^{\rm cross}(k)$). We
present the average auto and cross-power spectra of the images at the bottom
and top rows of Figure 5 respectively. In each panel, the solid red and dashed
blue lines indicate the average power spectra of the generated and simulated
images respectively; and the red and blue shaded areas denote the standard
deviations of the power spectra of the new and real images respectively. The
solid green line at the bottom of each panel represents the relative
difference between the fake and real average power spectra at each $k$-mode
$\left(\frac{\bar{P}_{\rm fake}(k)}{\bar{P}_{\rm real}(k)}-1\right)$. The good
agreement between the average auto-power spectra in each field is indicative
of the fact that the generator is capable of producing images whose clustering
properties are consistent with those of the data. However, it appears that
modeling the fluctuations of each field is more challenging on small scales,
as denoted by the larger discrepancies on scales $k>10\>h/{\rm Mpc}$ (see also
the solid green line at the bottom of each panel at the bottom row of Figure
5). The results in Figure 5 top panels suggest that the average cross-
correlation signals between channels in the generated instances agree with
those of the data, implying that all channels in each example generated by the
model represent the same physical region as expected. Similar to the case of
auto-power spectra, the relative difference between the predicted and real
average cross-power spectra is more important with increasing wavenumber $k$.
The agreement between the blue and red shaded areas (top panels in Figure 5)
demonstrates the ability of the generator to capture the variability of the
signals at each $k$-mode, denoting that the model generalizes well.
Technically, our results can’t be directly compared with those obtained in
[22] as their scale of interest is $k\leq 1\>h/{\rm Mpc}$. However the
relative error on the auto-power spectrum of each field on scales $k\leq
1\>h/{\rm Mpc}$ (see bottom row of Figure 5) is comparable to that obtained in
[22] (see the top left panel in their Figure 15).

###  4.2 Conditional GAN

In light of the results presented in § 4.1, it can be said that the model is
capable of producing new instances which exhibit statistical properties
closely similar to those of the data. While very promising, the underlying
cosmology and astrophysics are unknown in the unconditional case. When
exploring parameter space which requires accelerating cosmological
simulations, we wish to obtain the resulting map that corresponds to the
cosmological and astrophysical parameters at the input. In our analyses, as a
first step, we condition the GAN model on the two cosmological parameters
($\Omega_{\rm m}$ and $\sigma_{8}$) that the maps are most sensitive to in
general. To do so, we retrain the model using the same set of hyperparameters
as that in the unconditional case (see § 4.1), but both the generator and
discriminator are dependent on $\Omega_{\rm m}$ and $\sigma_{8}$. Conditioning
the generator consists of simply concatenating the cosmological parameters
(array of length 2) to the prior vector at its input. Implementing the
condition in the discriminator amounts to passing the cosmological parameters
through a dense layer of 4096 units whose output is reshaped to a tensor
$64\times 64$. The latter dimension is first upsampled to match the channel
dimension ($256\times 256$) via interpolation and then concatenated to the
input, yielding a new input comprising four channels. In Figure 6 on the left
panel, we show samples from the test data that have the same underlying
cosmology999We note that those samples from the test set have the same set of
astrophysical parameters as well. which has also been used to condition the
generation of the new images on the right panel. The diversity of the GAN-
generated images (see Figure 6), although corresponding to the same cosmology,
is noticeable. This points toward the fact the GAN model does not suffer from
mode collapse. Consistent with the results obtained in § 4.1, the quality of
the generated images is on a par with that of simulated ones, and visually all
channels of each new instance appear to show the same physical region.
Following the performance tests carried out in the unconditional case, the PDF
and power spectra are computed using 1,500 unseen samples from the test set
and 1,500 generated samples. Overall, the estimated mean $\mu_{\rm PDF}$ and
standard deviation $\sigma_{\rm PDF}$ of pixel value distribution indicate
that the generated images conditioned on the cosmology exhibit topology which
agrees well with that of the data, as shown in Figure 7. Results show that the
conditional GAN has also learned to capture the clustering properties of each
field from the training data, as indicated by the overall agreement between
the auto-power spectra of generated maps and those of real maps for each field
(see Figure 8 bottom row). The fact that cross-correlation signals between
channels of the generated instances are consistent with their real
counterparts (see Figure 8 top row) implies that all the channels in each GAN-
generated example are consistent with one another and depict the same physical
region.

In general, based on the metrics considered in our analyses, both
unconditional and conditional GAN perform equally well, but we further
investigate how well the new images are constrained by the cosmology
($\Omega_{\rm m}$, $\sigma_{8}$). Six subsets of ten images are selected from
the holdout set. The images in each subset correspond to the same cosmology,
characterized by the pair $\\{\Omega_{\rm m},\sigma_{8}\\}$, which is also
used to condition the generations of six subsets of ten new images. In other
words, in the entire subset which we name $\mathbb{S}^{\rm
cosmo}$101010$\mathbb{S}^{\rm cosmo}$ contains $6\times$ 10 CAMELS data, and
$6\times$ 10 generated data, giving 1200 samples in total. for clarity, each
pair $\\{\Omega_{\rm m},\sigma_{8}\\}$ has 20 corresponding images in which
half is drawn from the test set and the other half is produced by the model.
To assess the performance of the model in this test, like the one conducted in
[31], the average ($\bar{P}(k)$) and standard deviation ($\sigma_{P}(k)$)
power spectra are computed for each set of cosmological parameters using the
ten samples of each subset (real/new). In Figure 9 we compare the predicted
mean auto-power spectra $\bar{P}_{\rm fake}(k)$ (solid red line) with the real
ones $\bar{P}_{\rm real}(k)$ (dashed blue line) for different sets of
cosmological parameters. The field in each panel of each row corresponds to
the same cosmology whose parameters are shown in blue on the top right corner.
The standard deviation of the power spectra at each $k$-bin is denoted by red
and blue shaded areas for the GAN-generated and CAMELS instances respectively.
Coefficient of determination $R^{2}$ is used to check the consistency between
the power spectra and is given by

$R^{2}=1-\frac{\sum_{i=1}^{n}\left(\bm{y}_{i}-\hat{\bm{y}}_{i}\right)^{2}}{\sum_{i=1}^{n}\left(\bm{y}_{i}-\bar{\bm{y}}_{i}\right)^{2}},$
(4.1)

where $n$, $\bm{y}_{i}$ (or $\bar{P}_{\rm real,i}$), $\hat{\bm{y}}_{i}$ (or
$\bar{P}_{\rm fake,i}$) are the number of $k$-bins, data and generated images
power spectra at each $k$-bin respectively, and we have that
$\bar{\bm{y}}_{i}=(1/n)\sum_{i=1}^{n}\bm{y}_{i}$. For more accurate estimate
of $R^{2}$, we only select $k$-bins with more than ten modes. In other words,
our calculations are restricted to $k\geq 1h/{\rm Mpc}$.

Figure 9: For each field, the average auto-power spectrum of the data (using
10 instances from the test set) are compared with that of the generated
samples (using 10 GAN-generated samples). Each row corresponds to the power
spectra of all fields for a given cosmology ($\Omega_{\rm m}$ and
$\sigma_{8}$). The coefficient of determination $R^{2}$ between the predicted
and real power spectra of each field is computed and shown at the bottom left
of each panel.

Figure 10: Similar to what is shown in Figure 9 but for the cross-correlation
between fields of both real and fake images. The average cross-power spectra
of both the data and new images are computed using 10 instances from
$\mathbb{S}^{\rm cosmo}$ subset, 10 GAN-generated samples respectively.

In general, for any of the cosmologies and in each field, the clustering
properties of CAMELS and those of the generated data are consistent with each
other, as evidenced by all $R^{2}$ values $\geq 0.9$ (see Figure 9). This
suggests that the image generations can be constrained reasonably well by the
cosmological parameters. We also inspect the consistency between the field
maps in each GAN-produced sample when the cosmology is fixed. In Figure 10 we
present the average cross-correlation between channels of all instances
(CAMELS/GAN-generated) in $\mathbb{S}^{\rm cosmo}$. Like in Figure 9, the
results in all panels of each row are related to a given cosmology. Each
column corresponds to the same cross-correlation between two fields. Overall,
for each set of cosmological parameters in this test, the GAN model is able to
predict reasonably well the cross-correlations between the different fields
(`Mgas`$\times$`HI`, `Mgas`$\times$`B` and `HI`$\times$`B`) of CAMELS, with
most of $R^{2}$ values $\geq 0.84$. However there are cases where discrepancy
between two power spectra (of CAMELS and GAN-generated images) is relatively
important, as indicated by negative values of $R^{2}$. Predicting the cross
power spectra of both `Mgas`$\times$`B` and `HI`$\times$`B` for
$\\{\Omega_{\rm m}=0.30,\sigma_{8}=0.92\\}$ and $\\{\Omega_{\rm
m}=0.22,\sigma_{8}=0.98\\}$ cosmologies seems challenging to the generative
model. This could be potentially explained by the unconstrained stellar
feedbacks $A_{\rm SN1}$ and $A_{\rm SN2}$ which have a non-negligible effect
on the PDFs of HI and B. We defer the conditioning of the image generations on
the astrophysical parameters to future work.

| `HI` | `Mgas-HI` | `Mgas-HI-B`
---|---|---|---
$\Omega_{\rm m}$ | 0.80 (0.99) | 0.92 (0.99) | 0.96 (0.99)
$\sigma_{8}$ | -0.11 (0.92) | 0.63 (0.94) | 0.83 (0.96)

Table 1: $R^{2}$ obtained from predicting the cosmological parameters on the
images generated by the conditional generator in three different setups, which
depend on the number of channels at the input of a neural network trained in
[32]. The values in round brackets denote the performance of the ``CNN—s in
[32].

###  4.3 Extracting cosmological parameters from generated maps

We further analyze the features learnt by the GANs by extracting the
underlying cosmology of the generated maps. To this end, following [32], we
consider three different setups: predictions on neutral hydrogen maps,
predictions on instances that comprise two channels (gas density and neutral
hydrogen), and predictions on instances with three channels (gas density,
neutral hydrogen, and magnetic fields). In each scenario, we make use of the
trained network models in [32], which are convolutional neural networks
(`CNN`). To assess the performance of the regressors, we again consider the
coefficient of determination ($R^{2}$) which indicates both the ability of the
regression model to account for the variability in the predicted parameters
and the strength of the correlation between the ground truth and prediction.
It is noted that we choose the labels ($\Omega_{\rm m}$, $\sigma_{8}$) of the
test set, which is used to assess the performance of the trained `CNN`s in
[32], to condition the generation of 1,500 new instances. Depending on the
setup (`HI`, `Mgas-HI` or `Mgas-HI-B`), only the channel of interest is
selected from the new examples, e.g. for `HI` setup, only the `HI` maps from
the generated test sample is considered. The performance of the `CNN` model on
the fake images can be directly compared with its performance on the CAMELS
data reported in [32].

Each column in Table 1 corresponds to the resulting $R^{2}$ for both
$\Omega_{\rm m}$ and $\sigma_{8}$ in each scenario. On the one hand, it is
clear that, irrespective of the case, the CNN models are able to recover the
matter density with relatively good accuracy, as indicated by $R^{2}\geq 0.80$
in all setups. In the case of three channel inputs (`Mgas-HI-B`), the ability
of the `CNN` model to constrain $\Omega_{\rm m}$ from the GAN-generated images
is comparable to its performance on the CAMELS data, as evidenced by $R^{2}$ =
0.96, 0.99 (see Table 1) corresponding to the matter density constraint
achieved on the new images and CAMELS respectively. The $\Omega_{\rm m}$
constraint obtained from the generated images is still reasonably good on the
two channel (`Mgas-HI`) setup ($R^{2}=0.92$), but is relatively worse on the
generated single channel `HI` maps ($R=0.80$). This points to both how well
the deep regression model in [32] generalizes, i.e. its predictive power is
such that it is able to identify salient features of the fake maps in order to
infer the matter density, and the fact that the generative model has learnt
good representations of the CAMELS data to be able to mimic it. On the other
hand, retrieving $\sigma_{8}$ from the new images seems to be more
challenging. The `CNN` model fails to extract $\sigma_{8}$ from the fake `HI`
maps ($R^{2}=-0.11$) but its performance on the CAMELS-like data improves with
an increasing number of channels at the input, reaching $R^{2}=0.83$ on the
`Mgas-HI-B` setup. This trend (Table 1), in which the constraint on
$\sigma_{8}$ gets tighter with more information at the input, was also noticed
in [32].

##  5 Conclusion

In this work we have shown the ability of a generative model to produce
multifield images whose statistical properties are consistent with those of
the training data. We resort to generative adversarial networks (GANs), which
consist of two networks, a generator and a discriminator that are trained
adversarially. We have made use of CAMELS multifield dataset [27] and
considered three different fields obtained from CAMELS IllustrisTNG
simulations: gas density (`Mgas`), neutral hydrogen density (`HI`), and
magnetic field magnitudes (`B`). Each instance in our training set, which
comprises 10,000 examples in total, consists of three channels (`Mgas-HI-B`),
each with a resolution of $256\times 256$ pixel2. We have explored one
scenario where the model is not conditioned on any parameters and another one
in which the generated instances are constrained by the cosmological
parameters $\Omega_{\rm m}$ and $\sigma_{8}$. To assess the quality of the new
examples generated by the GAN in both scenarios, we employ probability
distribution function (PDF) of the pixel values and auto/cross-power spectrum.
We have further tested the quality of the generated images whose cosmology is
known by employing trained `CNN` models to recover their corresponding
cosmological parameters. We summarize our findings as follows:

  * •

Irrespective of the case (unconditional or conditional), the quality of the
images generated by the GAN considered in our study is comparable with that of
the training data, exhibiting all the morphological features, e.g. filaments
(Figures 3 and 6).

  * •

We have found that the average of PDF $\mu_{\rm PDF}$ and standard deviation
$\sigma_{\rm PDF}$ of the generated maps for each field are in good agreement
with the those of the data, demonstrating that the generator has encoded a
robust representation of the key features of the training data. Both the
unconditional (Figure 4) and conditional (Figure 7) models perform equally
well.

  * •

The generative model has learned the clustering properties of the training
data. For each field, we have found that the average auto/cross-power spectrum
of the new maps is consistent with that of the real maps in general, with a
discrepancy of $\leq 25\%$ up to $k\sim 10\>h/{\rm Mpc}$ in both unconditional
and conditional cases. In all scenarios, the cross-correlation signal between
channels in the GAN-generated examples is consistent with the training data on
average. This indicates that all three maps in each new instance represent the
same physical region (Figures 5 and 8).

  * •

Provided the cosmology, we compare the predicted power spectra (auto/cross)
with the real ones related to test data for each/cross field. It is found that
for each cosmology considered in the test, the auto-correlations of the CAMELS
and those of the GAN-generated data are in good agreement. However, the
average cross-correlation signals of some new images deviate from that of the
data. The unconstrained supernova feedback ($A_{\rm SN1}$, $A_{\rm SN2}$) can
potentially account for that.

  * •

For the cosmological parameter recovery test on the GAN-generated data, the
matter density is retrieved to a good accuracy in both `Mgas-HI` and `Mgas-
HI-B` setups, with $R^{2}\geq 0.92$, whereas inferring $\sigma_{8}$ is a bit
more complicated in that the combined information from the three fields, i.e.
`Mgas-HI-B` setup, is required to get the best constraint on that parameter,
corresponding to $R^{2}=0.83$. It can be inferred from this test on the
generated examples that the GAN model does not suffer from mode collapse
which, amongst other factors, makes training adversarial networks challenging.
As a whole, we argue that the capability of our generative model is very
promising.

We have only considered `Mgas`, `HI` and `B` in our analyses but the GAN model
in this study can also be trained to reproduce other fields in the CAMELS
project. The tool presented in the work can be used to help speed up map
generation in IllustrisTNG hydrodynamic simulation, for instance within the
context of exploring parameter space which is computationally expensive. At
this stage, image generation is only conditioned on cosmology. An improvement
for future work will be to further condition the generative model on
astrophysics. Provided the map topology is less sensitive to some
astrophysical parameters like the AGN feedbacks ($A_{\rm AGN1}$ and $A_{\rm
AGN2}$) as highlighted in [33] and [32], this will involve either more fine-
tuning of hyperparameters of the GAN model and possibly a deeper architecture
or making use of more sophisticated models like StyleGAN and Diffusion Model.

## Acknowledgments

SA acknowledges financial support from the South African Radio Astronomy
Observatory (SARAO). SH acknowledges support for Program number HST-HF2-51507
provided by NASA through a grant from the Space Telescope Science Institute,
which is operated by the Association of Universities for Research in
Astronomy, incorporated, under NASA contract NAS5-26555. The CAMELS project is
supported by the Simons Foundation and NSF grant AST 2108078.

## References

  * [1] M. National Academies of Sciences, Engineering et al., Pathways to Discovery in Astronomy and Astrophysics for the 2020s.  2021\.
  * [2] P. Predehl, R. Andritschke, V. Arefiev, V. Babyshkin, O. Batanov, W. Becker, H. Böhringer, A. Bogomolov, T. Boller, K. Borm, et al., The erosita x-ray telescope on srg, Astronomy & Astrophysics 647 (2021) A1.
  * [3] P. E. Dewdney, P. J. Hall, R. T. Schilizzi, and T. J. L. Lazio, The square kilometre array, Proceedings of the IEEE 97 (2009), no. 8 1482–1496.
  * [4] A. Weltman, P. Bull, S. Camera, K. Kelley, H. Padmanabhan, J. Pritchard, A. Raccanelli, S. Riemer-Sørensen, L. Shao, S. Andrianomena, et al., Fundamental physics with the square kilometre array, Publications of the Astronomical Society of Australia 37 (2020) e002.
  * [5] J. Amiaux, R. Scaramella, Y. Mellier, B. Altieri, C. Burigana, A. Da Silva, P. Gomez, J. Hoar, R. Laureijs, E. Maiorano, et al., Euclid mission: building of a reference survey, in Space Telescopes and Instrumentation 2012: Optical, Infrared, and Millimeter Wave, vol. 8442, pp. 380–390, SPIE, 2012.
  * [6] A. Aghamousa, J. Aguilar, S. Ahlen, S. Alam, L. E. Allen, C. A. Prieto, J. Annis, S. Bailey, C. Balland, O. Ballester, et al., The desi experiment part i: science, targeting, and survey design, arXiv:1611.00036 (2016).
  * [7] K. Abazajian, G. Addison, P. Adshead, Z. Ahmed, S. W. Allen, D. Alonso, M. Alvarez, A. Anderson, K. S. Arnold, C. Baccigalupi, et al., Cmb-s4 science case, reference design, and project plan, arXiv:1907.04473 (2019).
  * [8] Ž. Ivezić, S. M. Kahn, J. A. Tyson, B. Abel, E. Acosta, R. Allsman, D. Alonso, Y. AlSayyad, S. F. Anderson, J. Andrew, et al., Lsst: from science drivers to reference design and anticipated data products, The Astrophysical Journal 873 (2019), no. 2 111.
  * [9] G. Mosby Jr, B. J. Rauscher, C. Bennett, E. S. Cheng, S. Cheung, A. Cillis, D. Content, D. Cottingham, R. Foltz, J. Gygax, et al., Properties and characteristics of the nancy grace roman space telescope h4rg-10 detectors, Journal of Astronomical Telescopes, Instruments, and Systems 6 (2020), no. 4 046001–046001.
  * [10] L. Newburgh, K. Bandura, M. Bucher, T.-C. Chang, H. Chiang, J. Cliche, R. Davé, M. Dobbs, C. Clarkson, K. Ganga, et al., Hirax: a probe of dark energy and radio transients, in Ground-based and Airborne Telescopes VI, vol. 9906, pp. 2039–2049, SPIE, 2016.
  * [11] M. Amiri, K. Bandura, A. Boskovic, T. Chen, J.-F. Cliche, M. Deng, N. Denman, M. Dobbs, M. Fandino, S. Foreman, et al., An overview of chime, the canadian hydrogen intensity mapping experiment, The Astrophysical Journal Supplement Series 261 (2022), no. 2 29.
  * [12] O. Doré, J. Bock, M. Ashby, P. Capak, A. Cooray, R. de Putter, T. Eifler, N. Flagey, Y. Gong, S. Habib, et al., Cosmology with the spherex all-sky spectral survey, arXiv:1412.4872 (2014).
  * [13] M. Vogelsberger, F. Marinacci, P. Torrey, and E. Puchwein, Cosmological simulations of galaxy formation, Nature Reviews Physics 2 (Jan., 2020) 42–66, [arXiv:1909.0797].
  * [14] A. C. Rodriguez, T. Kacprzak, A. Lucchi, A. Amara, R. Sgier, J. Fluri, T. Hofmann, and A. Réfrégier, Fast cosmic web simulations with generative adversarial networks, Computational Astrophysics and Cosmology 5 (2018), no. 1 1–11.
  * [15] M. Mustafa, D. Bard, W. Bhimji, Z. Lukić, R. Al-Rfou, and J. M. Kratochvil, Cosmogan: creating high-fidelity weak lensing convergence maps using generative adversarial networks, Computational Astrophysics and Cosmology 6 (2019), no. 1 1–13.
  * [16] J. Zamudio-Fernandez, A. Okan, F. Villaescusa-Navarro, S. Bilaloglu, A. D. Cengiz, S. He, L. P. Levasseur, and S. Ho, Higan: Cosmic neutral hydrogen with generative adversarial networks, arXiv:1904.12846 (2019).
  * [17] N. Perraudin, A. Srivastava, A. Lucchi, T. Kacprzak, T. Hofmann, and A. Réfrégier, Cosmological n-body simulations: a challenge for scalable generative models, Computational Astrophysics and Cosmology 6 (2019), no. 1 1–17.
  * [18] R. M. Feder, P. Berger, and G. Stein, Nonlinear 3d cosmic web simulation with heavy-tailed generative adversarial networks, Physical Review D 102 (2020), no. 10 103504.
  * [19] V. Springel, The cosmological simulation code gadget-2, Monthly notices of the royal astronomical society 364 (2005), no. 4 1105–1134.
  * [20] N. Perraudin, S. Marcon, A. Lucchi, and T. Kacprzak, Emulation of cosmological mass maps with conditional generative adversarial networks, Frontiers in Artificial Intelligence 4 (2021) 673062.
  * [21] O. Curtis, T. G. Brainerd, and A. Hernandez, Cosmic voids in gan-generated maps of large-scale structure, Astronomy and Computing 38 (2022) 100525.
  * [22] A. Tamosiunas, H. A. Winther, K. Koyama, D. J. Bacon, R. C. Nichol, and B. Mawdsley, Investigating cosmological gan emulators using latent space interpolation, Monthly Notices of the Royal Astronomical Society 506 (2021), no. 2 3049–3067.
  * [23] I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio, Generative adversarial nets, in Advances in neural information processing systems, pp. 2672–2680, 2014.
  * [24] A. Radford, L. Metz, and S. Chintala, Unsupervised representation learning with deep convolutional generative adversarial networks, arXiv preprint arXiv:1511.06434 (2015).
  * [25] B. Liu, Y. Zhu, K. Song, and A. Elgammal, Towards faster and stabilized gan training for high-fidelity few-shot image synthesis, in International Conference on Learning Representations, 2020.
  * [26] K. He, X. Zhang, S. Ren, and J. Sun, Deep residual learning for image recognition, in Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
  * [27] F. Villaescusa-Navarro, S. Genel, D. Angles-Alcazar, L. Thiele, R. Dave, D. Narayanan, A. Nicola, Y. Li, P. Villanueva-Domingo, B. Wandelt, et al., The camels multifield data set: Learning the universe’s fundamental parameters with artificial intelligence, The Astrophysical Journal Supplement Series 259 (2022), no. 2 61.
  * [28] F. Villaescusa-Navarro, D. Anglés-Alcázar, S. Genel, D. N. Spergel, R. S. Somerville, R. Dave, A. Pillepich, L. Hernquist, D. Nelson, P. Torrey, et al., The camels project: Cosmology and astrophysics with machine-learning simulations, The Astrophysical Journal 915 (2021), no. 1 71.
  * [29] F. Villaescusa-Navarro, S. Genel, D. Anglés-Alcázar, L. A. Perez, P. Villanueva-Domingo, D. Wadekar, H. Shao, F. G. Mohammad, S. Hassan, E. Moser, et al., The camels project: public data release, arXiv:2201.01300 (2022).
  * [30] F. Villaescusa-Navarro, Pylians: Python libraries for the analysis of numerical simulations, Astrophysics Source Code Library (2018) ascl–1811.
  * [31] S. Hassan, F. Villaescusa-Navarro, B. Wandelt, D. N. Spergel, D. Anglés-Alcázar, S. Genel, M. Cranmer, G. L. Bryan, R. Davé, R. S. Somerville, et al., Hiflow: Generating diverse hi maps conditioned on cosmology using normalizing flow, arXiv:2110.02983 (2021).
  * [32] S. Andrianomena and S. Hassan, Predictive uncertainty on astrophysics recovery from multifield cosmology, Journal of Cosmology and Astroparticle Physics 2023 (2023), no. 06 051.
  * [33] F. Villaescusa-Navarro, D. Anglés-Alcázar, S. Genel, D. N. Spergel, Y. Li, B. Wandelt, A. Nicola, L. Thiele, S. Hassan, J. M. Z. Matilla, et al., Multifield cosmology with artificial intelligence, arxiv:2109.09747 (2021).