MCPcopy Create free account
hub / github.com/rushter/MLAlgorithms / batch_iterator

Function batch_iterator

mla/utils/main.py:10–25  ·  view source on GitHub ↗

Splits X into equal sized chunks.

(X, batch_size=64)

Source from the content-addressed store, hash-verified

8
9
10def batch_iterator(X, batch_size=64):
11 """Splits X into equal sized chunks."""
12 n_samples = X.shape[0]
13 n_batches = n_samples // batch_size
14 batch_end = 0
15
16 for b in range(n_batches):
17 batch_begin = b * batch_size
18 batch_end = batch_begin + batch_size
19
20 X_batch = X[batch_begin:batch_end]
21
22 yield X_batch
23
24 if n_batches * batch_size < n_samples:
25 yield X[batch_end:]

Callers 3

_trainMethod · 0.90
_predictMethod · 0.90
train_epochMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected