Images at the end of C3_W1_KMeans_Assignment are completely black

I did the coding exercise and submission was graded as success, but this (black images at the end) don’t seem right.

Ok, I figured it out…
There was this transformation in one of the cells original_img = original_img / 255

If that cell is run multiple times, rgb values of the image will become close to zero as they are divided by 255 multiple times.

Using a different varibles names for the transformed values can be a defensive strategy to avoid issue like this.

2 Likes

Hey @vangap,
Glad that you were able to figure it out by yourself.

Cheers,
Elemento

Hi,
I still got the images all drak after changing to a different varibles names. Could you maybe share your edited codes?

Hey @Zipeng_Huang,
Welcome to the community. As @vangap stated, the issue is simply due to running the same cell more than once. How about after passing all the test cases, you restart the kernel and run all the cells once? You can do this by selecting the option of “Restart and Run all” in the Kernel menu on the toolbar. Let me know if this resolves the issue.

Cheers,
Elemento

Thank you! That works now!

Hi,

My suggestion to use different variable names was just as a defensive programming technique to protect us from issues like this. If you run all the cells only once, then there shouldn’t be any issue.