Python Minibatch

Minibatch?

Mini batch is from Training from Machine Learning.

For training, if we use all training data, training calculation takes a lot of time.

To avoid this, we can use partial data training. This is mini batch

Get Random data from 1 dim Numpy array

import numpy as np

batch_size = 100
train_size = 1000

x_train = np.random.randn(train_size)

batch_mask = np.random.choice(train_size, batch_size)  # Pick 100 from 1000

print(batch_mask)  # Create mask index

batch_train = x_train[batch_mask]

print(x_train)
print(batch_train)
Python
スポンサーリンク
Professional Programmer2

コメント