PyTorch torch.maximum Function
Pytorch torch Reference Manual
torch.maximumIt is a function in PyTorch for element-wise maximum. Returns a new tensor composed of the maximum of corresponding elements of two tensors.
Function Definition
torch.maximum(input, other)
Usage Example
Example
import torch
# Create two tensors
x = torch.tensor([3, 1, 4])
y = torch.tensor([1, 5, 2])
# Take element-wise maximum
result = torch.maximum(x, y)
print(result)
# Create two tensors
x = torch.tensor([3, 1, 4])
y = torch.tensor([1, 5, 2])
# Take element-wise maximum
result = torch.maximum(x, y)
print(result)
The output result is:
tensor([3, 5, 4])
Other Extensions