Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Maker of things, breaker of things, fixer of things

Saketh Pericherla socket-var

🎯
Maker of things, breaker of things, fixer of things
  • Ciitizen
  • Palo Alto, California
View GitHub Profile
@socket-var
socket-var / random_minibatches.py
Last active Aug 1, 2019
Generates random mini-batches
View random_minibatches.py
def batch(X,Y,batch_size,seed = 0):
np.random.seed(seed)
m = X.shape[0] #total no of images
batches = []
# Shuffle data
perm = list(np.random.permutation(m))
shuffled_X = X[perm,:]
shuffled_Y = Y[perm,:]
# Partition (shuffled_X, shuffled_Y)
num_minibatches = math.floor(m/batch_size) # number of mini batches of required size in our partitioning