@@ -46,6 +46,8 @@ This mode supports a number of command-line arguments, the details of which can
...
@@ -46,6 +46,8 @@ This mode supports a number of command-line arguments, the details of which can
* `--predict_only`: Generates the model outputs without computing metrics. Use with `--log_samples` to retrieve decoded results.
* `--predict_only`: Generates the model outputs without computing metrics. Use with `--log_samples` to retrieve decoded results.
* `--seed`: Set seed for python's random, numpy and torch. Accepts a comma-separated list of 3 values for python's random, numpy, and torch seeds, respectively, or a single integer to set the same seed for all three. The values are either an integer or 'None' to not set the seed. Default is `0,1234,1234` (for backward compatibility). E.g. `--seed 0,None,8` sets `random.seed(0)` and `torch.manual_seed(8)`. Here numpy's seed is not set since the second value is `None`. E.g, `--seed 42` sets all three seeds to 42.
## External Library Usage
## External Library Usage
We also support using the library's external API for use within model training loops or other scripts.
We also support using the library's external API for use within model training loops or other scripts.
A class for reordering and batching elements of an array.
This class allows for sorting an array based on a provided sorting function, grouping elements based on a grouping function, and generating batches from the sorted and grouped data.
"""
def__init__(
self,
arr:List,
sort_fn:Callable,
group_fn:Callable=lambdax:x[1],
grouping:bool=False,
)->None:
self.grouping=grouping
self.fn=sort_fn
self.group_fn=lambdax:group_fn(x[1])# first index are enumerated indices