mythos.utils.helpers
Helper functions for the mythos package.
Attributes
Functions
|
Batch an iterable into chunks of size n. |
|
Stacks corresponding leaves of PyTrees into arrays along a new axis. |
|
Concatenates corresponding leaves of PyTrees along the first axis. |
Module Contents
- mythos.utils.helpers.ERR_BATCHED_N = 'n must be at least one'
- mythos.utils.helpers.batched(iterable: collections.abc.Iterable[Any], n: int) collections.abc.Iterable[Any][source]
Batch an iterable into chunks of size n.
- Parameters:
iterable (iter[Any]) – iterable to batch
n (int) – batch size
- Returns:
batched iterable
- Return type:
iter[Any]