<ipython-input-63-2caeb7a27c84> in <module>
15 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"
16 if ( m % mini_batch_size > 0):
---> 17 assert mini_batches[n_batches - 1][0].shape == (nx, m % mini_batch_size), f"Wrong shape in the last minibatch. {mini_batches[n_batches - 1][0].shape} != {(nx, m % mini_batch_size)}"
18
19 assert np.allclose(mini_batches[0][0][0][0:3], [294912, 86016, 454656]), "Wrong values. Check the indexes used to form the mini batches"
AttributeError: 'int' object has no attribute 'shape'```
I get the above error in minibatch implementation. This was asked before but not solved.
type(mini_batches[n_batches - 1][0])
should be numpy.ndarray
. Python int object doesn’t have shape
attribute and hence the problem.
I understand the error source, I just don’t understand how to get rid of it. Is the validation code incorrect or does my implementation of how I deal with the last batch buggy?
The last 2 statements are wrong since you’re not creating mini batches but scalars that represent the size of mini batches.
Please remove code from you previous reply. Posting code in public is likely to get your account suspended.