fn
flatten
→Tensorflatten(input: Tensor, start_axis: int = ..., end_axis: int = ...)Collapse a contiguous range of dimensions into a single dim.
All dimensions from start_axis to end_axis (inclusive) are
merged into one, preserving row-major order of the original elements.
Often used to feed a feature map into a fully-connected head.
Parameters
inputTensorSource tensor.
start_axisint= 0First dimension to flatten.
end_axisint= -1Last dimension to flatten (inclusive).
Returns
TensorTensor whose rank is reduced by end_axis - start_axis.
Notes
The merged dim has size
. The
result is a view when input is contiguous in the flattened range,
otherwise a copy.
Examples
>>> import lucid
>>> x = lucid.zeros(2, 3, 4)
>>> lucid.flatten(x).shape
(24,)
>>> lucid.flatten(x, 1, 2).shape
(2, 12)