Shortcuts

Self-supervised learning Transforms

These transforms are used in various self-supervised learning approaches.


CPC transforms

Transforms used for CPC

CIFAR-10 Train (c)

class pl_bolts.models.self_supervised.cpc.transforms.CPCTrainTransformsCIFAR10(patch_size=8, overlap=4)[source]

Bases: object

Transforms used for CPC:

Parameters
  • patch_size – size of patches when cutting up the image into overlapping patches

  • overlap – how much to overlap patches

Transforms:

random_flip
img_jitter
col_jitter
rnd_gray
transforms.ToTensor()
normalize
Patchify(patch_size=patch_size, overlap_size=patch_size // 2)

Example:

# in a regular dataset
CIFAR10(..., transforms=CPCTrainTransformsCIFAR10())

# in a DataModule
module = CIFAR10DataModule(PATH)
train_loader = module.train_dataloader(batch_size=32, transforms=CPCTrainTransformsCIFAR10())
__call__(inp)[source]

Call self as a function.

CIFAR-10 Eval (c)

class pl_bolts.models.self_supervised.cpc.transforms.CPCEvalTransformsCIFAR10(patch_size=8, overlap=4)[source]

Bases: object

Transforms used for CPC:

Parameters
  • patch_size – size of patches when cutting up the image into overlapping patches

  • overlap – how much to overlap patches

Transforms:

random_flip
transforms.ToTensor()
normalize
Patchify(patch_size=patch_size, overlap_size=overlap)

Example:

# in a regular dataset
CIFAR10(..., transforms=CPCEvalTransformsCIFAR10())

# in a DataModule
module = CIFAR10DataModule(PATH)
train_loader = module.train_dataloader(batch_size=32, transforms=CPCEvalTransformsCIFAR10())
__call__(inp)[source]

Call self as a function.

Imagenet Train (c)

class pl_bolts.models.self_supervised.cpc.transforms.CPCTrainTransformsImageNet128(patch_size=32, overlap=16)[source]

Bases: object

Transforms used for CPC:

Parameters
  • patch_size – size of patches when cutting up the image into overlapping patches

  • overlap – how much to overlap patches

Transforms:

random_flip
transforms.ToTensor()
normalize
Patchify(patch_size=patch_size, overlap_size=patch_size // 2)

Example:

# in a regular dataset
Imagenet(..., transforms=CPCTrainTransformsImageNet128())

# in a DataModule
module = ImagenetDataModule(PATH)
train_loader = module.train_dataloader(batch_size=32, transforms=CPCTrainTransformsImageNet128())
__call__(inp)[source]

Call self as a function.

Imagenet Eval (c)

class pl_bolts.models.self_supervised.cpc.transforms.CPCEvalTransformsImageNet128(patch_size=32, overlap=16)[source]

Bases: object

Transforms used for CPC:

Parameters
  • patch_size – size of patches when cutting up the image into overlapping patches

  • overlap – how much to overlap patches

Transforms:

random_flip
transforms.ToTensor()
normalize
Patchify(patch_size=patch_size, overlap_size=patch_size // 2)

Example:

# in a regular dataset
Imagenet(..., transforms=CPCEvalTransformsImageNet128())

# in a DataModule
module = ImagenetDataModule(PATH)
train_loader = module.train_dataloader(batch_size=32, transforms=CPCEvalTransformsImageNet128())
__call__(inp)[source]

Call self as a function.

STL-10 Train (c)

class pl_bolts.models.self_supervised.cpc.transforms.CPCTrainTransformsSTL10(patch_size=16, overlap=8)[source]

Bases: object

Transforms used for CPC:

Parameters
  • patch_size – size of patches when cutting up the image into overlapping patches

  • overlap – how much to overlap patches

Transforms:

random_flip
img_jitter
col_jitter
rnd_gray
transforms.ToTensor()
normalize
Patchify(patch_size=patch_size, overlap_size=patch_size // 2)

Example:

# in a regular dataset
STL10(..., transforms=CPCTrainTransformsSTL10())

# in a DataModule
module = STL10DataModule(PATH)
train_loader = module.train_dataloader(batch_size=32, transforms=CPCTrainTransformsSTL10())
__call__(inp)[source]

Call self as a function.

STL-10 Eval (c)

class pl_bolts.models.self_supervised.cpc.transforms.CPCEvalTransformsSTL10(patch_size=16, overlap=8)[source]

Bases: object

Transforms used for CPC:

Parameters
  • patch_size – size of patches when cutting up the image into overlapping patches

  • overlap – how much to overlap patches

Transforms:

random_flip
transforms.ToTensor()
normalize
Patchify(patch_size=patch_size, overlap_size=patch_size // 2)

Example:

# in a regular dataset
STL10(..., transforms=CPCEvalTransformsSTL10())

# in a DataModule
module = STL10DataModule(PATH)
train_loader = module.train_dataloader(batch_size=32, transforms=CPCEvalTransformsSTL10())
__call__(inp)[source]

Call self as a function.


AMDIM transforms

Transforms used for AMDIM

CIFAR-10 Train (a)

class pl_bolts.models.self_supervised.amdim.transforms.AMDIMTrainTransformsCIFAR10[source]

Bases: object

Transforms applied to AMDIM

Transforms:

img_jitter,
col_jitter,
rnd_gray,
transforms.ToTensor(),
normalize

Example:

x = torch.rand(5, 3, 32, 32)

transform = AMDIMTrainTransformsCIFAR10()
(view1, view2) = transform(x)
__call__(inp)[source]

Call self as a function.

CIFAR-10 Eval (a)

class pl_bolts.models.self_supervised.amdim.transforms.AMDIMEvalTransformsCIFAR10[source]

Bases: object

Transforms applied to AMDIM

Transforms:

transforms.ToTensor(),
normalize

Example:

x = torch.rand(5, 3, 32, 32)

transform = AMDIMEvalTransformsCIFAR10()
(view1, view2) = transform(x)
__call__(inp)[source]

Call self as a function.

Imagenet Train (a)

class pl_bolts.models.self_supervised.amdim.transforms.AMDIMTrainTransformsImageNet128(height=128)[source]

Bases: object

Transforms applied to AMDIM

Transforms:

img_jitter,
col_jitter,
rnd_gray,
transforms.ToTensor(),
normalize

Example:

x = torch.rand(5, 3, 128, 128)

transform = AMDIMTrainTransformsSTL10()
(view1, view2) = transform(x)
__call__(inp)[source]

Call self as a function.

Imagenet Eval (a)

class pl_bolts.models.self_supervised.amdim.transforms.AMDIMEvalTransformsImageNet128(height=128)[source]

Bases: object

Transforms applied to AMDIM

Transforms:

transforms.Resize(height + 6, interpolation=3),
transforms.CenterCrop(height),
transforms.ToTensor(),
normalize

Example:

x = torch.rand(5, 3, 128, 128)

transform = AMDIMEvalTransformsImageNet128()
view1 = transform(x)
__call__(inp)[source]

Call self as a function.

STL-10 Train (a)

class pl_bolts.models.self_supervised.amdim.transforms.AMDIMTrainTransformsSTL10(height=64)[source]

Bases: object

Transforms applied to AMDIM

Transforms:

img_jitter,
col_jitter,
rnd_gray,
transforms.ToTensor(),
normalize

Example:

x = torch.rand(5, 3, 64, 64)

transform = AMDIMTrainTransformsSTL10()
(view1, view2) = transform(x)
__call__(inp)[source]

Call self as a function.

STL-10 Eval (a)

class pl_bolts.models.self_supervised.amdim.transforms.AMDIMEvalTransformsSTL10(height=64)[source]

Bases: object

Transforms applied to AMDIM

Transforms:

transforms.Resize(height + 6, interpolation=3),
transforms.CenterCrop(height),
transforms.ToTensor(),
normalize

Example:

x = torch.rand(5, 3, 64, 64)

transform = AMDIMTrainTransformsSTL10()
view1 = transform(x)
__call__(inp)[source]

Call self as a function.


MOCO V2 transforms

Transforms used for MOCO V2

CIFAR-10 Train (m2)

class pl_bolts.models.self_supervised.moco.transforms.Moco2TrainCIFAR10Transforms(height=32)[source]

Bases: object

Moco 2 augmentation: https://arxiv.org/pdf/2003.04297.pdf

__call__(inp)[source]

Call self as a function.

CIFAR-10 Eval (m2)

class pl_bolts.models.self_supervised.moco.transforms.Moco2EvalCIFAR10Transforms(height=32)[source]

Bases: object

Moco 2 augmentation: https://arxiv.org/pdf/2003.04297.pdf

__call__(inp)[source]

Call self as a function.

Imagenet Train (m2)

class pl_bolts.models.self_supervised.moco.transforms.Moco2TrainSTL10Transforms(height=64)[source]

Bases: object

Moco 2 augmentation: https://arxiv.org/pdf/2003.04297.pdf

__call__(inp)[source]

Call self as a function.

Imagenet Eval (m2)

class pl_bolts.models.self_supervised.moco.transforms.Moco2EvalSTL10Transforms(height=64)[source]

Bases: object

Moco 2 augmentation: https://arxiv.org/pdf/2003.04297.pdf

__call__(inp)[source]

Call self as a function.

STL-10 Train (m2)

class pl_bolts.models.self_supervised.moco.transforms.Moco2TrainImagenetTransforms(height=128)[source]

Bases: object

Moco 2 augmentation: https://arxiv.org/pdf/2003.04297.pdf

__call__(inp)[source]

Call self as a function.

STL-10 Eval (m2)

class pl_bolts.models.self_supervised.moco.transforms.Moco2EvalImagenetTransforms(height=128)[source]

Bases: object

Moco 2 augmentation: https://arxiv.org/pdf/2003.04297.pdf

__call__(inp)[source]

Call self as a function.


SimCLR transforms

Transforms used for SimCLR

Train (sc)

class pl_bolts.models.self_supervised.simclr.simclr_transforms.SimCLRTrainDataTransform(input_height, s=1)[source]

Bases: object

Transforms for SimCLR

Transform:

RandomResizedCrop(size=self.input_height)
RandomHorizontalFlip()
RandomApply([color_jitter], p=0.8)
RandomGrayscale(p=0.2)
GaussianBlur(kernel_size=int(0.1 * self.input_height))
transforms.ToTensor()

Example:

from pl_bolts.models.self_supervised.simclr.transforms import SimCLRTrainDataTransform

transform = SimCLRTrainDataTransform(input_height=32)
x = sample()
(xi, xj) = transform(x)
__call__(sample)[source]

Call self as a function.

Eval (sc)

class pl_bolts.models.self_supervised.simclr.simclr_transforms.SimCLREvalDataTransform(input_height, s=1)[source]

Bases: object

Transforms for SimCLR

Transform:

Resize(input_height + 10, interpolation=3)
transforms.CenterCrop(input_height),
transforms.ToTensor()

Example:

from pl_bolts.models.self_supervised.simclr.transforms import SimCLREvalDataTransform

transform = SimCLREvalDataTransform(input_height=32)
x = sample()
(xi, xj) = transform(x)
__call__(sample)[source]

Call self as a function.

Read the Docs v: 0.2.1
Versions
latest
stable
0.2.1
0.2.0
0.1.1
0.1.0
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.