Soft-constrained neural networks for nonparametric density estimation