Computes the Euclidean norm of elements across dimensions of a tensor. Reduces `input_tensor` along the dimensions given in `axis`. Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each entry in `axis`. If `keepdims` is true, the reduced dimensions are retained with len
(input_tensor, axis=None, keepdims=False, name=None)
| 1566 | |
| 1567 | @tf_export("math.reduce_euclidean_norm") |
| 1568 | def reduce_euclidean_norm(input_tensor, axis=None, keepdims=False, name=None): |
| 1569 | """Computes the Euclidean norm of elements across dimensions of a tensor. |
| 1570 | |
| 1571 | Reduces `input_tensor` along the dimensions given in `axis`. |
| 1572 | Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each |
| 1573 | entry in `axis`. If `keepdims` is true, the reduced dimensions |
| 1574 | are retained with length 1. |
| 1575 | |
| 1576 | If `axis` is None, all dimensions are reduced, and a |
| 1577 | tensor with a single element is returned. |
| 1578 | |
| 1579 | For example: |
| 1580 | |
| 1581 | ```python |
| 1582 | x = tf.constant([[1, 2, 3], [1, 1, 1]]) |
| 1583 | tf.reduce_euclidean_norm(x) # sqrt(17) |
| 1584 | tf.reduce_euclidean_norm(x, 0) # [sqrt(2), sqrt(5), sqrt(10)] |
| 1585 | tf.reduce_euclidean_norm(x, 1) # [sqrt(14), sqrt(3)] |
| 1586 | tf.reduce_euclidean_norm(x, 1, keepdims=True) # [[sqrt(14)], [sqrt(3)]] |
| 1587 | tf.reduce_euclidean_norm(x, [0, 1]) # sqrt(17) |
| 1588 | ``` |
| 1589 | |
| 1590 | Args: |
| 1591 | input_tensor: The tensor to reduce. Should have numeric type. |
| 1592 | axis: The dimensions to reduce. If `None` (the default), reduces all |
| 1593 | dimensions. Must be in the range `[-rank(input_tensor), |
| 1594 | rank(input_tensor))`. |
| 1595 | keepdims: If true, retains reduced dimensions with length 1. |
| 1596 | name: A name for the operation (optional). |
| 1597 | |
| 1598 | Returns: |
| 1599 | The reduced tensor, of the same dtype as the input_tensor. |
| 1600 | """ |
| 1601 | return _may_reduce_to_scalar( |
| 1602 | keepdims, axis, |
| 1603 | gen_math_ops.euclidean_norm( |
| 1604 | input_tensor, _ReductionDims(input_tensor, axis), keepdims, |
| 1605 | name=name)) |
| 1606 | |
| 1607 | |
| 1608 | @tf_export(v1=["math.count_nonzero", "count_nonzero"]) |
nothing calls this directly
no test coverage detected