# Other Functions¶

## dilatedavgpool2d¶

encoding.functions.dilatedavgpool2d(input, kernel_size, stride=None, padding=0, dilation=1)[source]

Dilated Average Pool 2d, for dilation of DenseNet.

Applies 2D average-pooling operation in kh x kw regions by step size dh x dw steps. The number of output features is equal to the number of input planes.

See DilatedAvgPool2d for details and output shape.

Parameters: input – input tensor (minibatch x in_channels x iH x iW) kernel_size – size of the pooling region, a single number or a tuple (kh x kw) stride – stride of the pooling operation, a single number or a tuple (sh x sw). Default is equal to kernel size padding – implicit zero padding on the input, a single number or a tuple (padh x padw), Default: 0 dilation – the dilation parameter similar to Conv2d

## upsample¶

encoding.functions.upsample(input, size=None, scale_factor=None, mode='nearest')[source]

Multi-GPU version torch.nn.functional.upsample

Upsamples the input to either the given size or the given scale_factor

The algorithm used for upsampling is determined by mode.

Currently temporal, spatial and volumetric upsampling are supported, i.e. expected inputs are 3-D, 4-D or 5-D in shape.

The input dimensions are interpreted in the form: mini-batch x channels x [depth] x [height] x width

The modes available for upsampling are: nearest, linear (3D-only), bilinear (4D-only), trilinear (5D-only)

Parameters: input (Variable) – input size (int or Tuple[int] or Tuple[int, int] or Tuple[int, int, int]) – output spatial size. scale_factor (int) – multiplier for spatial size. Has to be an integer. mode (string) – algorithm used for upsampling: ‘nearest’ | ‘linear’ | ‘bilinear’ | ‘trilinear’. Default: ‘nearest’

## dropout¶

encoding.functions.dropout(input, p=0.5, training=False, inplace=True)[source]

Multi-GPU version torch.nn.functional.droupout

The channels to zero-out are randomized on every forward call.

Usually the input comes from Conv2d modules.

As described in the paper Efficient Object Localization Using Convolutional Networks, if adjacent pixels within feature maps are strongly correlated (as is normally the case in early convolution layers) then iid dropout will not regularize the activations and will otherwise just result in an effective learning rate decrease.

In this case, nn.Dropout2d() will help promote independence between feature maps and should be used instead.

Parameters: p (float, optional) – probability of an element to be zeroed. inplace (bool, optional) – If set to True, will do this operation in-place
Shape:
• Input: $$(N, C, H, W)$$
• Output: $$(N, C, H, W)$$ (same shape as input)

## relu¶

encoding.functions.relu(input, inplace=False)[source]

Multi-GPU version torch.nn.functional.relu

Applies the rectified linear unit function element-wise $${ReLU}(x)= max(0, x)$$

Parameters: inplace – can optionally do the operation in-place. Default: False
Shape:
• Input: $$(N, *)$$ where * means, any number of additional dimensions
• Output: $$(N, *)$$, same shape as the input

## view_each¶

encoding.functions.view_each(x, size)[source]

Multi-GPU version torch.view

Returns a new tensor with the same data but different size. The returned tensor shares the same data and must have the same number of elements, but may have a different size. A tensor must be contiguous to be viewed.

Parameters: input – list of multi-gpu tensors size (torch.Size or int...) – Desired size

## multi_each¶

encoding.functions.multi_each(a, b)[source]

Multi-GPU version multiplication

$y[i] = a[i] * b[i]$

## sum_each¶

encoding.functions.sum_each(x, y)[source]

$y[i] = a[i] + b[i]$
encoding.functions.cat_each(x1, x2, dim)[source]
$y[i] = torch.cat(a[i], b[i], dim)$