Machine learning is transforming the scientiﬁc landscape, with the use of advanced algorithmic tools in data analysis yielding new insights into many areas of fundamental and applied science. Photonics is no exception, and machine-learning methods have been applied in a variety of ways to optimise and analyse the output of optical ﬁbre systems. In parallel with these developments, pulse shaping based on nonlinear propagation eﬀects in optical ﬁbres has developed into a remarkable tool to tailor the spectral and temporal content of light signals, leading to the generation of a large variety of optical waveforms. Yet, due to the typically large number of degrees of freedom involved, optimising nonlinear pulse shaping for application purposes may require extensive numerical simulations based on the integration of the nonlinear Schr¨odinger equation (NLSE) or its extensions. This is computationally demanding and potentially creates a severe bottleneck in using numerical techniques to design and optimise experiments in real time. Here, we present a solution to this problem using a supervised machine-learning model based on a feedforward neural network (NN) to solve both the direct and inverse problems relating to pulse shaping, bypassing the need for numerical solution of the governing propagation model. Speciﬁcally, we show how the network accurately predicts the temporal and spectral intensity proﬁles of the pulses that form upon nonlinear propagation in ﬁbres with both anomalous and normal dispersion. Further, we demonstrate the ability of the NN to determine the nonlinear propagation properties from the pulses observed at the ﬁbre output, and to classify the output pulses according to the initial pulse shape. We also expand our analysis to the case of pulse propagation in the presence of distributed gain or loss, with a special focus on the generation of self-similar parabolic pulses . The results show that the network is able to accommodate to and maintain high accuracy for a wide dynamic range of system parameters. Although demonstrated here in a ﬁbre optics context, the principle of using NN architectures to solve wave equation-based inverse problems is expected to apply to many physical systems.