我想从caltech256数据集中只加载几个类,并且由于类的数量会随着每次实验而变化,因此我无法手动完成我想知道是否有一种方法在imagedataggenerator的tensorlflow,这将允许我这样做到目前为止我所做的是
from google.colab import drive
drive.mount('/content/gdrive')
import pathlib
data = pathlib.Path('/content/gdrive/My Drive/Data_Clatech256/2_categ_caltech')
from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(
)
test_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
data,
target_size=(150, 150),
batch_size=3,
class_mode = "categorical"
)
感谢大家的努力
的"类">参数是你需要的,遵循这个源代码链接,它向我们展示了类是用来列出我们想要的。和flow_from_directory函数显示了一个名为classes
的参数flow_from_directory(
directory, target_size=(256, 256), color_mode='rgb', classes=None,
class_mode='categorical', batch_size=32, shuffle=True, seed=None,
save_to_dir=None, save_prefix='', save_format='png',
follow_links=False, subset=None, interpolation='nearest'
)