A machine-learning-based exchange-correlation functional is proposed for general-purpose density functional theory calculations. It is built upon the long-range-corrected Becke-Lee-Yang-Parr (LC-BLYP) functional, along with an embedded neural network which determines the value of the range-separation parameter μ for every individual system. The structure and the weights of the neural network are optimized with a reference data set containing 368 highly accurate thermochemical and kinetic energies. The newly developed functional (LC-BLYP-NN) achieves a balanced performance for a variety of energetic properties investigated. It largely improves the accuracy of atomization energies and heats of formation on which the original LC-BLYP with a fixed μ performs rather poorly. Meanwhile, it yields a similar or slightly compromised accuracy for ionization potentials, electron affinities, and reaction barriers, for which the original LC-BLYP works reasonably well. This work clearly highlights the potential usefulness of machine-learning techniques for improving density functional calculations.