Machine learning implicit solvation for molecular dynamics