  Using an end-to-end differentiable implementation of the Kohn-Sham
self-consistent field equations, we obtain an accurate neural network-based
exchange and correlation (XC) functional of the electronic density. The
functional is optimized using information on both energy and density while
exact constraints are enforced through an appropriate neural network
architecture. We evaluate our model against different families of XC
approximations and show that, for non-empirical functionals, there is a strong
linear correlation between energy and density errors. We use this correlation
to define a novel XC functional quality metric that includes both energy and
density errors, leading to a new, improved way to rank different
approximations. Judged by this metric, our machine-learned functional
significantly outperforms those within the same rung of approximations.
