PyTorch torch.exp2 Function

PyTorch torch.exp2 Function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.exp2It is a function in PyTorch used to compute the power of 2 element-wise.

Function Definition

torch.exp2(input, *, out=None)

Usage Example

Example

import torch

# Power of 2 Example
x = torch.tensor([0, 1, 2, 3, 4], dtype=torch.float32)
result = torch.exp2(x)
print(result)  # tensor([1., 2., 4., 8., 16.])

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions