Week2 Exercise 5 Image2 Vector Error

Hi, can you help with the traceback error at the end.

{moderator edit - solution code removed}

This is a 3 by 3 by 2 array, typically images will be (num_px_x, num_px_y,3) where 3 represents the RGB values

t_image = np.array([[[ 0.67826139, 0.29380381],
[ 0.90714982, 0.52835647],
[ 0.4215251 , 0.45017551]],

[[ 0.92814219, 0.96677647],
[ 0.85304703, 0.52351845],
[ 0.19981397, 0.27417313]],

[[ 0.60659855, 0.00533165],
[ 0.10820313, 0.49978937],
[ 0.34144279, 0.94630077]]])

print ("image2vector(image) = " + str(image2vector(t_image)))

image2vector_test(image2vector)

image2vector(image) = [[0.67826139]
[0.29380381]
[0.90714982]
[0.52835647]
[0.4215251 ]
[0.45017551]
[0.92814219]
[0.96677647]
[0.85304703]
[0.52351845]
[0.19981397]
[0.27417313]
[0.60659855]
[0.00533165]
[0.10820313]
[0.49978937]
[0.34144279]
[0.94630077]]

NameError Traceback (most recent call last)
in
14 print ("image2vector(image) = " + str(image2vector(t_image)))
15
—> 16 image2vector_test(image2vector)

NameError: name ‘image2vector_test’ is not defined

That means you have not run the previous cells in the notebook since the last time you closed and reopened it. Try “Cell → Run All Above” and then run the test again.

1 Like

Thank-you that worked