Skip to content

Commit

Permalink
fix MNIST download (#1044)
Browse files Browse the repository at this point in the history
* fix MNIST download

* simple
  • Loading branch information
williamFalcon committed Mar 4, 2020
1 parent e586ed4 commit 165b9fb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
# TODO: this should be discussed and moved out of this package
raise ImportError('Missing test-tube package.')

from pytorch_lightning.core.decorators import data_loader
from pytorch_lightning.core.lightning import LightningModule

# TODO: remove after getting own MNIST
# TEMPORAL FIX, https://github.com/pytorch/vision/issues/1938
import urllib.request
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib.request.install_opener(opener)


class TestingMNIST(MNIST):

Expand Down Expand Up @@ -54,8 +60,8 @@ def configure_optimizers(self):
return torch.optim.Adam(self.parameters(), lr=0.02)

def train_dataloader(self):
return DataLoader(MNIST(os.getcwd(), train=True, download=True,
transform=transforms.ToTensor()), batch_size=32)
return DataLoader(TestingMNIST(os.getcwd(), train=True, download=True,
transform=transforms.ToTensor()), batch_size=32)


class TestModelBase(LightningModule):
Expand Down

0 comments on commit 165b9fb

Please sign in to comment.