MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / reduce_logsumexp_v1

Function reduce_logsumexp_v1

tensorflow/python/ops/math_ops.py:2412–2461  ·  view source on GitHub ↗

Computes log(sum(exp(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 length 1.

(input_tensor,
                        axis=None,
                        keepdims=None,
                        name=None,
                        reduction_indices=None,
                        keep_dims=None)

Source from the content-addressed store, hash-verified

2410 "keep_dims is deprecated, use keepdims instead",
2411 "keep_dims")
2412def reduce_logsumexp_v1(input_tensor,
2413 axis=None,
2414 keepdims=None,
2415 name=None,
2416 reduction_indices=None,
2417 keep_dims=None):
2418 """Computes log(sum(exp(elements across dimensions of a tensor))).
2419
2420 Reduces `input_tensor` along the dimensions given in `axis`.
2421 Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
2422 entry in `axis`. If `keepdims` is true, the reduced dimensions
2423 are retained with length 1.
2424
2425 If `axis` has no entries, all dimensions are reduced, and a
2426 tensor with a single element is returned.
2427
2428 This function is more numerically stable than log(sum(exp(input))). It avoids
2429 overflows caused by taking the exp of large inputs and underflows caused by
2430 taking the log of small inputs.
2431
2432 For example:
2433
2434 ```python
2435 x = tf.constant([[0., 0., 0.], [0., 0., 0.]])
2436 tf.reduce_logsumexp(x) # log(6)
2437 tf.reduce_logsumexp(x, 0) # [log(2), log(2), log(2)]
2438 tf.reduce_logsumexp(x, 1) # [log(3), log(3)]
2439 tf.reduce_logsumexp(x, 1, keepdims=True) # [[log(3)], [log(3)]]
2440 tf.reduce_logsumexp(x, [0, 1]) # log(6)
2441 ```
2442
2443 Args:
2444 input_tensor: The tensor to reduce. Should have numeric type.
2445 axis: The dimensions to reduce. If `None` (the default), reduces all
2446 dimensions. Must be in the range `[-rank(input_tensor),
2447 rank(input_tensor))`.
2448 keepdims: If true, retains reduced dimensions with length 1.
2449 name: A name for the operation (optional).
2450 reduction_indices: The old (deprecated) name for axis.
2451 keep_dims: Deprecated alias for `keepdims`.
2452
2453 Returns:
2454 The reduced tensor.
2455 """
2456 axis = deprecation.deprecated_argument_lookup("axis", axis,
2457 "reduction_indices",
2458 reduction_indices)
2459 keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
2460 "keep_dims", keep_dims)
2461 return reduce_logsumexp(input_tensor, axis, keepdims, name)
2462
2463
2464@tf_export("math.reduce_logsumexp", "reduce_logsumexp", v1=[])

Callers

nothing calls this directly

Calls 1

reduce_logsumexpFunction · 0.85

Tested by

no test coverage detected