05_transfer_learning_in_tensorflow_part_2_fine_tuning.ipynb #456
Unanswered
surabhip14
asked this question in
Q&A
Replies: 1 comment
-
Hi @surabhip14 , could you link your notebook file? I think the code should work. I too seem to recall that I used this kind of code to extract labels. Please correct me if I am wrong, the indentation was due to markdown write? not because you had wrote your code in this form.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi There,
I created the train/test datasets using the method taught in the fine tuning section of the Tensorflow course by Daniel. (Code snippets below). However am unable to extract the actual labels from the batched dataset, because of which am unable to create confusion matrix.
This is a binary image classification problem that am working on
I/P data:
IMG_SIZE = (224, 224)
BATCH_SIZE = 32
train_data = tf.keras.preprocessing.image_dataset_from_directory(train_dir,
label_mode="binary",
image_size=IMG_SIZE,
batch_size =BATCH_SIZE)
test_data = tf.keras.preprocessing.image_dataset_from_directory(test_dir,
label_mode="binary",
image_size=IMG_SIZE,
batch_size =BATCH_SIZE,
shuffle=False) # don't shuffle test data for prediction analysis
Unbatching the Test data for collecting y_true lables gives me error as below:
ds_labels=[]
for images, labels in test_data.unbatch():
ds_labels.append(labels)
ERROR:
RuntimeError:
tf.data.Dataset
only supports Python-style iteration in eager mode or within tf.function.Would you know how can I extract labels from tf.dataset object created using image_dataset_from_directory??? Nothing seems to work or iterate over this object, while my model seems to be working fine with an accuracy of 77%.
Beta Was this translation helpful? Give feedback.
All reactions