Issue
I am using the below function to read images from a directory
train_ds = tf.keras.preprocessing.image_dataset_from_directory(directory=image_dataset_path,
validation_split=0.2,
subset='training',
batch_size=32,
color_mode='rgb',
seed=1)
and it display below text in the output
Found 284 files belonging to 5 classes.
Using 228 files for training.
After exploring the above function here I am not able to find out how it is displaying the text in the console. One thing that I noticed is that the output of the function is a dataset but how does it generate the text in console?
Please help me understand How tf.keras is showing this output in the console. What is the exact code behind this?
Solution
Those two statements are the result of two helper functions used by tf.keras.preprocessing.image_dataset_from_directory
.
See the relevant part of those functions below:
dataset_utils.index_directory.
if labels is None: print('Found %d files.' % (len(filenames),)) else: print('Found %d files belonging to %d classes.' % (len(filenames), len(class_names)))
dataset_utils.get_training_or_validation_split
if subset == 'training': print('Using %d files for training.' % (len(samples) - num_val_samples,)) samples = samples[:-num_val_samples] labels = labels[:-num_val_samples]
Those two helper functions simply print those messages in the standard output as a way to provide information to the developer.
Answered By - Lescurel Answer Checked By - Terry (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.