Thursday, February 5, 2026
HomeLanguagesHow to compute the inverse hyperbolic sine in PyTorch?

How to compute the inverse hyperbolic sine in PyTorch?

In this article, we are going to discuss how to compute the inverse hyperbolic sine in PyTorch. 

torch.asinh() method:

The torch.asinh() method is used to compute the inverse hyperbolic sine of each element present in a given input tensor. This method accepts both real and complex-valued as input. It supports input tensors of any dimension. This method returns a tensor after computing the inverse hyperbolic sine of each element in a given input tensor. before moving further let’s see the syntax of this method.

Syntax: torch.asinh(input, *, out=None)

Parameters:

  • input: This is our input tensor.
  • out (optional) – This is our output tensor. 

Return: This method returns a tensor after computing the inverse hyperbolic sine of each element in a given input tensor.

Example 1:

In this example, we are computing the inverse hyperbolic sine for the real-valued 1D tensor.

Python3




# Import required library
import torch
  
# creating a input tensor
tens = torch.tensor([3., 1.3, 2., 2.3, -2.3])
  
# print the input tensor
print(" Input Tensor - ", tens)
  
# compute the inverse hyperbolic sine 
# of input tensor
tens_inv_hsin = torch.asinh(tens)
  
# print the above computed tensor
print(" Computed Inverse Hyperbolic Sine Tensor - "
      tens_inv_hsin)


Output:

 

Example 2:

In this example, we are computing the inverse hyperbolic sine for the complex-valued 1D tensor.

Python3




# Import required library
import torch
  
# creating a input tensor
tens = torch.tensor([2.1+3j, 2.+2.j, 4.+2.j, 2.4+2.j])
  
# print the input tensor
print(" Input Tensor - ", tens)
  
# compute the inverse hyperbolic sine 
# of input tensor
tens_inv_hsin = torch.asinh(tens)
  
# print the above computed tensor
print(" Computed Inverse Hyperbolic Sine - ",
      tens_inv_hsin)


Output:

 

Example 3:

In this example, we are computing the inverse hyperbolic sine for the real-valued 2D tensor.

Python3




# Import required library
import torch
  
# define a 2D input tensor
tens = torch.tensor([[1., 2.3, 1.3],
                     [2.1, 3., -2.3],
                     [3.2, 5.2, 2.3]])
  
# print the input tensor
print("\n Input Tensor: \n", tens)
  
# compute the inverse hyperbolic sine of 
# input tensor
tens_inv_hsin = torch.asinh(tens)
  
# print the above computed tensor
print("\n Computed Inverse Hyperbolic Sine: \n "
      tens_inv_hsin)


Output:

 

Example 4:

In this example, we are computing the inverse hyperbolic sine for the complex-valued 2D tensor.

Python3




# Import required library
import torch
  
# define a 2D input tensor
tens = torch.tensor([[2.1+3j, 2.+3.j, 3.1-3.5j],
                     [1.3+2j, 2.3-2.3j, 4.+3.j],
                     [3.2+5j, 6.+3.j, 4.2-3.2j]])
  
# print the input tensor
print("\n Input Tensor: \n", tens)
  
# compute the inverse hyperbolic sine
# of input tensor
tens_inv_hsin = torch.asinh(tens)
  
# print the above computed tensor
print("\n Computed Inverse Hyperbolic Sine: \n "
      tens_inv_hsin)


Output:

 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32487 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6861 POSTS0 COMMENTS
Nicole Veronica
11983 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12071 POSTS0 COMMENTS
Shaida Kate Naidoo
6994 POSTS0 COMMENTS
Ted Musemwa
7233 POSTS0 COMMENTS
Thapelo Manthata
6944 POSTS0 COMMENTS
Umr Jansen
6926 POSTS0 COMMENTS