homura.vision.models package

Submodules

homura.vision.models.cifar_resnet module

class homura.vision.models.cifar_resnet.BasicBlock(in_planes, planes, stride, groups, width_per_group, norm, act)[source]

Bases: torch.nn.modules.module.Module

expansion = 1
forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters

x (torch.Tensor) –

Return type

torch.Tensor

training: bool
class homura.vision.models.cifar_resnet.Bottleneck(in_planes, planes, stride, groups, width_per_group, norm, act)[source]

Bases: torch.nn.modules.module.Module

expansion = 4
forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters

x (torch.Tensor) –

Return type

torch.Tensor

training: bool
class homura.vision.models.cifar_resnet.PreactBasicBlock(in_planes, planes, stride, groups, width_per_group, norm, act)[source]

Bases: homura.vision.models.cifar_resnet.BasicBlock

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters

x (torch.Tensor) –

Return type

torch.Tensor

training: bool
class homura.vision.models.cifar_resnet.ResNet(block, num_classes, layer_depth, width=16, widen_factor=1, in_channels=3, groups=1, width_per_group=16, norm=<class 'torch.nn.modules.batchnorm.BatchNorm2d'>, act=ReLU(), preact=False, final_pool=AdaptiveAvgPool2d(output_size=1), initializer=None)[source]

Bases: torch.nn.modules.module.Module

ResNet for CIFAR data. For ImageNet classification, use torchvision’s.

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class homura.vision.models.cifar_resnet.SEBasicBlock(*args, **kwargs)[source]

Bases: homura.vision.models.cifar_resnet.BasicBlock

training: bool
class homura.vision.models.cifar_resnet.SEBottleneck(*args, **kwargs)[source]

Bases: homura.vision.models.cifar_resnet.Bottleneck

training: bool
class homura.vision.models.cifar_resnet.TVResNet(*args, **kwargs)[source]

Bases: torchvision.models.resnet.ResNet

training: bool
homura.vision.models.cifar_resnet.cifar_resnet18(num_classes=10)[source]
Parameters

num_classes (int) –

Return type

homura.vision.models.cifar_resnet.TVResNet

homura.vision.models.cifar_resnet.cifar_resnet50(num_classes=10)[source]
Parameters

num_classes (int) –

Return type

homura.vision.models.cifar_resnet.TVResNet

homura.vision.models.cifar_resnet.initialization(module, use_zero_init)[source]
Parameters
  • module (torch.nn.modules.module.Module) –

  • use_zero_init (bool) –

homura.vision.models.cifar_resnet.resnet(num_classes, depth, in_channels=3, norm=<class 'torch.nn.modules.batchnorm.BatchNorm2d'>, act=ReLU(), block=<class 'homura.vision.models.cifar_resnet.BasicBlock'>, **kwargs)[source]
Parameters
  • num_classes (int) –

  • depth (int) –

  • in_channels (int) –

  • norm (Optional[Type[torch.nn.modules.batchnorm.BatchNorm2d]]) –

  • act (Callable[[torch.Tensor], torch.Tensor]) –

  • block (Type[homura.vision.models.cifar_resnet.BasicBlock]) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.resnet110(num_classes=10, in_channels=3)[source]

ResNet by He+16

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.resnet20(num_classes=10, in_channels=3)[source]

ResNet by He+16

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.resnet32(num_classes=10, in_channels=3)[source]

ResNet by He+16

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.resnet56(num_classes=10, in_channels=3)[source]

ResNet by He+16

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.resnext(num_classes, depth, width_per_group, groups, in_channels, norm=<class 'torch.nn.modules.batchnorm.BatchNorm2d'>, act=ReLU(), block=<class 'homura.vision.models.cifar_resnet.Bottleneck'>, **kwargs)[source]
Parameters
  • num_classes (int) –

  • depth (int) –

  • width_per_group (int) –

  • groups (int) –

  • in_channels (int) –

  • norm (Optional[Type[torch.nn.modules.batchnorm.BatchNorm2d]]) –

  • act (Callable[[torch.Tensor], torch.Tensor]) –

  • block (Type[homura.vision.models.cifar_resnet.Bottleneck]) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.resnext29_32x4d(num_classes=10, in_channels=3)[source]

ResNeXT by Xie+17

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.resnext29_8x64d(num_classes=10, in_channels=3)[source]

ResNeXT by Xie+17

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.se_resnet20(num_classes=10, in_channels=3)[source]

SEResNet by Hu+18

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.se_resnet56(num_classes=10, in_channels=3)[source]

SEResNet by Hu+18

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.wide_resnet(num_classes, depth, widen_factor, in_channels=3, norm=<class 'torch.nn.modules.batchnorm.BatchNorm2d'>, act=ReLU(), block=<class 'homura.vision.models.cifar_resnet.PreactBasicBlock'>, **kwargs)[source]
Parameters
  • num_classes (int) –

  • depth (int) –

  • widen_factor (int) –

  • in_channels (int) –

  • norm (Optional[Type[torch.nn.modules.batchnorm.BatchNorm2d]]) –

  • act (Callable[[torch.Tensor], torch.Tensor]) –

  • block (Type[homura.vision.models.cifar_resnet.BasicBlock]) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.wrn16_8(num_classes=10, in_channels=3)[source]

WideResNet by Zagoruyko&Komodakis 17

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.wrn28_10(num_classes=10, in_channels=3)[source]

WideResNet by Zagoruyko&Komodakis 17

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.wrn28_10_attention_pool(num_classes=10, in_channels=3, num_heads=10)[source]
Parameters
  • num_classes (int) –

  • in_channels (int) –

  • num_heads (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.wrn28_2(num_classes=10, in_channels=3)[source]

WideResNet by Zagoruyko&Komodakis 17

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.wrn28_2_attention_pool(num_classes=10, in_channels=3, num_heads=2)[source]
Parameters
  • num_classes (int) –

  • in_channels (int) –

  • num_heads (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.cifar_resnet.wrn40_2(num_classes=10, in_channels=3)[source]

WideResNet by Zagoruyko&Komodakis 17

Parameters
  • num_classes (int) –

  • in_channels (int) –

Return type

homura.vision.models.cifar_resnet.ResNet

homura.vision.models.densenet module

DenseNet for CIFAR dataset proposed in Gao et al. 2016 https://github.com/liuzhuang13/DenseNet

class homura.vision.models.densenet.CIFARDenseNet(num_classes, init_channels, num_layers, growth_rate, dropout_rate=0, bn_size=4, reduction=2, padding='reflect')[source]

Bases: torch.nn.modules.module.Module

DenseNet-BC (bottleneck and compactness) for CIFAR dataset. For ImageNet classification, use torchvision’s.

Parameters
  • num_classes – (int) number of output classes

  • init_channels – (int) output channels which is performed on the input. 16 or 2 * growth_rate

  • num_layers – (int) number of layers of each dense block

  • growth_rate – (int) growth rate, which is referred as k in the paper

  • dropout_rate – (float=0) dropout rate

  • bn_size – (int=4) multiplicative factor in bottleneck

  • reduction – (int=2) divisional factor in transition

forward(input)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

initialize()[source]
training: bool
homura.vision.models.densenet.densenet100(num_classes, **kwargs)[source]
homura.vision.models.densenet.densenet40(num_classes, **kwargs)[source]

homura.vision.models.unet module

class homura.vision.models.unet.CustomUNet(num_classes, input_channels, config=((64, 128, 256, 512, 1024), (1024, 512, 256, 128, 64)))[source]

Bases: homura.vision.models.unet.UNet

forward(input)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
homura.vision.models.unet.unet(num_classes, input_channels=3)[source]

Module contents