ut  ` .

Parameters

    

  * **dim** ( [ _int_ ](https://docs.python.org/3/library/functions.html#int "\(in Python v3.8\)") ) – the dimension to reduce 

  * **keepdim** ( [ _bool_ ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.8\)") ) – whether the output tensor has ` dim  ` retained or not 

  * **out** (  _Tensor_ _,_ _optional_ ) – the output tensor 

Example:

    
    
    >>> a = torch.rand(4, 2).bool()
    >>> a
    tensor([[True, True],
            [True, False],
            [True, True],
            [True, True]], dtype=torch.bool)
    >>> a.all(dim=1)
    tensor([ True, False,  True,  True], dtype=torch.bool)
    >>> a.all(dim=0)
    tensor([ True, False], dtype=torch.bool)
    

` any ` (  )  ¶

    

` any ` (  )  → bool

    

Returns True if any elements in the tensor are True, False otherwise.

Example:

    
    
    >>> a = torch.rand(1, 2).bool()
    >>> a
    tensor([[False, True]], dtype=torch.bool)
    >>> a.any()
    tensor(True, dtype=torch.bool)
    

` any ` (  _dim_ , _keepdim=False_ , _out=None_ )  → Tensor

    

Returns True if any elements in each row of the tensor in the given dimension
` dim  ` are True, False otherwise.

If ` keepdim  ` is ` True  ` , the output tensor is of the same size as `
input  ` except in the dimension ` dim  ` where it is of size 1. Otherwise, `
dim  ` is squeezed (see [ ` torch.squeeze()  `
](generated/torch.squeeze.html#torch.squeeze "torch.squeeze") ), resulting in
the output tensor having 1 fewer dimension than ` input  ` .

Parameters

    

  * **dim** ( [ _int_ ](https://docs.python.org/3/library/functions.html#int "\(in Python v3.8\)") ) – the dimension to reduce 

  * **keepdim** ( [ _bool_ ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.8\)") ) – whether the output tensor has ` dim  ` retained or not 

  * **out** (  _Tensor_ _,_ _optional_ ) – the output tensor 

Example:

    
    
    >>> a = torch.randn(4, 2) < 0
    >>> a
    tensor([[ True,  True],
            [False,  True],
            [ True,  True],
            [False, False]])
    >>> a.any(1)
    tensor([ True,  True,  True, False])
    >>> a.any(0)
    tensor([True, True])
    

[ Next ![](_static/images/chevron-right-orange.svg) ](tensor_attributes.html
"Tensor Attributes") [ ![](_static/images/chevron-right-orange.svg) Previous
](nn.functional.html "torch.nn.functional")

* * *

© Copyright 2019, Torch Contributors.

Built with [ Sphinx ](http://sphinx-doc.org/) using a [ theme
](https://github.com/rtfd/sphinx_rtd_theme) provided by [ Read the Docs
](https://readthedocs.org) .

  * torch.Tensor 

![](https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&guid=ON&script=0)

##  Docs

Access comprehensive developer documentation for PyTorch

[ View Docs ](https://pytorch.org/docs/stable/index.html)

##  Tutorials

Get in-depth tutorials for beginners and advanced developers

[ View Tutorials ](https://pytorch.org/tutorials)

##  Resources

Find development resources and get your questions answered

[ View Resources ](https://pytorch.org/resources)

[ ](https://pytorch.org/)

  * [ PyTorch ](https://pytorch.org/)
  * [ Get Started ](https://pytorch.org/get-started)
  * [ Features ](https://pytorch.org/features)
  * [ Ecosystem ](https://pytorch.org/ecosystem)
  * [ Blog ](https://pytorch.org/blog/)
  * [ Contributing ](https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md)

  * [ Resources ](https://pytorch.org/resources)
  * [ Tutorials ](https://pytorch.org/tutorials)
  * [ Docs ](https://pytorch.org/docs/stable/index.html)
  * [ Discuss ](https://discuss.pytorch.org)
  * [ Github Issues ](https://github.com/pytorch/pytorch/issues)
  * [ Brand Guidelines ](https://pytorch.org/assets/brand-guidelines/PyTorch-Brand-Guidelines.pdf)

  * Stay Connected 
  * Email Address 

[ ](https://www.facebook.com/pytorch) [ ](https://twitter.com/pytorch) [
](https://www.youtube.com/pytorch)

To analyze traffic and opti