Skip to content

Instantly share code, notes, and snippets.

View socket-var's full-sized avatar
🎯
Maker of things, breaker of things, fixer of things

Saketh Varma Pericherla socket-var

🎯
Maker of things, breaker of things, fixer of things
  • Invitae
  • Palo Alto, California
View GitHub Profile
@socket-var
socket-var / random_minibatches.py
Last active August 1, 2019 16:31
Generates random mini-batches
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