Recovering the phase and amplitude of X-ray FEL pulses using neural networks and differentiable models