Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 819 of 3363
571 Views
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. The padding is done along the height and width of the input tensor.It takes the size of padding (padding) and constant values (value) as the parameters. The size of padding may be an integer or a tuple. The padding may be the same for all boundaries or different for each ... Read More
3K+ Views
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 a tuple in (left, right, top, bottom) format. If it is an integer, then the padding along all the boundaries are the same. The height of the padded tensor is increased by top+bottom, whereas the width of the padded tensor is increased by left+right. It does not change the channel ... Read More
5K+ Views
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 W are the height and width of the input image, respectively.The main feature of a Max Pool operation is the filter or kernel size and stride. This module supports TensorFloat32.Syntaxtorch.nn.MaxPool2d(kernel_size)Parameterskernel_size – The size of the window to take a max over.Along with this parameter, there are some optional parameters also ... Read More
2K+ Views
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, W] where N is the batch size, C is the number of channels, H and W are the height and width of the input image, respectively.Generally a 2D transposed convolution operation is applied on the image tensors. For a RGB image, the number of channels is 3. The main feature ... Read More
8K+ Views
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 the batch size, C is the number of channels, H and W are the height and width of the input tensor.Generally a 2D convolution operation is applied on the image tensors. For an RGB image, the number of channels is 3. The main feature of a convolution operation is the ... Read More
790 Views
In this problem, we are given a prime number N. Our task is to find the number of primitive roots modulo prime.Primitive Root of a number − It is a number (r) smaller than N which has all values of r^x(mod N) different for all X in range [0, n-2].Let’s take an example to understand the problem, Input : N = 5 Output : 2Solution ApproachA simple solution to the problem is based on a trial method. We will check for all numbers from 2 to (N-1) for the conditions with x ranging from [0, n-2] and break if a value ... Read More
173 Views
In this problem, we are given N points that lie in a 2D plane. Our task is to find the number of points that have at least 1 point above, below, left or right of it.We need to count all the points that have at least 1 point which satisfies any of the below conditions.Point above it − The point will have the same X coordinate and the Y coordinate is one more than its current value.Point below it − The point will have the same X coordinate and the Y coordinate is one less than its current value.Point left ... Read More
433 Views
In this problem, we are given an array arr of size n. Our task is to Find the number of operations required to make all array elements EqualThe operation is defined as distribution of equal weights from the element with maximum weight to all the elements of the array.If it is not possible to make array elements equal, print -1. Let’s take an example to understand the problem, Input : arr[] = {7, 3, 3, 3} Output : 3ExplanationArray after distribution is {4, 4, 4, 4}Solution ApproachA simple solution to the problem is by finding the largest value of the array. ... Read More
182 Views
In this problem, we are given a positive number of 1. Our task is to find the Nth binary string in sorted order.We need to find the Nth string in an infinite list of strings created using only two symbols a and b sorted in lexicographical order.The list is −a, b, aa, ab, ba, bb, aaa, aab, aba, …Let’s take an example to understand the problem, Input : N = 8 Output : aabSolution ApproachA simple solution to the problem is by using loops to generate all n strings. And then return the Nth string. This solution does the work ... Read More
250 Views
In this problem, we are given a graph of N nodes. Our task is to Find the maximum possible value of the minimum value of the modified array.For the graph we have a permutation of nodes which is the number of induces with minimum 1 node on the left of it sharing a common edge.Let’s take an example to understand the problem, Input : N = 4, edge = {{1, 2}, {2, 3}, {3, 4}, {4, 1}} Output : 3Solution ApproachA simple solution to the problem is by traversing the tree from one node visiting all its adjacent nodes. We ... Read More