tf.math.reduce_all
Stay organized with collections
Save and categorize content based on your preferences.
Computes tf.math.logical_and
of elements across dimensions of a tensor.
tf.math.reduce_all(
input_tensor, axis=None, keepdims=False, name=None
)
Used in the notebooks
Used in the guide |
Used in the tutorials |
|
|
This is the reduction operation for the elementwise tf.math.logical_and
op.
Reduces input_tensor
along the dimensions given in axis
.
Unless keepdims
is true, the rank of the tensor is reduced by 1 for each
of the entries in axis
, which must be unique. If keepdims
is true, the
reduced dimensions are retained with length 1.
If axis
is None, all dimensions are reduced, and a
tensor with a single element is returned.
For example |
>>> x = tf.constant([[True, True], [False, False]])
>>> tf.math.reduce_all(x)
<tf.Tensor: shape=(), dtype=bool, numpy=False>
>>> tf.math.reduce_all(x, 0)
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([False, False])>
>>> tf.math.reduce_all(x, 1)
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, False])>
|
Args |
input_tensor
|
The boolean tensor to reduce.
|
axis
|
The dimensions to reduce. If None (the default), reduces all
dimensions. Must be in the range [-rank(input_tensor),
rank(input_tensor)) .
|
keepdims
|
If true, retains reduced dimensions with length 1.
|
name
|
A name for the operation (optional).
|
Returns |
The reduced tensor.
|
Equivalent to np.all
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.math.reduce_all\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/math_ops.py#L3083-L3128) |\n\nComputes [`tf.math.logical_and`](../../tf/math/logical_and) of elements across dimensions of a tensor.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.reduce_all`](https://www.tensorflow.org/api_docs/python/tf/math/reduce_all)\n\n\u003cbr /\u003e\n\n tf.math.reduce_all(\n input_tensor, axis=None, keepdims=False, name=None\n )\n\n### Used in the notebooks\n\n| Used in the guide | Used in the tutorials |\n|----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|\n| - [Extension types](https://www.tensorflow.org/guide/extension_type) | - [Neural machine translation with attention](https://www.tensorflow.org/text/tutorials/nmt_with_attention) |\n\nThis is the reduction operation for the elementwise [`tf.math.logical_and`](../../tf/math/logical_and) op.\n\nReduces `input_tensor` along the dimensions given in `axis`.\nUnless `keepdims` is true, the rank of the tensor is reduced by 1 for each\nof the entries in `axis`, which must be unique. If `keepdims` is true, the\nreduced dimensions are retained with length 1.\n\nIf `axis` is None, all dimensions are reduced, and a\ntensor with a single element is returned.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| For example ----------- ||\n|---|---|\n| \u003cbr /\u003e \u003e\u003e\u003e x = tf.constant([[True, True], [False, False]]) \u003e\u003e\u003e tf.math.reduce_all(x) \u003ctf.Tensor: shape=(), dtype=bool, numpy=False\u003e \u003e\u003e\u003e tf.math.reduce_all(x, 0) \u003ctf.Tensor: shape=(2,), dtype=bool, numpy=array([False, False])\u003e \u003e\u003e\u003e tf.math.reduce_all(x, 1) \u003ctf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, False])\u003e \u003cbr /\u003e ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `input_tensor` | The boolean tensor to reduce. |\n| `axis` | The dimensions to reduce. If `None` (the default), reduces all dimensions. Must be in the range `[-rank(input_tensor), rank(input_tensor))`. |\n| `keepdims` | If true, retains reduced dimensions with length 1. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The reduced tensor. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nnumpy compatibility\n-------------------\n\n\u003cbr /\u003e\n\nEquivalent to np.all\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]