Hi every one,
For the first part where you should write your code I think I write the indexes correctly because when i run the code where you print shape of X and Y mini batches the numbers are correct and i get all tests passed but for middle part i got “AssertionError: Wrong values. It happens if the order of X rows(features) changes” Can any one tell me what is the problem?
Thank you
There must be something wrong with the way you do the indexing. Just because the shapes are correct does not mean you extract that shape from the correct position. The most common problems are with the last partial minibatch. I suggest you add some print statements to your loop to show the “start” index you are computing for each minibatch. Do you get the pattern you expect, based on doing the computation with pencil and paper?
Thank you for your answer I checked every thing several times I don’t change the feature size I just put : for it .when I print(np.sum(np.sum(mini_batches[k][0] - mini_batches[k][0][0], axis=0))) I get the value 536477696 and when I print(((nx * (nx - 1) / 2 ) * mini_batch_size)) i get the value 4831444992.0 could you please tell me what does this line do ?
assert np.sum(np.sum(mini_batches[k][0] - mini_batches[k][0][0], axis=0)) == ((nx * (nx - 1) / 2 ) * mini_batch_size), “Wrong values. It happens if the order of X rows(features) changes”
I commented this line the other parts are ok
I think you are missing the point here. Changing the test is not the solution to the fact that the test fails. The failure of the test means that the contents of at least one of the minibatches is wrong. You need to be looking at your code. Did you try what I suggested: print the start index value of the first dimension of each batch, including the last partial batch. That is the most likely thing that is wrong.
Here, in the screenshot, the shapes and indexes of each mini-batch are depicted. Could you please help to understand the error
Interesting. I believe that all the shapes and “start, end” numbers you show are correct. But there must still be something wrong with how you are selecting the elements of the X minibatches. What that test is checking for is the actual X values in each minibatch. The way the test data is constructed, it is a sequence of consecutive integers starting from 0 and they are checking your results by using the famous formula that Gauss figured out when he was 10 years old:
\displaystyle \sum_{i = 1}^{n} i = \frac{n(n+1)}{2}
Notice also that it’s failing on one of the “normal” minibatches, not the last partial one. So it’s worth taking a careful look at how you are applying your start and end values to extract the elements.
If that’s not enough of a hint to get you to a solution, then we’ll probably need to look at your code, but we’ll need to use a private DM thread for that. I’ll send you a DM (Direct Message) about how to proceed on that.