Python Forum
NameError: name 'predicted_labels' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError: name 'predicted_labels' is not defined
#1
Hello! I am trying to run the code from this tutorial: link-for-the-code

but on this part:

val_image_batch, val_label_batch = next(iter(valid_generator))

tf_model_predictions = model.predict(val_image_batch)
print("Prediction results shape:", tf_model_predictions.shape)
plt.figure(figsize=(10,9))
plt.subplots_adjust(hspace=0.5)
for n in range((len(predicted_labels)-2)): # here is the problem
 plt.subplot(6,5,n+1)
 plt.imshow(val_image_batch[n])
 color = "green" if predicted_ids[n] == true_label_ids[n] else "red"
 plt.title(predicted_labels[n].title(), color=color)
 plt.axis('off')
_ = plt.suptitle("Model predictions (green: correct, red: incorrect)")
I get this error:

Error:
NameError: name 'predicted_labels' is not defined
I am searching all day in order to find a solution via google...Nothing yet!! Has anyone, any idea how to solve it?
Reply


Messages In This Thread
NameError: name 'predicted_labels' is not defined - by hobbyist - Dec-07-2023, 05:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  NameError: name 'rand' is not defined Truman 7 6,895 Jun-17-2020, 07:14 PM
Last Post: Truman
  NameError mlab not defined PythonAndArduino 5 7,076 Nov-08-2017, 06:47 PM
Last Post: nilamo
  Python : NameError: name 'total_wait' is not defined carla 3 5,309 Jun-04-2017, 05:49 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020