[英]How can I explore and modify the created dataset from tf.keras.preprocessing.image_dataset_from_directory()?
[英]how to obtain the number of classes using tf.keras.preprocessing.image_dataset_from_directory?
img_height,img_width=180,100 batch_size=32 train_ds = tf.keras.preprocessing.image_dataset_from_directory(data_dir1,validation_split=0.01,subset="training",seed=123,image_size=(img_height, img_width),batch_size=batch_size)
输出:找到属于 4 个类的 1376 个文件。 使用 1363 文件进行训练。
如何获取变量中的类总数?
如果你有类似的东西
train_gen=tf.keras.preprocessing.image_dataset_from_directory(etc
那么您可以使用下面的代码来获取您想要的信息类型
classes=list(train_gen.class_indices.keys())
class_indices=list(train_gen.class_indices.values())
num_of_classes=len(classes)
train_gen.class_indices 是 {class: index} 形式的字典
label_map = (train.ds.class_indices)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.