ConvBnRelu¶
tiatoolbox
.models
.architecture
.nuclick
.ConvBnRelu
- class ConvBnRelu(num_input_channels, num_output_channels, kernel_size=(3, 3), strides=(1, 1), dilation_rate=(1, 1), activation='relu', *, use_bias=False, do_batchnorm=True)[source]¶
Performs Convolution, Batch Normalization and activation.
- Parameters:
num_input_channels (int) – Number of channels in input.
num_output_channels (int) – Number of channels in output.
kernel_size (int) – Size of the kernel in the convolution layer.
strides (int) – Size of the stride in the convolution layer.
use_bias (bool) – Whether to use bias in the convolution layer.
dilation_rate (int) – Dilation rate in the convolution layer.
activation (str) – Name of the activation function to use.
do_batchnorm (bool) – Whether to do batch normalization after the convolution layer.
- Returns:
a pytorch model.
- Return type:
model (torch.nn.Module)
Initialize
ConvBnRelu
.Methods
Logic for using layers defined in init.
Function to acquire a convolutional block.
Attributes
training
- forward(input_tensor)[source]¶
Logic for using layers defined in init.
This method defines how layers are used in forward operation.
- Parameters:
input_tensor (torch.Tensor) – Input, the tensor is of the shape NCHW.
self (ConvBnRelu)
- Returns:
The inference output.
- Return type:
output (torch.Tensor)
- static get_block(in_channels, out_channels, kernel_size, strides, dilation_rate, activation, *, do_batchnorm, use_bias)[source]¶
Function to acquire a convolutional block.
- Parameters:
in_channels (int) – Number of channels in input.
out_channels (int) – Number of channels in output.
kernel_size (int or tuple(int, int)) – Size of the kernel in the acquired convolution block.
strides (int) – Size of stride in the convolution layer.
use_bias (bool) – Whether to use bias in the convolution layer.
dilation_rate (int or tuple(int, int)) – Dilation rate for each convolution layer.
activation (str) – Name of the activation function to use.
do_batchnorm (bool) – Whether to do batch normalization after the convolution layer.
- Returns:
a pytorch layer
- Return type: