forked from sischei/DeepEquilibriumNets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
26 lines (20 loc) · 789 Bytes
/
utils.py
File metadata and controls
26 lines (20 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""TODO(@azinoma)."""
import tensorflow as tf
import math
import numpy as np
def random_mini_batches(X, minibatch_size=64, seed=0):
"""Generate random minibatches from X."""
np.random.seed(seed)
m = X.shape[0]
mini_batches = []
# Step 1: Shuffle X
permutation = list(np.random.permutation(m))
shuffled_X = X[permutation, :]
# Step 2: Partition shuffled_X. Minus the end case.
# number of mini batches of size mini_batch_size in your partitionning
num_complete_minibatches = int(math.floor(m / minibatch_size))
for k in range(0, num_complete_minibatches):
mini_batch_X = shuffled_X[(k * minibatch_size):((k+1) * minibatch_size), :]
mini_batch = (mini_batch_X)
mini_batches.append(mini_batch)
return mini_batches