Q:

How to apply list of functions cumulatively in TensorFlow

Assume I have input x and a list of functions [f, g, h, j] is there a TensorFlow function to get the composition of these? i.e. [f(x), g(f(x)), h(g(f(x))), j(h(g(f(x))))].

A:

Python can have callables (i.e., functions) assigned to variables. If you use this feature, you can easily loop through a list of callables to get the composition:
def compose(x):
    # For more clarity, let's actually assign callables to variables
    f = tf.nn.leaky_relu
    g = lambda x: -x
    h = tf.nn.sigmoid
    j = tf.reduce_mean

    callables = [f, g, h, j]
    results = []
    for func in callables:
        x = func(x)
        results.append(x)
    return results

A parallel form of this, something like tf.map_fn, isn't possible in this case, since an element depends on previous elements; the flow is inherently sequential.

