osl_dynamics.data.tf.dataset_from_index#
- osl_dynamics.data.tf.dataset_from_index(index, slice_fn, batch_size, shuffle=True, drop_last_batch=False, seed=None)#
Create a batched dataset from a sequence index.
Shuffling is done on the index (which is tiny), so it is a perfect shuffle without a buffer. The index is reshuffled every epoch.
- Parameters:
- indexnp.ndarray
Sequence index from
sequence_index().- slice_fncallable
Function from
make_slice_fn().- batch_sizeint
Number sequences in each mini-batch which is used to train the model.
- shufflebool, optional
Should we shuffle the sequences?
- drop_last_batchbool, optional
Should we drop the last batch if it is smaller than the batch size?
- seedint, optional
Seed for shuffling.
- Returns:
- datasettf.data.Dataset
Batched dataset. The number of batches is known (
dataset.cardinality()).