ConvolutionalDecoder2d#
- class deeplay.components.cnn.encdec.ConvolutionalDecoder2d(*args, **kwargs)#
Bases:
ConvolutionalNeuralNetworkConvolutional Decoder module in 2D.
Parameters#
- in_channels: int or None
Number of input features. If None, the input shape is inferred from the first forward pass
- channels: list[int]
Number of hidden units in the decoder layers
- out_channels: int
Number of output features
- out_activation: template-like
Specification for the output activation. (Default: nn.Sigmoid)
- pool: template-like
Specification for the pooling of the block. Is not applied to the first block. (Default: nn.MaxPool2d)
preprocess: preprocessing layer (Default: nn.Identity)
Configurables#
in_channels (int): Number of input features. If None, the input shape is inferred from the first forward pass.
channels: list[int]: Number of hidden units in the decoder layers
out_channels (int): Number of output features.
out_activation (template-like): Specification for the output activation. (Default: nn.ReLU)
Constraints#
input shape: (batch_size, ch_in)
output shape: (batch_size, ch_out)
Evaluation#
>>> >>> x = self.preprocess(x) >>> for block in blocks: >>> x = block(x) >>> return x
Examples#
>>> # Using default values >>> dec = ConvolutionalDecoder2d(128, [128, 64, 32], 1) >>> # Customizing output activation >>> dec.block[-1].activation(nn.Identity)
Return Values#
The forward method returns the processed tensor.
Additional Notes#
The Config and Layer classes are used for configuring the blocks. For more details refer to [Config Documentation](#) and [Layer Documentation](#).
Methods Summary
configure(*args, **kwargs)Configures the module with specified arguments.
forward(x)Define the computation performed at every call.
upsampled([upsample, apply_to_last_layer, ...])Methods Documentation
- configure(*args: Any, **kwargs: Any)#
Configures the module with specified arguments.
This method allows dynamic configuration of the module’s properties and behaviors. It can be used to set or modify the attributes and parameters of the module and, if applicable, its child modules. The method intelligently handles both direct attribute configuration and delegation to child modules’ configure methods.
Parameters#
- *argsAny
Positional arguments specifying the configuration settings. When the first argument is a string matching a configurable attribute, the method expects either one or two arguments: the attribute name and, optionally, its value. If the attribute is itself a DeeplayModule, subsequent arguments are passed to its configure method.
- **kwargsAny
Keyword arguments for configuration settings. If provided, these are used to update the module’s configuration directly.
Raises#
- ValueError
Raised if a configuration key is not recognized as a valid configurable for the module or if the provided arguments do not match the expected pattern for configuration.
Example Usage#
To configure a single attribute:
` module.configure('attribute_name', attribute_value) # or module.configure(attribute_name=attribute_value) `To configure multiple attributes using keyword arguments:
` module.configure(attribute1=value1, attribute2=value2) `To configure a child module’s attribute:
` module.configure('child_module_attribute', child_attribute=child_attribute_value) # or module.child_module.configure(child_attribute=child_attribute_value) `
- forward(x)#
Define 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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.