简介
- 累计求和
函数
cumsum(
x,
axis=0,
exclusive=False,
reverse=False,
name=None
)
exclusive
- True:排除第一项
- False:不排除第一项
reverse
- True:逆向求和
- False:顺序求和
示例
a = [[1 ,2, 3],
[4, 5, 6],
[7, 8, 9]]
# axis=0
sum1 = tf.cumsum(a, axis=0)
sum1 = [[ 1, 2, 3],
[ 5, 7, 9],
[12, 15, 18]]
# axis=1
sum2 = tf.cumsum(a, axis=1)
sum2 = [[ 1, 3, 6],
[ 4, 9, 15],
[ 7, 15, 24]]
# exclusive=False
sum3 = tf.cumsum(a, exclusive=False)
sum3 = [[ 1, 2, 3],
[ 5, 7, 9],
[12, 15, 18]]
# exclusive=True
sum4 = tf.cumsum(a, exclusive=True)
sum4= [[0, 0, 0],
[1, 2, 3],
[5, 7, 9]]
# reverse=True
sum5 = tf.cumsum(a, reverse=True)
sum5 = [[12, 15, 18],
[11, 13, 15],
[ 7, 8, 9]]
# exclusive=True, reverse=True
sum6 = tf.cumsum(a, exclusive=True, reverse=True)
sum6 = [[11, 13, 15],
[ 7, 8, 9],
[ 0, 0, 0]]
参考
- https://blog.csdn.net/YiRanNingJing/article/details/79451786