def argmin(input, dim=None, keepdim=False): """Returns the indices of the minimum values of a tensor across a dimension. This is the second value returned by :meth:`torch.min`. See its documentation for the exact semantics of this method. Args: input (Tensor): the input tensor dim (int): the dimension to reduce. If ``None``, the argmin of the flattened input is returned. keepdim (bool): whether the output tensors have :attr:`dim` retained or not. Ignored if ``dim=None``. Example:: >>> a = torch.randn(4, 4) >>> a 2.3461 0.0056 1.4846 0.3911 -1.3584 -1.0066 0.0530 1.1754 -0.7929 -0.3194 -1.4865 0.4020 0.1101 0.6694 1.3456 0.8235 [torch.FloatTensor of size (4,4)] >>> torch.argmin(a, dim=1) 1 0 2 0 [torch.LongTensor of size (4,)] """ if dim is None: return torch._argmin(input.contiguous().view(-1), dim=0, keepdim=False) return torch._argmin(input, dim, keepdim)
def argmin(input, dim=None, keepdim=False): r"""Returns the indices of the minimum values of a tensor across a dimension. This is the second value returned by :meth:`torch.min`. See its documentation for the exact semantics of this method. Args: input (Tensor): the input tensor dim (int): the dimension to reduce. If ``None``, the argmin of the flattened input is returned. keepdim (bool): whether the output tensors have :attr:`dim` retained or not. Ignored if ``dim=None``. Example:: >>> a = torch.randn(4, 4) >>> a tensor([[ 0.1139, 0.2254, -0.1381, 0.3687], [ 1.0100, -1.1975, -0.0102, -0.4732], [-0.9240, 0.1207, -0.7506, -1.0213], [ 1.7809, -1.2960, 0.9384, 0.1438]]) >>> torch.argmin(a, dim=1) tensor([ 2, 1, 3, 1]) """ if dim is None: return torch._argmin(input.contiguous().view(-1), dim=0, keepdim=False) return torch._argmin(input, dim, keepdim)
def argmin(input, dim=None, keepdim=False): """Returns the indices of the minimum values of a tensor across a dimension. This is the second value returned by :meth:`torch.min`. See its documentation for the exact semantics of this method. Args: input (Tensor): the input tensor dim (int): the dimension to reduce. If ``None``, the argmin of the flattened input is returned. keepdim (bool): whether the output tensors have :attr:`dim` retained or not. Ignored if ``dim=None``. Example:: >>> a = torch.randn(4, 4) >>> a tensor([[ 0.1139, 0.2254, -0.1381, 0.3687], [ 1.0100, -1.1975, -0.0102, -0.4732], [-0.9240, 0.1207, -0.7506, -1.0213], [ 1.7809, -1.2960, 0.9384, 0.1438]]) >>> torch.argmin(a, dim=1) tensor([ 2, 1, 3, 1]) """ if dim is None: return torch._argmin(input.contiguous().view(-1), dim=0, keepdim=False) return torch._argmin(input, dim, keepdim)