Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit bc91705

Browse files
Enhance .max() documentation with additional details
Updated the description to clarify that .max() can return maximum values across a specified dimension. Added the 'out' parameter to the syntax and clarified return values.
1 parent 6485e5f commit bc91705

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

  • content/pytorch/concepts/tensor-operations/terms/max

content/pytorch/concepts/tensor-operations/terms/max/max.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Title: '.max()'
3-
Description: 'Returns the maximum value of a tensor.'
3+
Description: 'Returns the maximum value of a tensor, either across the entire tensor or along a specified dimension.'
44
Subjects:
55
- 'Computer Science'
66
- 'Data Science'
@@ -19,19 +19,20 @@ The **`.max()`** method in PyTorch returns the maximum value from a [tensor](htt
1919
## Syntax
2020

2121
```pseudo
22-
torch.max(input, dim=None, keepdim=False) → Tensor or (Tensor, LongTensor)
22+
torch.max(input, dim=None, keepdim=False, *, out=None) → Tensor or (Tensor, LongTensor)
2323
```
2424

2525
**Parameters:**
2626

2727
- `input` (Tensor): The input tensor.
2828
- `dim` (int, optional): The dimension along which to find the maximum values. If not specified, returns the maximum value of the entire tensor.
2929
- `keepdim` (bool, optional): Whether the output tensor retains the reduced dimension. Defaults to `False`.
30+
- `out` (tuple of Tensors, optional): Optional tuple of two tensors to store the output values and indices.
3031

3132
**Return value:**
3233

33-
- When `dim` is not specified: Returns a tensor containing the single maximum value from the entire tensor.
34-
- When `dim` is specified: Returns a named tuple `(values, indices)` where `values` contains the maximum values along the specified dimension, and `indices` contains the indices of those maximum values.
34+
- When `dim` is not specified, it returns a tensor containing the single maximum value from the entire tensor.
35+
- When `dim` is specified, it returns a named tuple `(values, indices)` where `values` contains the maximum values along the specified dimension, and `indices` contains the indices of those maximum values.
3536

3637
## Example
3738

0 commit comments

Comments
 (0)