Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

torch_amax

Amax


Description

Amax

Usage

torch_amax(self, dim = list(), keepdim = FALSE)

Arguments

self

(Tensor) the input tensor.

dim

(int or tuple of ints) the dimension or dimensions to reduce.

keepdim

(bool) whether the output tensor has dim retained or not.

amax(input, dim, keepdim=FALSE, *, out=None) -> Tensor

Returns the maximum value of each slice of the input tensor in the given dimension(s) dim.

Note

The difference between max/min and amax/amin is:

  • amax/amin supports reducing on multiple dimensions,

  • amax/amin does not return indices,

  • amax/amin evenly distributes gradient between equal values, while max(dim)/min(dim) propagates gradient only to a single index in the source tensor.

If keepdim is TRUE, the output tensors are of the same size as inputexcept in the dimension(s)dimwhere they are of size 1. Otherwise,dims are squeezed (see [torch_squeeze()]), resulting in the output tensors having fewer dimension than input'.

Examples

if (torch_is_installed()) {

a <- torch_randn(c(4, 4))
a
torch_amax(a, 1)
}

torch

Tensors and Neural Networks with 'GPU' Acceleration

v0.3.0
MIT + file LICENSE
Authors
Daniel Falbel [aut, cre, cph], Javier Luraschi [aut], Dmitriy Selivanov [ctb], Athos Damiani [ctb], Christophe Regouby [ctb], Krzysztof Joachimiak [ctb], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.