PyTorch torch.maximum function
PyTorch torch reference manual
torch.maximum is a function in PyTorch used to take the element-wise maximum. It returns a new tensor made of the maximum of corresponding elements of two tensors.
Function definition
torch.maximum(input, other)
Usage examples
Example
import
torch
Create two tensors
x
=
torch.
tensor
(
[
3
,
1
,
4
]
)
y
=
torch.
tensor
(
[
1
,
5
,
2
]
)
Element-wise maximum
result
=
torch.
maximum
(
x
,
y
)
(
result
)
The output is:
tensor([3, 5, 4])