The Boussinesq and Camassa–Holm equations are, respectively, used to describe the bidirectional and unidirectional motions of small-amplitude waves on shallow water surfaces, but their wave dynamics remain a challenge for almost all conventional numerical methods. In this paper, we use physics-informed neural networks (PINNs), a mesh-free deep learning method, to accurately predict the soliton (peakon) interaction or rogue wave behaviours of both equations with only a few initial and boundary data, providing a method for solving certain numerically unstable fluid systems or extreme wave solutions of regular fluid systems. It is revealed that by decomposing both of the equations into lower-order coupled systems, one can obtain higher-precision wave behaviours, especially for the Camassa–Holm equation. To retrieve certain unknown hydraulic parameters based on the observed wave data, e.g. the water depth, we use a multiple PINN method and stably identify the dynamic parameters in the Boussinesq equation through the association of localized soliton and rogue wave solutions. Furthermore, we compare the PINNs with conventional high-precision time-splitting Fourier spectral (TSFS) method and find that to achieve the same split feature of the Y-shapedsoliton of the Boussinesq equation, PINNs require only one-third of the initial and boundary data of the TSFS method.