PyTorch .acosh()
Anonymous contributor
Published Mar 12, 2025
The .acosh() method in PyTorch computes the inverse hyperbolic cosine of each element in a tensor. This operation is applied element-wise and is commonly used in scientific computations involving hyperbolic functions.
Syntax
torch.acosh(input, *, out=None) → Tensor
Parameters:
input: The input tensor containing values greater than or equal to 1.out(Optional): The output tensor to store the result. If not provided, a new tensor is created.
Returns:
A tensor with the inverse hyperbolic cosine of each element from the input tensor.
Example
This example shows how to use .acosh() to compute the inverse hyperbolic cosine of a tensor:
import torch# Define a tensor with values >= 1input_tensor = torch.tensor([1.0, 2.0, 3.0, 10.0])# Compute the inverse hyperbolic cosineoutput_tensor = torch.acosh(input_tensor)print("Input Tensor:")print(input_tensor)print("\nOutput Tensor:")print(output_tensor)
This example results in the following output:
Input Tensor:tensor([ 1., 2., 3., 10.])Output Tensor:tensor([0.0000, 1.3169, 1.7627, 2.9932])
All contributors
- Anonymous contributor
Learn PyTorch on Codecademy
- Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.
- Includes 27 Courses
- With Professional Certification
- Beginner Friendly.95 hours
- Learn how to use PyTorch to build, train, and test artificial neural networks in this course.
- Intermediate.3 hours