Skip to content

Add Padding as an Argument to AutoEncoder #7045

@surajpaib

Description

@surajpaib

Is your feature request related to a problem? Please describe.
In the current implementation of the AutoEncoder class in the monai.networks.nets module, the padding parameter is not customizable. This limits the model's flexibility, as different padding strategies might suit different data-sizes.

Describe the solution you'd like
I would like to propose adding a padding argument to the AutoEncoder class constructor. This would allow users to specify the padding strategy when instantiating the model.

Describe alternatives you've considered
An alternative solution could be to create a subclass of AutoEncoder (like CustomAE) whenever a different padding strategy is needed. See below,

class CustomAE(AutoEncoder):
    def __init__(self, padding, **kwargs):
        self.padding = padding
        super().__init__(**kwargs)
    
    def _get_encode_layer(self, in_channels: int, out_channels: int, strides: int, is_last: bool) -> nn.Module:
        # ...
        mod = Convolution(
            spatial_dims=self.dimensions,
            in_channels=in_channels,
            out_channels=out_channels,
            strides=strides,
            kernel_size=self.kernel_size,
            padding=self.padding,
            # ...
        )
        return mod

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions