tf.foldl( fn, elems, initializer=None, parallel_iterations=10, back_prop=True, swap_memory=False, name=None )
See the guide: Higher Order Functions > Higher Order Operators
foldl on the list of tensors unpacked from
elems on dimension 0.
This foldl operator repeatedly applies the callable
fn to a sequence
of elements from first to last. The elements are made of the tensors
elems on dimension 0. The callable fn takes two tensors as
arguments. The first argument is the accumulated value computed from the
preceding invocation of fn. If
initializer is None,
elems must contain
at least one element, and its first element is used as the initializer.
elems is unpacked into
values, a list of tensors. The shape
of the result tensor is fn(initializer, values).shape`.
fn: The callable to be performed.
elems: A tensor to be unpacked on dimension 0.
initializer: (optional) The initial value for the accumulator.
parallel_iterations: (optional) The number of iterations allowed to run in parallel.
back_prop: (optional) True enables support for back propagation.
swap_memory: (optional) True enables GPU-CPU memory swapping.
name: (optional) Name prefix for the returned tensors.
A tensor resulting from applying
fn consecutively to the list of tensors
elems, from first to last.
fnis not callable.
elems = [1, 2, 3, 4, 5, 6] sum = foldl(lambda a, x: a + x, elems) .html# sum == 21