-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reviewing GAN basics, VisionDataModule, MNISTDataModule, CIFAR10DataModule #843
Merged
Merged
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d1d7745
removing deprecated argument refresh rate to progressbar
shivammehta25 a9161a9
re structuring test folder and adding generator tests
shivammehta25 857218d
typo fix
shivammehta25 7c85262
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 10886c3
Adding discriminator unit test
shivammehta25 e51b16f
merging pre-commit
shivammehta25 3807c56
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6f2e848
running pre-commit locally
shivammehta25 bac6e2c
Merge branch 'gan_review' of github.com:shivammehta007/lightning-bolt…
shivammehta25 2aae0d1
overriding the getters and setters of {train/val/test}_transforms in …
shivammehta25 7879aa2
Adding MNISTDataModule, CIFAR10DataModule, VisionDataModule with upda…
shivammehta25 72beca6
filtering num worker exception
shivammehta25 e8d8f22
Merge branch 'master' of github.com:Lightning-AI/lightning-bolts into…
shivammehta25 6422e23
Fixing mypy errors and adding new transforms to the class instances
shivammehta25 bace5a4
fixing test's accelerator
shivammehta25 3c9415b
removing further mypy errors
shivammehta25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
import torch | ||
from pytorch_lightning import seed_everything | ||
|
||
from pl_bolts.models.gans.basic.components import Discriminator, Generator | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"latent_dim, img_shape", | ||
[ | ||
pytest.param(100, (3, 28, 28), id="100-multichannel"), | ||
pytest.param(100, (1, 28, 28), id="100-singlechannel"), | ||
], | ||
) | ||
def test_generator(latent_dim, img_shape): | ||
batch_dim = 10 | ||
seed_everything() | ||
generator = Generator(latent_dim=latent_dim, img_shape=img_shape) | ||
noise = torch.randn(batch_dim, latent_dim) | ||
samples = generator(noise) | ||
assert samples.shape == (batch_dim, *img_shape) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"img_shape", | ||
[ | ||
pytest.param((3, 28, 28), id="discriminator-multichannel"), | ||
pytest.param((1, 28, 28), id="discriminator-singlechannel"), | ||
], | ||
) | ||
def test_discriminator(img_shape): | ||
batch_dim = 10 | ||
seed_everything() | ||
discriminator = Discriminator(img_shape=img_shape) | ||
samples = torch.randn(batch_dim, *img_shape) | ||
real_or_fake = discriminator(samples) | ||
assert real_or_fake.shape == (batch_dim, 1) | ||
assert (torch.clamp(real_or_fake.clone(), 0, 1) == real_or_fake).all() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this test case, as it is very heavy dataset