代码拉取完成,页面将自动刷新
tf.math.cumsum(x, axis=0, exclusive=False, reverse=False, name=None)
更多内容详见tf.math.cumsum。
mindspore.Tensor.cumsum(self, axis=None, dtype=None)
更多内容详见mindspore.Tensor.cumsum。
在TensorFlow1.15版本中,tf.math.cumsum==tf.cumsum。
两接口基本功能相同,都是计算某个维度上Tensor的累加和(cumulative sum)。不同点在于,tf.math.cumsum
多两个入参:exclusive
用于指定是否包含当前值的累加,reverse
用于指定返回值是否做逆转。
from mindspore import Tensor
import numpy as np
a = Tensor(np.ones((2,3)).astype("float32"))
print(a.cumsum(axis=0))
# [[1. 1. 1.]
# [2. 2. 2.]]
import tensorflow as tf
tf.enable_eager_execution()
b = tf.constant(np.ones((2, 3)))
print(tf.cumsum(b, axis=0))
# tf.Tensor(
# [[1. 1. 1.]
# [2. 2. 2.]], shape=(2, 3), dtype=float64)
print(tf.cumsum(b, exclusive=True))
# tf.Tensor(
# [[0. 0. 0.]
# [1. 1. 1.]], shape=(2, 3), dtype=float64)
print(tf.cumsum(b, reverse=True))
# tf.Tensor(
# [[2. 2. 2.]
# [1. 1. 1.]], shape=(2, 3), dtype=float64)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。