Lightning-AI / tutorials

Collection of Pytorch lightning tutorial form as rich scripts automatically transformed to ipython notebooks.
https://lightning-ai.github.io/tutorials
Apache License 2.0
290 stars 83 forks source link

Repeated calls to generator and discriminator's forward in GAN tutorial #306

Closed jhauret closed 3 months ago

jhauret commented 10 months ago

📚 Documentation

In the training_step of the GAN(L.LightningModule) the generator and discriminator forward are called several times on the same input. Obviously this slows down the training because more computation is required. I wonder if we could just reuse the results of the first call. After all, the toggle_optimiser/untoggle_optimiser functions should make it safe, right?

For the generator:

For the discriminator:

cc @borda

jhauret commented 10 months ago

Still on the basic GAN tutorial, I spotted a few more track of improvements:

I am willing to implement and submit a PR if you find this helpful :smiley:

Borda commented 4 months ago

Hello @jhauret, I apologize for the late reply, it was not in good shape until a few days ago, so would you be interested in sending PR with the fix? :rabbit:

jhauret commented 4 months ago

Hi @Borda, I hope you're feeling better now. Yes, I'll do it the first week of August!