I am reviewing the input data structure in the CBOW in Week 4/Course 2, and in Trax in Week 1/Course 3 for the embedding layer.
In Week 4/Course 2, it uses “get_batches” function to generate V X batches_size
data matrix to feed into “gradient_descent” function. However, all those columns are the same.
If I set batch_size to 1, or batch_size to 128 as in the assignment, the results are all the same. For this assignment, the data is only single list of words.
So what’s the purpose of using this “get_batches” as the function to generate input data structure in COBW as it does not do anything to get “next” batch as in Week 1/Course 3?
It just appends the same data again and again.
It confuses how the batch_size works, and what input data structure should look like in COBW alone.
def get_batches(data, word2Ind, V, C, batch_size):
batch_x = []
batch_y = []
for x, y in get_vectors(data, word2Ind, V, C):
while len(batch_x) < batch_size:
batch_x.append(x)
batch_y.append(y)
else:
yield np.array(batch_x).T, np.array(batch_y).T
batch_x = []
batch_y = []
W1_batch_1 = np.copy(W1)
W1_batch_128 = np.copy(W1)
check_eqv = abs(W1_batch_1 - W1_batch_128) < 1e-7
np.sum(check_eqv==False)
0