.acosh()

Anonymous contributor's avatar
Anonymous contributor
Published Mar 12, 2025
Contribute to Docs

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 >= 1
input_tensor = torch.tensor([1.0, 2.0, 3.0, 10.0])
# Compute the inverse hyperbolic cosine
output_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

Contribute to Docs

Learn PyTorch on Codecademy