fn
repeat
→Tensorrepeat(tensor: Tensor, pattern: str, axes_lengths: int = {})Repeat tensor along new or existing axes via an einops pattern.
Provides a single notation for both tiling along existing axes and
broadcasting into entirely new axes. The pattern's right-hand side
enumerates the desired output axes; any axis appearing on the right
but not on the left is introduced and must be given an explicit
length through **axes_lengths.
Parameters
tensorTensorInput tensor to repeat.
patternstrEinops pattern such as
"b h w -> b h w c" (new axis c).**axes_lengthsint= {}Sizes for every new axis introduced by the pattern.
Returns
TensorThe repeated tensor.
Notes
For an axis of size introduced via repeat,
No data is materialised until reading — internally the new axis is expressed as a broadcast / stride manipulation when possible.
Examples
>>> import lucid
>>> x = lucid.randn(2, 3, 4)
>>> lucid.einops.repeat(x, "b h w -> b h w c", c=5).shape
(2, 3, 4, 5)