I am facing a little trouble with the lab assignment for Week 4. Specifically exercise 3 on the center_data function.
So I filled out the function and it seems to work because the cat picture in the code block right below generates correctly. However, the unit tester says 1 test passed and the other failed and the grader gives me a zero for the exercise.
I am suspicious that it is not the same cat though, and I don’t know if that makes a difference or if all of the operations we have done up to then have scrambled the order of the images.
Here is what I have so far for the function:
# Graded cell
def center_data(Y):
"""
Center your original data
Args:
Y (ndarray): input data. Shape (n_observations x n_pixels)
Outputs:
X (ndarray): centered data
"""
### START CODE HERE ###
# mentor edit: code removed
### END CODE HERE ###
return X
Also note that they make things a lot more complicated than they need to be in the instructions for this section. If you just use keepdims = True when you compute the mean as a vector, then don’t need to use repeat and reshape: just take advantage of “broadcasting” when you subtract the mean to get the final “centered” data.
It’s great news that you found the solution based on those hints!
The “meta” lesson here is that when you’re just 100% sure that your code is right but it still fails, it’s always worth just taking a couple of deep calming breaths and then having a careful look at the instructions again with the thought in mind that maybe you missed something the first time through.