Skip to content

Instantly share code, notes, and snippets.

@leconteur
Created February 3, 2016 18:23
Show Gist options
  • Save leconteur/82f968f483ddd2234a03 to your computer and use it in GitHub Desktop.
Save leconteur/82f968f483ddd2234a03 to your computer and use it in GitHub Desktop.
cumsum function in tensorflow
def cumsum(softmax):
values = tf.split(1, softmax.get_shape()[1], softmax)
out = []
prev = tf.zeros_like(values[0])
for val in values:
s = prev + val
out.append(s)
prev = s
cumsum = tf.concat(1, out)
return cumsum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment