Computes the product 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 length 1.
(input_tensor, axis=None, keepdims=False, name=None)
| 1967 | @tf_export("math.reduce_prod", "reduce_prod", v1=[]) |
| 1968 | @dispatch.add_dispatch_support |
| 1969 | def reduce_prod(input_tensor, axis=None, keepdims=False, name=None): |
| 1970 | """Computes the product of elements across dimensions of a tensor. |
| 1971 | |
| 1972 | Reduces `input_tensor` along the dimensions given in `axis`. |
| 1973 | Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each |
| 1974 | entry in `axis`. If `keepdims` is true, the reduced dimensions |
| 1975 | are retained with length 1. |
| 1976 | |
| 1977 | If `axis` is None, all dimensions are reduced, and a |
| 1978 | tensor with a single element is returned. |
| 1979 | |
| 1980 | Args: |
| 1981 | input_tensor: The tensor to reduce. Should have numeric type. |
| 1982 | axis: The dimensions to reduce. If `None` (the default), reduces all |
| 1983 | dimensions. Must be in the range `[-rank(input_tensor), |
| 1984 | rank(input_tensor))`. |
| 1985 | keepdims: If true, retains reduced dimensions with length 1. |
| 1986 | name: A name for the operation (optional). |
| 1987 | |
| 1988 | Returns: |
| 1989 | The reduced tensor. |
| 1990 | |
| 1991 | @compatibility(numpy) |
| 1992 | Equivalent to np.prod |
| 1993 | @end_compatibility |
| 1994 | """ |
| 1995 | keepdims = False if keepdims is None else keepdims |
| 1996 | return _may_reduce_to_scalar( |
| 1997 | keepdims, axis, |
| 1998 | gen_math_ops.prod( |
| 1999 | input_tensor, _ReductionDims(input_tensor, axis), keepdims, |
| 2000 | name=name)) |
| 2001 | |
| 2002 | |
| 2003 | @tf_export(v1=["math.reduce_prod", "reduce_prod"]) |
no test coverage detected