The Dark Matter Particle Explorer (DAMPE) is a space-borne particle detector and cosmic ray observatory in operation since 2015, designed to probe electrons and gamma rays from a few GeV to 10 TeV energy, as well as cosmic protons and nuclei up to 100 TeV. Among the main scientific objectives is the precise measurement of the cosmic electron+positron flux, which due to the very large proton background in orbit requires a powerful particle identification method. In the past decade, the field of machine learning has provided us the needed tools. This paper presents a neural network based approach to cosmic electron identification and proton rejection and showcases its performances based on simulated Monte Carlo data. The neural network reaches significantly lower background than the classical, cut-based method for the same detection efficiency, especially at highest energies. A good matching between simulations and real data completes the picture.