resizing
– Resizing Layers¶
Extended Resizing Layers¶
-
class
neuralnet_pytorch.resizing.
Interpolate
(size=None, scale_factor=None, mode='bilinear', align_corners=None, input_shape=None)¶ Down/Upsamples a given multi-channel 1D (temporal), 2D (spatial) or 3D (volumetric) data.
Parameters: - size – output spatial sizes. Mutually exclusive with
scale_factor
. - scale_factor – float or tuple of floats.
Multiplier for spatial size. Has to match input size if it is a tuple.
Mutually exclusive with
size
. - mode – talgorithm used for upsampling:
'nearest'
,'linear'
,'bilinear'
,'bicubic'
,'trilinear'
, and'area'
. Default:'nearest'
. - align_corners – if
True
, the corner pixels of the input and output tensors are aligned, and thus preserving the values at those pixels. IfFalse
, the input and output tensors are aligned by the corner points of their corner pixels, and the interpolation uses edge value padding for out-of-boundary values, making this operation independent of input size whenscale_factor
is kept the same. This only has effect when mode is'linear'
,'bilinear'
, or'trilinear'
. Default:False
. - input_shape – shape of the input tensor. Optional.
- size – output spatial sizes. Mutually exclusive with
-
class
neuralnet_pytorch.resizing.
AvgPool2d
(kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=False, input_shape=None)¶ Applies a 2D average pooling over an input signal composed of several input planes.
Parameters: - kernel_size – the size of the window.
- stride – the stride of the window. Default value is kernel_size.
- padding – implicit zero padding to be added on both sides.
- ceil_mode – when True, will use ceil instead of floor to compute the output shape.
- count_include_pad – when True, will include the zero-padding in the averaging calculation.
- input_shape – shape of the input image. Optional.
-
class
neuralnet_pytorch.resizing.
MaxPool2d
(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False, input_shape=None)¶ Applies a 2D max pooling over an input signal composed of several input planes.
Parameters: - kernel_size – the size of the window.
- stride – the stride of the window. Default value is kernel_size.
- padding – implicit zero padding to be added on both sides.
- dilation – a parameter that controls the stride of elements in the window.
- return_indices – if
True
, will return the max indices along with the outputs. Useful fortorch.nn.MaxUnpool2d
later. - ceil_mode – when True, will use ceil instead of floor to compute the output shape.
- input_shape – shape of the input image. Optional.
Custom Resizing Layers¶
-
class
neuralnet_pytorch.resizing.
GlobalAvgPool2D
(keepdim=False, input_shape=None)¶ Applies a 2D global average pooling over an input signal composed of several input planes.
Parameters: - keepdim (bool) – whether to keep the collapsed dim as (1, 1). Default:
False
. - input_shape – shape of the input image. Optional.
- keepdim (bool) – whether to keep the collapsed dim as (1, 1). Default:
-
class
neuralnet_pytorch.resizing.
Cat
(dim=1, *modules_or_tensors)¶ Concatenates the outputs of multiple modules given an input tensor. A subclass of
MultiSingleInputModule
.
-
class
neuralnet_pytorch.resizing.
ConcurrentCat
(dim=1, *modules_or_tensors)¶ Concatenates the outputs of multiple modules given input tensors. A subclass of
MultiMultiInputModule
.
-
class
neuralnet_pytorch.resizing.
SequentialCat
(dim=1, *modules_or_tensors)¶ Concatenates the intermediate outputs of multiple sequential modules given an input tensor. A subclass of
Cat
.
-
class
neuralnet_pytorch.resizing.
Reshape
(shape, input_shape=None)¶ Reshapes the input tensor to the specified shape.
Parameters: - shape – new shape of the tensor. One dim can be set to -1
to let
torch
automatically calculate the suitable value. - input_shape – shape of the input tensor. Optional.
- shape – new shape of the tensor. One dim can be set to -1
to let
-
class
neuralnet_pytorch.resizing.
Flatten
(start_dim=0, end_dim=-1, input_shape=None)¶ Collapses some adjacent dims.
Parameters: - start_dim – dim where flattening starts.
- end_dim – dim where flattening ends.
- input_shape – shape of the input tensor. Optional.
-
class
neuralnet_pytorch.resizing.
DimShuffle
(pattern, input_shape=None)¶ Reorder the dimensions of this variable, optionally inserting broadcasted dimensions. Inspired by Theano’s dimshuffle.
Parameters: - pattern – List/tuple of int mixed with ‘x’ for broadcastable dimensions.
- input_shape – shape of the input tensor. Optional.