## How to measure the Binary Cross Entropy between the target and the input probabilities in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 08:13:43

We apply the BCELoss() method to compute the binary cross entropy loss between the input and target (predicted and actual) probabilities. BCELoss() is accessed from the torch.nn module. It creates a criterion that measures the binary cross entropy loss. It is a type of loss function provided by the torch.nn ... Read More

## torch.nn.Dropout() Method in Python PyTorch Shahid Akhtar Khan

Updated on 25-Jan-2022 08:08:00

Making some of the random elements of an input tensor zero has been proven to be an effective technique for regularization during the training of a neural network. To achieve this task, we can apply torch.nn.Dropout(). It zeroes some of the elements of the input tensor.An element will be zeroed ... Read More

## How to rescale a tensor in the range [0, 1] and sum to 1 in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 08:03:26

We can rescale an n-dimensional input Tensor such that the elements lie within the range [0, 1] and sum to 1. To do this, we can apply the Softmax() function. We can rescale the n-dimensional input tensor along a particular dimension. The size of the output tensor is the same ... Read More

## How to apply rectified linear unit function element-wise in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 07:59:27

To apply a rectified linear unit (ReLU) function element-wise on an input tensor, we use torch.nn.ReLU(). It replaces all the negative elements in the input tensor with 0 (zero), and all the non-negative elements are left unchanged. It supports only real-valued input tensors. ReLU is used as an activation function ... Read More

## How to apply a 2D Average Pooling in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 07:48:40

We can apply a 2D Average Pooling over an input image composed of several input planes using the torch.nn.AvgPool2d() module. The input to a 2D Average Pooling layer must be of size [N, C, H, W] where N is the batch size, C is the number of channels, H and ... Read More

## How to pad the input tensor boundaries with a constant value in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 07:40:43

The torch.nn.ConstantPad2D() pads the input tensor boundaries with constant value. The size of the input tensor must be in 3D or 4D in (C, H, W) or (N, C, H, W) format respectively. Where N, C, H, W represents the mini batch size, number of channels, height and width respectively. ... Read More

## How to pad the input tensor boundaries with zero in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 07:31:55

The torch.nn.ZeroPad2D() pads the input tensor boundaries with zeros. It takes the size of padding (padding) as a parameter. The size of padding may be an integer or a tuple. The padding may be the same for all boundaries or different for each boundary.The padding may be an integer or ... Read More

## How to apply a 2D Max Pooling in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 07:17:45

We can apply a 2D Max Pooling over an input image composed of several input planes using the torch.nn.MaxPool2d() module. The input to a 2D Max Pool layer must be of size [N, C, H, W] where N is the batch size, C is the number of channels, H and ... Read More

## How to apply a 2D transposed convolution operation in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 07:09:16

We can apply a 2D transposed convolution operation over an input image composed of several input planes using the torch.nn.ConvTranspose2d() module. This module can be seen as the gradient of Conv2d with respect to its input.The input to a 2D transpose convolution layer must be of size [N, C, H, ... Read More

## How to apply a 2D convolution operation in PyTorch? Shahid Akhtar Khan

Updated on 25-Jan-2022 06:59:37

We can apply a 2D convolution operation over an input image composed of several input planes using the torch.nn.Conv2d() module. It is implemented as a layer in a convolutional neural network (CNN). The input to a 2D convolution layer must be of size [N, C, H, W] where N is ... Read More