  Hybrid machine learning based on Hamiltonian formulations has recently been
successfully demonstrated for simple mechanical systems, both energy conserving
and not energy conserving. We introduce a pseudo-Hamiltonian formulation that
is a generalization of the Hamiltonian formulation via the port-Hamiltonian
formulation, and show that pseudo-Hamiltonian neural network models can be used
to learn external forces acting on a system. We argue that this property is
particularly useful when the external forces are state dependent, in which case
it is the pseudo-Hamiltonian structure that facilitates the separation of
internal and external forces. Numerical results are provided for a forced and
damped mass-spring system and a tank system of higher complexity, and a
symmetric fourth-order integration scheme is introduced for improved training
on sparse and noisy data.
