Python | PyTorch asin() method Last Updated : 10 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes.The function torch.asin() provides support for the inverse sine function in PyTorch. It expects the input to be in the range [-1, 1] and gives the output in radian form. It returns nan if the input does not lie in the range [-1, 1]. The input type is tensor and if the input contains more than one element, element-wise inverse sine is computed. Syntax: torch.asin(x, out=None)Parameters: x: Input tensor name (optional): Output tensorReturn type: A tensor with the same type as that of x. Code #1: Python3 # Importing the PyTorch library import torch # A constant tensor of size 6 a = torch.FloatTensor([1.0, -0.5, 3.4, 0.2, 0.0, -2]) print(a) # Applying the inverse sin function and # storing the result in 'b' b = torch.asin(a) print(b) Output: tensor([ 1.0000, -0.5000, 3.4000, 0.2000, 0.0000, -2.0000]) tensor([ 1.5708, -0.5236, nan, 0.2014, 0.0000, nan]) Code #2: Visualization Python3 # Importing the PyTorch library import torch # Importing the NumPy library import numpy as np # Importing the matplotlib.pyplot function import matplotlib.pyplot as plt # A vector of size 15 with values from -1 to 1 a = np.linspace(-1, 1, 15) # Applying the inverse sine function and # storing the result in 'b' b = torch.asin(torch.FloatTensor(a)) print(b) # Plotting plt.plot(a, b.numpy(), color = 'red', marker = "o") plt.title("torch.asin") plt.xlabel("X") plt.ylabel("Y") plt.show() Output: tensor([-1.5708, -1.0297, -0.7956, -0.6082, -0.4429, -0.2898, -0.1433, 0.0000, 0.1433, 0.2898, 0.4429, 0.6082, 0.7956, 1.0297, 1.5708]) Comment More infoAdvertise with us Next Article Python - PyTorch add() method V vaibhav29498 Follow Improve Article Tags : Python Practice Tags : python Similar Reads Python - PyTorch abs() method PyTorch torch.abs() method computes the element-wise absolute value of the given input tensor. Syntax: torch.abs(inp, out=None) ? Tensor Arguments inp: This is input tensor. out: This is optional parameter and is the output tensor. Return: It returns a Tensor having absolute value of input inp. Let' 1 min read Python | PyTorch acos() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.acos() provides support for the inverse cosine function in PyTorch. It expects the input to be in the range [-1, 1] and gives the 2 min read Python | PyTorch atan() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.atan() provides support for the inverse tangent function in PyTorch. It gives the output in radian form. The input type is tensor 2 min read Python - PyTorch add() method PyTorch torch.add() method adds a constant value to each element of the input tensor and returns a new modified tensor. Syntax: torch.add(inp, c, out=None) Arguments inp: This is input tensor. c: The value that is to be added to every element of tensor. out: This is optional parameter and it is the 1 min read Python | PyTorch cos() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes.The function torch.cos() provides support for the cosine function in PyTorch. It expects the input in radian form and the output is in the range [-1, 2 min read Python - PyTorch div() method PyTorch torch.div() method divides every element of the input with a constant and returns a new modified tensor. Syntax: torch.div(inp, other, out=None) Arguments inp: This is input tensor. other: This is a number to be divided to each element of input inp. out: The output tensor. Return: It returns 1 min read Like