Open 00krishna opened 3 years ago
@00krishna Thank you for using the repo!
If you don't want to create a datamodule then simply don't do it - it should be easy to remove it from the pipeline and delete its configs.
You could also consider replacing the datamodule config with dataloader config and pass it as train_dataloaders
:
trainer.fit(model, train_dataloaders=train_loader)
@ashleve Thanks for the suggestions. Yes, I was actually able to get this working :). I found a different repo that has example code using RL with pytorch lightning. So that file had the dataloader and model in separate files. And I was able to adapt that code to work inside of the framework that you developed :). So perfecto. It was not too difficult.
Thanks again for creating and sharing the template. It just make it so much easier to work on the model itself, instead of writing all that code for hyperparameter tuning, and managing experiments, and everything else. Now I can focus on getting data into the system and then quickly testing different model variations.
If you like I can share the code with you on adapting your template to the RL algorithms I found. So far I just have the DQN model in there--that was my test case. But today I will adapt a few more algorithm now that DQN works. Let me know.
If you like I can share the code with you on adapting your template to the RL algorithms I found.
Sure, if you want you can post it here for others for reference :)
I personally prefer using Ray instead of lightning when doing RL, since it's easy to scale it to multiple concurrent environments, but as for now I don't really have any example of using Ray with the template
@00krishna Can you share the code?
Hello @ZeguanXiao which code would you like me to share? I have been using this template for most of my usual NN code, like image segmentation, text stuff etc. For reinforcement learning I have been looking into the Ray
library as @ashleve said. There are now some very nice connectors between Ray
and Pytorch Lightning
, so I will further adjust this template to leverage those connections for RL.
Hello @ZeguanXiao which code would you like me to share?
Hi, I mean your RL code adapted from this template. I thought you have finished an RL flavor of this template. You can share it if it's convenient for you.
@ZeguanXiao yeah, I can do that. I still have a bit of work to do on the template, but it is not that bad. There is a plugin for the Ray/RLlib library and pytorch lightning. So that should make it pretty easy to connect the two libraries. I have some simple demo code for a custom environment that I can include, just to get things started. It will probably take a week, but I can post the link here when it is set.
@00krishna can I ask for your template? Thanks
This is a nice example (Lightning + Hydra + RL): https://github.com/belerico/lightning-rl
Hello @ashleve thanks so much for creating this template. I am finding it so helpful in a lot of my development. I can't thank you enough.
I had a question about adapting this template for Reinforcement learning workflows. I was trying to port some code from a Pytorch Lightning DQN demo to your template, and just had a couple of questions. Here is a link to the PL docs with this code. I pasted the code below for your convenience as well.
One thing I noticed in this code is that the Dataloader is not a separate file, as in the template. And since the
train.py
function will have a function with something liketrainer.fit(model=model, datamodule=datamodule)
, this could cause a problem. So I have to think about how to adapt the code to fit into the current template. I have to also think about how to handle the cpu/gpudevice
calls in this code, since some of the classes are notnn.Modules
so PL might not be able to control where the tensors are created like in other PL modules. etc.I was just wondering if you had any suggestions about how to port this code. I imagine I would need to create a separate file for the Datamodule and carry on like any other model. But if you can think of an easier way that I might not have considered then please suggest away.
Here is the full code, in case it is more convenient to look at it here rather than going to the PL repo.