TypeError in Week Four Lab Assignment 3

I am receiving a TypeError that I can’t resolve. Here is my error message:


TypeError Traceback (most recent call last)
in
----> 1 X = center_data(imgs_flatten)
2 plt.imshow(X[0].reshape(64,64), cmap=‘gray’)

in center_data(Y)
10 ### START CODE HERE ###
11 mean_vector = Y.mean(axis=0, dtype=np.float64)
—> 12 mean_matrix = Y.repeat(mean_vector, Y.shape[0])
13 # use np.reshape to reshape into a matrix with the same size as Y. Remember to use order=‘F’
14 mean_matrix = Y.reshape(mean_matrix, Y.shape, order=‘F’)

TypeError: Cannot cast array data from dtype(‘float64’) to dtype(‘int64’) according to the rule ‘safe’

I would appreciate any help. Thank you.

Using repeat() as a “method” of Y, means you are saying you want to repeat Y and then the first argument is the “repeat count”, which needs to be an integer. But you are feeding it an array of 64 bit floats as the repeat count.

But it’s a mistake on two levels: Y is not the thing you want to repeat, is it?

Thanks Paul!