Now tf1.7 doesn't seem to find this function, but it can be used. Hey, Google API is a bit unprofessional. I flipped through the previous documentation for an introduction to it:
tf.reduce_prod 函数
reduce_prod(
input_tensor,
axis=None,
keep_dims=False,
name=None,
reduction_indices=None
)
Defined in: tensorflow/python/ops/math_ops.py .
See guide: Math Functions > Reduce
This function computes the product of elements in each dimension of a tensor.
The input_tensor in the function is reduced by the dimension already given in axis; unless keep_dims is true, the rank of the tensor will be reduced by 1 in each entry of axis; if keep_dims is true, the reduced dimension will be preserved is length 1.
If axis has no entries, all dimensions are reduced and a tensor with a single element is returned.
parameter:
- input_tensor: The tensor to reduce. Should have numeric type.
- axis: The dimension to reduce. If None (default), all dimensions will be reduced. Must be in the range [-rank(input_tensor), rank(input_tensor)).
- keep_dims: If true, keep the reduced dimensions of length 1.
- name: The name of the action (optional).
- reduction_indices: Deprecated names for axis.
return:
The result returns a reduced tensor.
numpy compatibility
Equivalent to np.prod
TensorFlow function: tf.reduce_sum
tf.reduce_sum 函数
reduce_sum ( input_tensor , axis = None , keep_dims = False , name = None , reduction_indices = None )
Defined in: tensorflow/python/ops/math_ops.py .
See guide: Math Functions > Reduce
This function computes the sum of elements in each dimension of a tensor.
The input_tensor in the function is reduced by the dimension already given in axis; unless keep_dims is true, the rank of the tensor will be reduced by 1 in each entry of axis; if keep_dims is true, the reduced dimension will be preserved is length 1.
If axis has no entries, all dimensions are reduced and a tensor with a single element is returned.
E.g:
x = tf.constant([[1, 1, 1], [1, 1, 1]])
tf.reduce_sum(x) # 6
tf.reduce_sum(x, 0) # [2, 2, 2]
tf.reduce_sum(x, 1) # [3, 3]
tf.reduce_sum(x, 1, keep_dims=True) # [[3], [3]]
tf.reduce_sum(x, [0, 1]) # 6
parameter:
- input_tensor: The tensor to reduce. Should have numeric type.
- axis: The dimension to reduce. If None (default), all sizes are reduced. Must be in the range [-rank(input_tensor), rank(input_tensor)).
- keep_dims: If true, keep the reduced dimensions of length 1.
- name: The name of the action (optional).
- reduction_indices: Deprecated names for axis.
return:
The function returns the reduced tensor.
numpy compatibility
Equivalent to np.sum
https://blog.csdn.net/fu6543210/article/details/80221748
TensorFlow函数:tf.reduce_mean
tf.reduce_mean 函数
reduce_mean(
input_tensor,
axis=None,
keep_dims=False,
name=None,
reduction_indices=None
)
Defined in: tensorflow/python/ops/math_ops.py .
See guide: Math Functions > Reduce
Computes the mean of the elements in each dimension of a tensor.
axis is a parameter in the tf.reduce_mean function, reducing input_tensor according to the dimension given by axis in the function. Unless keep_dims is true, the rank of the tensor will decrease by 1 in each entry of axis. If keep_dims is true, the reduced dimensions will remain at 1.
If axis has no entries, reduce all dimensions and return a tensor with a single element.
E.g:
x = tf.constant([[1., 1.], [2., 2.]])
tf.reduce_mean(x) # 1.5
tf.reduce_mean(x, 0) # [1.5, 1.5]
tf.reduce_mean(x, 1) # [1., 2.]
parameter:
- input_tensor: The tensor to reduce. Should have numeric type.
- axis: The dimension to reduce. If None (default), all dimensions are reduced. Must be in the range [-rank(input_tensor), rank(input_tensor)).
- keep_dims: If true, keep the reduced dimensions of length 1.
- name: The name of the action (optional).
- reduction_indices: Unsupported names for axis use.
return:
The function returns the reduced tensor.
numpy compatibility
Equivalent to np.mean
TensorFlow function: tf.reduce_max
tf.reduce_max 函数
reduce_max(
input_tensor,
axis=None,
keep_dims=False,
name=None,
reduction_indices=None
)
Defined in: tensorflow/python/ops/math_ops.py .
See guide: Math Functions > Reduce
Computes the maximum value of elements in each dimension of a tensor.
Reduce input_tensor according to the dimension given by axis. Unless keep_dims is true, the rank of the tensor will decrease by 1 in each entry of axis. If keep_dims is true, the reduced dimensions will remain at length 1.
If axis has no entries, reduce all dimensions and return a tensor with a single element.
parameter:
- input_tensor: The tensor to reduce. Should have numeric type.
- axis: The dimension to reduce. If None (default), all dimensions are reduced. Must be in the range [-rank(input_tensor), rank(input_tensor)).
- keep_dims: If true, keep reduced dimensions of length 1.
- name: The name of the action (optional).
- reduction_indices: Deprecated names for axis .
return:
The function returns the reduced tensor.
numpy compatibility
Equivalent to np.max.
TensorFlow function: tf.reduce_min
tf.reduce_min 函数
reduce_min(
input_tensor,
axis=None,
keep_dims=False,
name=None,
reduction_indices=None
)
Defined in: tensorflow/python/ops/math_ops.py .
See guide: Math Functions > Reduce
The tf.reduce_min function is used to calculate the minimum value of elements in each dimension of a tensor.
Also reduce input_tensor according to the dimension given by axis. Unless keep_dims is true, the rank of the tensor will decrease by 1 in each entry of axis. If keep_dims is true, the reduced dimensions will remain at length 1.
If axis has no entries, all dimensions are reduced and a tensor with a single element is returned.
parameter:
- input_tensor: reduced tensor. Should have numeric type.
- axis: The dimension to reduce. If None (default), all dimensions are reduced. Must be in the range [-rank(input_tensor), rank(input_tensor)).
- keep_dims: If true, keep the reduced dimensions of length 1.
- name: The name of the action (optional).
- reduction_indices: Deprecated names for axis.
return:
The function returns the reduced tensor.
numpy compatibility
Equivalent to np.min