Upsample / Downsample#
- pydantic model vision_architectures.layers.scale.PixelShuffleScaleConfig[source]#
Bases:
CNNBlockConfigShow JSON schema
{ "title": "PixelShuffleScaleConfig", "type": "object", "properties": { "in_channels": { "description": "Number of input channels", "title": "In Channels", "type": "integer" }, "out_channels": { "description": "Number of output channels", "title": "Out Channels", "type": "integer" }, "kernel_size": { "anyOf": [ { "type": "integer" }, { "items": { "type": "integer" }, "type": "array" } ], "description": "Kernel size for the convolution", "title": "Kernel Size" }, "padding": { "anyOf": [ { "type": "integer" }, { "items": { "type": "integer" }, "type": "array" }, { "type": "string" } ], "default": "same", "description": "Padding for the convolution. Can be 'same' or an integer/tuple of integers.", "title": "Padding" }, "stride": { "anyOf": [ { "type": "integer" }, { "items": { "type": "integer" }, "type": "array" } ], "default": 1, "description": "Stride for the convolution", "title": "Stride" }, "conv_kwargs": { "additionalProperties": true, "default": {}, "description": "Additional keyword arguments for the convolution layer", "title": "Conv Kwargs", "type": "object" }, "transposed": { "default": false, "description": "Whether to perform ConvTranspose instead of Conv", "title": "Transposed", "type": "boolean" }, "normalization": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": "batchnorm3d", "description": "Normalization layer type.", "title": "Normalization" }, "normalization_pre_args": { "default": [], "description": "Arguments for the normalization layer before providing the dimension. Useful when using GroupNorm layers are being used to specify the number of groups.", "items": {}, "title": "Normalization Pre Args", "type": "array" }, "normalization_post_args": { "default": [], "description": "Arguments for the normalization layer after providing the dimension.", "items": {}, "title": "Normalization Post Args", "type": "array" }, "normalization_kwargs": { "additionalProperties": true, "default": {}, "description": "Additional keyword arguments for the normalization layer", "title": "Normalization Kwargs", "type": "object" }, "activation": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": "relu", "description": "Activation function type.", "title": "Activation" }, "activation_kwargs": { "additionalProperties": true, "default": {}, "description": "Additional keyword arguments for the activation function.", "title": "Activation Kwargs", "type": "object" }, "sequence": { "default": "CNA", "description": "Sequence of operations in the block.", "enum": [ "C", "AC", "CA", "CD", "CN", "DC", "NC", "ACD", "ACN", "ADC", "ANC", "CAD", "CAN", "CDA", "CDN", "CNA", "CND", "DAC", "DCA", "DCN", "DNC", "NAC", "NCA", "NCD", "NDC", "ACDN", "ACND", "ADCN", "ADNC", "ANCD", "ANDC", "CADN", "CAND", "CDAN", "CDNA", "CNAD", "CNDA", "DACN", "DANC", "DCAN", "DCNA", "DNAC", "DNCA", "NACD", "NADC", "NCAD", "NCDA", "NDAC", "NDCA" ], "title": "Sequence", "type": "string" }, "drop_prob": { "default": 0.0, "description": "Dropout probability.", "title": "Drop Prob", "type": "number" }, "scale_factor": { "default": 2, "description": "Scale factor for upsampling / downsampling.", "title": "Scale Factor", "type": "integer" } }, "required": [ "in_channels", "out_channels", "kernel_size" ] }
- Config:
arbitrary_types_allowed: bool = True
extra: str = ignore
validate_default: bool = True
validate_assignment: bool = True
validate_return: bool = True
- Fields:
- Validators:
-
field scale_factor:
int= 2# Scale factor for upsampling / downsampling.
- Validated by:
- class vision_architectures.layers.scale.PixelShuffleUpsample3D(config={}, checkpointing_level=0, **kwargs)[source]#
Bases:
ModulePixel Shuffle Upsampling layer for 3D data. This class is designed for 3D input eg. medical images, videos etc.
- __init__(config={}, checkpointing_level=0, **kwargs)[source]#
Initializes the PixelShuffleUpsample3D layer.
- Parameters:
config (
PixelShuffleScaleConfig) – An instance of the Config class that contains all the configuration parameters. It can also be passed as a dictionary and the instance will be created automatically.checkpointing_level (
int) – The level of checkpointing to use for activation checkpointing. Refer toActivationCheckpointingfor more details.**kwargs – Additional keyword arguments for configuration.
- forward(x, channels_first=True)[source]#
Forward pass of the PixelShuffleUpsample3D layer.
- Parameters:
x (
Tensor) – Tensor of shape (B, C, Z, Y, X) or (B, Z, Y, X, C) representing the input features.channels_first (
bool) – Whether the inputs are in channels first format (B, C, …) or not (B, …, C).
- Return type:
Tensor- Returns:
Tensor of shape (B, C, Z, Y, X) or (B, Z, Y, X, C) representing the output features.
- class vision_architectures.layers.scale.PixelShuffleDownsample3D(config={}, checkpointing_level=0, **kwargs)[source]#
Bases:
ModulePixel Shuffle Downsampling layer for 3D data. This class is designed for 3D input eg. medical images, videos etc.
- __init__(config={}, checkpointing_level=0, **kwargs)[source]#
Initializes the PixelShuffleDownsample3D layer.
- Parameters:
config (
PixelShuffleScaleConfig) – An instance of the Config class that contains all the configuration parameters. It can also be passed as a dictionary and the instance will be created automatically.checkpointing_level (
int) – The level of checkpointing to use for activation checkpointing. Refer toActivationCheckpointingfor more details.**kwargs – Additional Additional keyword arguments for configuration.
- forward(x, channels_first=True)[source]#
Forward pass of the PixelShuffleDownsample3D layer.
- Parameters:
x (
Tensor) – Tensor of shape (B, C, Z, Y, X) or (B, Z, Y, X, C) representing the input features.channels_first (
bool) – Whether the inputs are in channels first format (B, C, …) or not (B, …, C).
- Return type:
Tensor- Returns:
Tensor of shape (B, C, Z, Y, X) or (B, Z, Y, X, C) representing the output features.