The optical depth to reionization,
τ, is the least constrained parameter of the cosmological
ΛCDM model. To date, its most precise value is inferred from large-scale polarized CMB power spectra from the
Planck High-Frequency Instrument (HFI). These maps are known to contain significant contamination by residual non-Gaussian systematic effects, which are hard to model analytically. Therefore, robust constraints on
τ are currently obtained through an empirical cross-spectrum likelihood built from simulations. In this paper, we present a likelihood-free inference of
τ from polarized
Planck HFI maps which, for the first time, is fully based on neural networks (NNs). NNs have the advantage of not requiring an analytical description of the data and can be trained on state-of-the-art simulations, combining information from multiple channels. By using Gaussian sky simulations and
Planck SRoll2 simulations, including CMB, noise, and residual instrumental systematic effects, we train, test and validate NN models considering different setups. We infer the value of
τ directly from
Q and
U maps at
∼4∘ pixel resolution, without computing power spectra. On
Planck data, we obtain
τNN=0.058±0.008, compatible with current EE cross-spectrum results but with a
∼30% larger uncertainty, which can be assigned to the inherent non-optimality of our estimator and to the retraining procedure applied to avoid biases. While this paper does not improve on current cosmological constraints, our analysis represents a first robust application of NN-based inference on real data and highlights its potential as a promising tool for complementary analysis of near-future CMB experiments, also in view of the ongoing challenge to achieve a detection of primordial gravitational waves.