MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / repeat

Function repeat

monai/transforms/utils_pytorch_numpy_unification.py:364–378  ·  view source on GitHub ↗

`np.repeat` with equivalent implementation for torch (`repeat_interleave`). Args: a: input data to repeat. repeats: number of repetitions for each element, repeats is broadcast to fit the shape of the given axis. axis: axis along which to repeat values. kwar

(a: NdarrayOrTensor, repeats: int, axis: int | None = None, **kwargs)

Source from the content-addressed store, hash-verified

362
363
364def repeat(a: NdarrayOrTensor, repeats: int, axis: int | None = None, **kwargs) -> NdarrayOrTensor:
365 """
366 `np.repeat` with equivalent implementation for torch (`repeat_interleave`).
367
368 Args:
369 a: input data to repeat.
370 repeats: number of repetitions for each element, repeats is broadcast to fit the shape of the given axis.
371 axis: axis along which to repeat values.
372 kwargs: if `a` is PyTorch Tensor, additional args for `torch.repeat_interleave`, more details:
373 https://pytorch.org/docs/stable/generated/torch.repeat_interleave.html.
374
375 """
376 if isinstance(a, np.ndarray):
377 return np.repeat(a, repeats, axis)
378 return torch.repeat_interleave(a, repeats, dim=axis, **kwargs)
379
380
381def isnan(x: NdarrayOrTensor) -> NdarrayOrTensor:

Callers 2

blend_imagesFunction · 0.90
parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…