将 pytorch lightning 与 vanilla pytorch 混合

Mix pytorch lightning with vanilla pytorch

我正在进行元学习研究,并且正在使用 learn2learn 提供的 MAML 优化。然而,作为基线之一,我想测试一种非元学习方法,即传统的训练+测试。

Due to the lightning's internal usage of optimizer it seems that it is difficult to make the MAML work with learn2learn in lightning,所以我不能在我的元学习设置中使用闪电,但是对于我的基线,我真的很喜欢使用闪电,因为它提供了许多方便的功能,比如 deepspeed 或 ddp盒子.

这是我的问题,除了设置两个单独的 folders/repos,我如何将 vanilia pytorch (learn2learn) 与 pytorch lightning (baseline) 混合使用?最佳做法是什么?

谢谢!

决定回答我的问题。所以我最终使用了 torch lightning 的手动优化,这样我就可以自定义 optimization step。这将使两种方法使用相同的框架,我认为这比维护 2 个单独的 repos 更好。