PyTorch .pow()
Anonymous contributor
Published Nov 5, 2025
Contribute to Docs
The .pow() method in PyTorch computes the power of each tensor element by raising it to a specified exponent.
Syntax
torch.pow(input, exponent, *, out=None)
Parameters:
input: The input tensor whose elements are to be raised to a power.exponent: The exponent value(s). If a tensor, it must be broadcastable to the shape ofinput.out(Optional): A tensor to store the output. If provided, it must have the same shape asinput.
Return value:
Returns a new tensor containing the element-wise results of raising each input element to the specified power.
Example
The following example demonstrates the usage of the .pow() function:
import torch# Define a tensorinput_tensor = torch.tensor([1.0, 0.5, 3.0, 5.5, 11.0])# Compute the exponent of each element in the input tensoroutput_tensor = torch.pow(input_tensor, 3)# Print the resultant tensorprint(output_tensor)
The above code produces the following output:
tensor([1.0000e+00, 1.2500e-01, 2.7000e+01, 1.6638e+02, 1.3310e+03])
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
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 the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
- With Certificate
- Beginner Friendly.24 hours