Stiffness-aware neural network for learning Hamiltonian systems