Week 2 Assignment: Wrong Shape of Data

ValueError: decode_predictions expects a batch of predictions (i.e. a 2D array of shape (samples, 1000)). Found array with shape: (32, 5, 5, 1280)

I do not know why I am getting this error
The block of code that gives me this error is below

base_model.trainable = False
image_var = tf.Variable(image_batch)
pred = base_model(image_var)

tf.keras.applications.mobilenet_v2.decode_predictions(pred.numpy(), top=2)

I believe that this is code that is pre-programmed and not part of the assignment. Please forgive me if this is not so; I have no intention of breaking the honor code

It would help if you quoted the entire stack trace for the error.

Complete Stack Trace is below.

ValueError Traceback (most recent call last)
in
3 pred = base_model(image_var)
4
----> 5 tf.keras.applications.mobilenet_v2.decode_predictions(pred.numpy(), top=2)

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/applications/mobilenet_v2.py in decode_predictions(preds, top)
505 @keras_export(‘keras.applications.mobilenet_v2.decode_predictions’)
506 def decode_predictions(preds, top=5):
→ 507 return imagenet_utils.decode_predictions(preds, top=top)
508
509

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/applications/imagenet_utils.py in decode_predictions(preds, top)
149 'a batch of predictions ’
150 '(i.e. a 2D array of shape (samples, 1000)). ’
→ 151 'Found array with shape: ’ + str(preds.shape))
152 if CLASS_INDEX is None:
153 fpath = data_utils.get_file(

ValueError: decode_predictions expects a batch of predictions (i.e. a 2D array of shape (samples, 1000)). Found array with shape: (32, 5, 5, 1280)

If I’m reading it correctly, I think the only way an error would occur there is if you accidentally modified some of the provided code cells.

“base_model” is a global variable, and it’s created earlier in the notebook, in a cell that’s just below Figure 1.

Would it be the block labeled In [9]:

Is there a way to get back to the original block without losing all that I have done so far?

Ok, the In [9] block was one that I was supposed to edit.
But, I think that I did modify one of the provided code cells
Is there a way to get to the original setup without losing what I have done

Well, I got past that error
Had an include_top boolean set wrong