Magnetic soft robots have attracted growing interest due to their unique advantages in terms of untethered actuation and excellent controllability. However, finding the required magnetization patterns or magnetic fields to achieve the desired functions of these robots is quite challenging in many cases. No unified framework for design has been proposed yet, and existing methods mainly rely on manual heuristics, which are hard to satisfy the high complexity level of the desired robotic motion. Here, we develop an intelligent method to solve the related inverse-design problems, implemented by introducing a novel simulation platform for magnetic soft robots based on Cosserat rod models and a deep reinforcement learning framework based on TD3. We demonstrate that magnetic soft robots with different magnetization patterns can learn to move without human guidance in simulations, and effective magnetic fields can be autonomously generated that can then be applied directly to real magnetic soft robots in an open-loop way.