Dark matter cannot be observed directly, but its weak gravitational lensing slightly distorts the apparent shapes of background galaxies, making weak lensing one of the most promising probes of cosmology. Several observational studies have measured the effect, and there are currently running [1,2], and planned efforts [3,4] to provide even larger, and higher resolution weak lensing maps. Due to nonlinearities on small scales, the traditional analysis with two-point statistics does not fully capture all the underlying information [5]. Multiple inference methods were proposed to extract more details based on higher order statistics [6, 7], peak statistics [8][9][10][11][12][13], Minkowski functionals [14-16] and recently convolutional neural networks (CNN) [17,18]. Here we present an improved convolutional neural network that gives significantly better estimates of Ω m and σ 8 cosmological parameters from simulated convergence maps than the state of art methods and also is free of systematic bias. We show that the network exploits information in the gradients around peaks, and with this insight, we construct a new, easy-to-understand, and robust peak counting algorithm based on the 'steepness' of peaks, instead of their heights. The proposed scheme is even more accurate than the neural network on high-resolution noiseless maps. With shape noise and lower resolution its relative advantage deteriorates, but it remains more accurate than peak counting.Following the idea and using the simulation data from a recent study [18] we created an improved convolutional neural network (CNN) architecture (see details in the Methods) which is able to recover cosmological parameters more accurately from simulated weak lensing maps. The input of the network is a set of mock convergence (κ) maps generated by ray-tracing n-body simulations with 96 different values for the matter density Ω m and the scale of the initial perturbations normalized at the late Universe, σ 8 (see [18] and [19] for details of the weak lensing map generation), the outputs of the network were the predicted cosmological parameters. The modifications of the CNN mostly consisted of adding further activations, increasing the number of filters, and introducing a regular block structure, following successful computer vision models [20,21].