What's the purpose of batch_size in the "get_batches" function in "utils2.py"

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:
            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


Hi @Eureka

Could you explain more what do you mean by saying:

However, all those columns are the same.

Also I’m not sure what do you expect check_eqv variable to be when you copy the exact same variable (W1) ?

I should be more clear that

The first W1 from the results when running at batch_size = 1, and the second W1 from the results when running at batch_size = 128 with the assignment’s setting. That’s why I renamed them to W1_batch_1 and W1_batch_128.

If you run the above function from the utils2.py, with
test_data = ["I", "am", "happy", "because", "I", "am", "learning"], and batch_size = 5,
You will get exactly the same 5 columns in batch_x output.
I think this is clear from the function itself.

However, running

test_data =[ ["I", "am", "happy", "because", "I", "am", "learning"], ["this", "is", "a", "beautiful", "day"]]

won’t work on this function.
That’s why I am confused what’s the purpose of this get_batches function, what’s the purpose to duplicate the columns multiple times.