Structure-Preserving Physics-Informed Neural Networks With Energy or Lyapunov Structure