如何获得符号向量的反向累积和?
import tensorflow as tf
input = tf.placeholder('float32', [None])
output = some_function(input)
例如
输入
input = [1,2,3,4]
输出
`output` = [1+2+3+4, 2+3+4, 3+4, 4] = [10, 9, 7, 4]
答案 0 :(得分:2)
您可以使用tf.cumsum
:
import tensorflow as tf
input = tf.placeholder('float32', [None])
output = tf.cumsum(input, reverse=True)