W3 assignment errors messages

Reload the images in case you run this cell multiple times

(training_images, _), _ = tf.keras.datasets.mnist.load_data(path=data_path)

Apply your function

training_images = reshape_and_normalize(training_images)

print(f"Maximum pixel value after normalization: {np.max(training_images)}\n")
print(f"Shape of training set after reshaping: {training_images.shape}\n")
print(f"Shape of one image after reshaping: {training_images[0].shape}")

Here is error message

NameError Traceback (most recent call last)
4 # Apply your function
----> 5 training_images = reshape_and_normalize(training_images)
7 print(f"Maximum pixel value after normalization: {np.max(training_images)}\n")

in reshape_and_normalize(images)
7 # Reshape the images to add an extra dimension
----> 8 training_images = training_image.reshape(60000,28,28,1)
9 training_images = np.expand_dims(training_images, axis =-1)
10 # Normalize pixel values

NameError: name ‘training_image’ is not defined

@Chris.X @paulinpaloalto

@Chris.X please kindly help me out​:pray:t2:


You can DM me the source code of your homework as before then we can inspect it, thanks.

Your profile is now hidden​:pleading_face:

@KINGSLEY_TOM I guess now you can. Basically, you can attach the code in the thread so that other guys can also see and give suggestions.

Is that line in a loop? That could explain why that reference is to training_image but elsewhere it’s always training_images with a trailing s. The 60000 first dimension suggests to me they should all be the same but I don’t have the rest of the code.

You misspelled the name of the variable, right? training_image is not the same as training_images.

Also note that you filed this under “General Discussions”, so it’s really not clear which course you are talking about. You’ll generally have better luck getting answers if you file things under the relevant categories. Note that you can edit that using the little “edit pencil” on the title. I’d offer to move it for you, but I don’t recognize which course this is from.

Likely TF Developer Professional Certificate. TF1 W3

@KINGSLEY_TOM One of your other posts had an error due to leading Upper Case where it should have been lower, while this one truncates the last character. This level of attention to detail is critical and given this pattern, I recommend that you devote some time to close inspection of variable names whenever you get unexpected results.