Week 2 Exercise 2 - random_mini_batches -AssertionError: Wrong values

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.