The new generation of galaxy surveys will provide unprecedented data allowing us to test gravity at cosmological scales. A robust cosmological analysis of the large-scale structure demands exploiting the nonlinear information encoded in the cosmic web. Machine Learning techniques provide such tools, however, do not provide a priori assessment of uncertainties. This study aims at extracting cosmological parameters from modified gravity (MG) simulations through deep neural networks endowed with uncertainty estimations. We implement Bayesian neural networks (BNNs) with an enriched approximate posterior distribution considering two cases: one with a single Bayesian last layer (BLL), and another one with Bayesian layers at all levels (FullB). We train both BNNs with real-space density fields and power-spectra from a suite of 2000 dark matter only particle mesh $N$-body simulations including modified gravity models relying on MG-PICOLA covering 256 $h^{-1}$ Mpc side cubical volumes with 128$^3$ particles. BNNs excel in accurately predicting parameters for $\Omega_m$ and $\sigma_8$ and their respective correlation with the MG parameter. We find out that BNNs yield well-calibrated uncertainty estimates overcoming the over- and under-estimation issues in traditional neural networks. We observe that the presence of MG parameter leads to a significant degeneracy with $\sigma_8$ being one of the possible explanations of the poor MG predictions. Ignoring MG, we obtain a deviation of the relative errors in $\Omega_m$ and $\sigma_8$ by at least $30\%$. Moreover, we report consistent results from the density field and power spectra analysis, and comparable results between BLL and FullB experiments which permits us to save computing time by a factor of two. This work contributes in setting the path to extract cosmological parameters from complete small cosmic volumes towards the highly nonlinear regime.
I present a new approach to recover the primordial density fluctuations and the cosmic web structure underlying a galaxy distribution. The method is based on sampling Gaussian fields which are compatible with a galaxy distribution and a structure formation model. This is achieved by splitting the inversion problem into two Gibbs-sampling steps: the first being a Gaussianisation step transforming a distribution of point sources at Lagrangian positions -which are not a priori given- into a linear alias-free Gaussian field. This step is based on Hamiltonian sampling with a Gaussian-Poisson model. The second step consists on a likelihood comparison in which the set of matter tracers at the initial conditions is constrained on the galaxy distribution and the assumed structure formation model. For computational reasons second order Lagrangian Perturbation Theory is used. However, the presented approach is flexible to adopt any structure formation model. A semi-analytic halo-model based galaxy mock catalog is taken to demonstrate that the recovered initial conditions are closely unbiased with respect to the actual ones from the corresponding N-body simulation down to scales of a ~ 5 Mpc/h. The cross-correlation between them shows a substantial gain of information, being at k ~ 0.3 h/Mpc more than doubled. In addition the initial conditions are extremely well Gaussian distributed and the power-spectra follow the shape of the linear power-spectrum being very close to the actual one from the simulation down to scales of k ~ 1 h/Mpc.