  Accurately learning the temporal behavior of dynamical systems requires
models with well-chosen learning biases. Recent innovations embed the
Hamiltonian and Lagrangian formalisms into neural networks and demonstrate a
significant improvement over other approaches in predicting trajectories of
physical systems. These methods generally tackle autonomous systems that depend
implicitly on time or systems for which a control signal is known apriori.
Despite this success, many real world dynamical systems are non-autonomous,
driven by time-dependent forces and experience energy dissipation. In this
study, we address the challenge of learning from such non-autonomous systems by
embedding the port-Hamiltonian formalism into neural networks, a versatile
framework that can capture energy dissipation and time-dependent control
forces. We show that the proposed \emph{port-Hamiltonian neural network} can
efficiently learn the dynamics of nonlinear physical systems of practical
interest and accurately recover the underlying stationary Hamiltonian,
time-dependent force, and dissipative coefficient. A promising outcome of our
network is its ability to learn and predict chaotic systems such as the Duffing
equation, for which the trajectories are typically hard to learn.
