A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://scikit-learn.org/dev/developers/../api/../modules/generated/sklearn.utils.gen_batches.html below:

gen_batches — scikit-learn 1.8.dev0 documentation

gen_batches#
sklearn.utils.gen_batches(n, batch_size, *, min_batch_size=0)[source]#

Generator to create slices containing batch_size elements from 0 to n.

The last slice may contain less than batch_size elements, when batch_size does not divide n.

Parameters:
nint

Size of the sequence.

batch_sizeint

Number of elements in each batch.

min_batch_sizeint, default=0

Minimum number of elements in each batch.

Yields:
slice of batch_size elements

Examples

>>> from sklearn.utils import gen_batches
>>> list(gen_batches(7, 3))
[slice(0, 3, None), slice(3, 6, None), slice(6, 7, None)]
>>> list(gen_batches(6, 3))
[slice(0, 3, None), slice(3, 6, None)]
>>> list(gen_batches(2, 3))
[slice(0, 2, None)]
>>> list(gen_batches(7, 3, min_batch_size=0))
[slice(0, 3, None), slice(3, 6, None), slice(6, 7, None)]
>>> list(gen_batches(7, 3, min_batch_size=2))
[slice(0, 3, None), slice(3, 7, None)]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4