Constructing custom thermodynamics using deep learning