Shahid Akhtar Khan has Published 216 Articles

How to join two images horizontally and vertically using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 11:52:01

4K+ Views

Images in OpenCV are represented as numpy.ndarray. OpenCV provides two functions − cv2.hconcat() and cv2.vconcat() to join images. The function cv2.hconcat() joins images horizontally and the function cv2.vconcat() joins images vertically. These functions join two or more images. These functions accept a list of images of the same size ... Read More

How to resize an image in OpenCV using Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 10:33:16

10K+ Views

OpenCV provides the function cv2.resize() to resize an image. Resizing in OpenCV is referred to as scaling. We can resize an image by specifying the image size or scaling factor. The aspect ratio is preserved when we specify the scaling factor. There are different interpolation methods used in cv2.resize() function ... Read More

torch.argmax() Method in Python PyTorch

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Jan-2022 07:43:30

8K+ Views

To find the indices of the maximum value of the elements in an input tensor, we can apply the torch.argmax() function. It returns the indices only, not the element value. If the input tensor has multiple maximal values, then the function will return the index of the first maximal element. ... Read More

How to compute elementwise logical AND, OR and NOT of given input tensors in PyTorch?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Jan-2022 07:33:01

680 Views

To compute elementwise logical AND of given input tensors we apply torch.logical_and(). It takes two input tensors and computes the logical AND element wise. The zeros in the tensors are treated as False and non-zeros as True. The input tensors may be of any dimension.The torch.logical_or() function computes elementwise logical ... Read More

How to estimate the gradient of a function in one or more dimensions in PyTorch?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Jan-2022 07:28:29

583 Views

To estimate the gradient of a function, we can apply the torch.gradient() function. This function estimates the gradient using the second-order accurate central differences method. We can estimate the gradient in one or more dimensions. The function of which the gradient is to be estimated may be defined on a ... Read More

How to compute the inverse hyperbolic sine in PyTorch?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Jan-2022 07:20:09

119 Views

The torch.asinh() method computes the inverse hyperbolic sine of each element of the input tensor. It supports both real and complex-valued inputs. It supports any dimension of the input tensor.Syntaxtorch.asinh(input)where input is the input tensor.OutputIt returns a tensor inverse hyperbolic sine of each element.StepsTo compute the inverse hyperbolic sine of ... Read More

torch.rsqrt() Method in Python PyTorch

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Jan-2022 07:12:49

296 Views

The torch.rsqrt() method computes the reciprocal of square-root of each element of the input tensor. It supports both real and complex-valued inputs. If an element in the input tensor is zero, then the corresponding element in the output tensor is NaN.Syntaxtorch.rsqrt(input)Parametersinput – Input tensorOutputIt returns a tensor with reciprocal of ... Read More

How to compute the element-wise angle of the given input tensor in PyTorch?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Jan-2022 07:08:23

382 Views

To compute the elementwise angle of the given input tensor, we apply torch.angle(). It takes an input tensor and returns a tensor with angle in radian computed element wise. To convert the angles into the degree we multiply the angle in radian by 180/np.pi. It supports both real and complex-valued ... Read More

How to compute bitwise AND, OR and NOT of given input tensors in PyTorch?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Jan-2022 07:02:10

371 Views

To compute bitwise AND of given input tensors we apply torch.bitwise_and(). The input tensors must be of integral or Boolean types. For bool tensors, it computes the logical AND.To compute bitwise NOT of a given input tensor we apply torch.bitwise_not() method. The input tensors must be of integral or Boolean ... Read More

How to compute the inverse cosine and inverse hyperbolic cosine in PyTorch?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Jan-2022 06:53:56

147 Views

The torch.acos() method computes the inverse cosine of each element of an input tensor. It supports both real and complex-valued inputs. It supports any dimension of the input tensor. The elements of the input tensor must be in the range [-1, 1], as the inverse cosine function has its domain ... Read More

Advertisements