Actually had that debate with a friend of mine who was tired of working as a full-stack web dev and found himself a new job in the field of machine learning after thinking of going back to uni for a phd. So everything is possible when you can code I guess!
Totally agree with @st1x7, you should be learning by doing at this point. There is enough material online to work with especially in the field of AI and machine learning and maybe you could also learn on the job like my friend.
All the best with your decision!