Partitioning Algorithm seems to work fine, but fails two tests

I’m in the Programming Assignment for Optimization Algorithms, and I’m stuck on Exercise 2, where I need to partition a batch into some mini-batches.

The algorithm passes all tests for the first cell, but fails two tests in the second cell. It doesn’t specify what exactly went wrong.

The algorithm I came up with works perfectly fine when partitioning data in my python terminal, so I am completely clueless.

Here is the error:
shape of the 1st mini_batch_X: (12288, 64)
shape of the 2nd mini_batch_X: (12288, 64)
shape of the 3rd mini_batch_X: (12288, 20)
shape of the 1st mini_batch_Y: (1, 64)
shape of the 2nd mini_batch_Y: (1, 64)
shape of the 3rd mini_batch_Y: (1, 20)
mini batch sanity check: [ 0.90085595 -0.7612069 0.2344157 ]
1 Tests passed
2 Tests failed

AssertionError Traceback (most recent call last)
in
10 print ("mini batch sanity check: " + str(mini_batches[0][0][0][0:3]))
11
—> 12 random_mini_batches_test(random_mini_batches)

~/work/release/W2A1/public_tests.py in random_mini_batches_test(target)
82 ]
83
—> 84 multiple_test(test_cases, target)
85
86

/opt/conda/lib/python3.7/site-packages/dlai_tools/testing_utils.py in multiple_test(test_cases, target)
162 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
163 raise AssertionError(
→ 164 “Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))

AssertionError: Not all tests were passed for random_mini_batches. Check your equations and avoid using global variables inside the function.

When there are 3 tests, they typically are:

  1. Check the data type of the result
  2. Check the shape of the result
  3. Check the actual values of the result

So if you pass 1 or 2 tests, that is not a reason to celebrate, meaning that it is a low bar.

But this is pretty hard to diagnose just based on this type of info. It’s probably better just to look at your code. Please check your DMs for a message from me.