Recursively generating a tuple from intermediate neural network outputs

Hi, I have different neural network “encoders” and would like to generate a tuple containing the output of intermediate stages. The encoders and the number of their stages vary. So essentially I want to automate and flexibilise the following:

function foo(input, fs)
    x1 = f1(input)
    x2 = f2(x1)
    ...
    xn = fn(xn-1)
    return (x1,x2,...,xn)
end

I think there must be an easy solution, but I just can’t wrap my head around it.

Looks like Flux.activations might be what you need?

1 Like

Tail recursion it is… :bulb:
That‘s why I love julia: jump to the source, look at it, understand it, use it.

1 Like