Ejemplo n.º 1
0
 def get_transforms(stage: str = None, mode: str = None):
     """
     @TODO: Docs. Contribution is welcome
     """
     return Compose([ToTensor(), Normalize((0.1307, ), (0.3081, ))])
Ejemplo n.º 2
0
if os.getenv("USE_DDP", "0") != "0":
    sys.exit()

# # Data

# In[ ]:

import collections
import torch

from catalyst.contrib.data.dataset import MNIST, ToTensor, Compose, Normalize

bs = 32
num_workers = 0

data_transform = Compose([ToTensor(), Normalize((0.1307, ), (0.3081, ))])

loaders = collections.OrderedDict()

trainset = MNIST("./data",
                 train=False,
                 download=True,
                 transform=data_transform)
trainloader = torch.utils.data.DataLoader(trainset,
                                          batch_size=bs,
                                          shuffle=True,
                                          num_workers=num_workers)

testset = MNIST("./data", train=False, download=True, transform=data_transform)
testloader = torch.utils.data.DataLoader(testset,
                                         batch_size=bs,
Ejemplo n.º 3
0
    )

    loaders["train"] = train_loader
    loaders["valid"] = valid_loader

    return loaders


data_transform = Compose([
    Augmentor(
        dict_key="features",
        augment_fn=lambda x: torch.from_numpy(x.copy().astype(np.float32) /
                                              255.0).unsqueeze_(0),
    ),
    Augmentor(
        dict_key="features",
        augment_fn=Normalize((0.5, ), (0.5, )),
    ),
    Augmentor(
        dict_key="targets",
        augment_fn=lambda x: torch.from_numpy(x.copy().astype(np.float32) /
                                              255.0).unsqueeze_(0),
    ),
])

loaders = get_loaders(data_transform)

# # Model

# In[ ]:

from catalyst.contrib.models.cv import Unet