Spatial Mode Correction of Single Photons using Machine Learning