第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何知道 flow_from_directory 中的圖像數(shù)量

如何知道 flow_from_directory 中的圖像數(shù)量

慕少森 2022-11-01 14:29:01
我們可以使用帶有 flow_from_directory 方法的 ImageDataGenerator 生成圖像數(shù)據(jù)集。train_datagen = ImageDataGenerator(    rescale=1./255, #scale images from integers 0-255 to floats 0-1.    shear_range=0.2,    zoom_range=0.2, # zoom in or out in images    horizontal_flip=True) #horizontal flip of imagestrain_set = train_datagen.flow_from_directory(..)并顯示:Found 200 images belonging to 2 classes我想寫一個(gè)循環(huán)來計(jì)算train_set上的圖像數(shù)量For image in train_set:    count = count+1print(count)但這并沒有顯示任何東西!
查看完整描述

3 回答

?
楊__羊羊

TA貢獻(xiàn)1943條經(jīng)驗(yàn) 獲得超7個(gè)贊

得到?jīng)]有。圖像,請(qǐng)嘗試使用以下代碼。

train_set.samples


查看完整回答
反對(duì) 回復(fù) 2022-11-01
?
Qyouu

TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超11個(gè)贊

要訪問數(shù)據(jù)集的樣本數(shù)量,您首先必須知道它是哪種類型:

如果您使用的是 ImageDataGenerator,那么:

type(train_ds)

將返回 tensorflow.python.keras.preprocessing.image.DirectoryIterator。在這種情況下,您可以通過以下方式訪問樣本數(shù)量:

train_ds.samples

但是,如果您正在使用以下方法創(chuàng)建數(shù)據(jù)集:

train_ds = tf.keras.preprocessing.image_dataset_from_directory( rescale = 1/255. , etc...)

然后

type(train_ds)

將返回 tensorflow.python.data.ops.dataset_ops.BatchDataset 這意味著您可以使用間接訪問樣本數(shù)

len(train_ds.file_paths)


查看完整回答
反對(duì) 回復(fù) 2022-11-01
?
DIEA

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超2個(gè)贊

__iter__將是您的解決方案。

首先,您嘗試預(yù)測(cè)train_set的類型。如果您不知道。

print(type(train_set))
#then you find **keras.preprocessing.image.DirectoryIterator**

現(xiàn)在您想對(duì)這種類型的數(shù)據(jù)應(yīng)用一些功能或修改,請(qǐng)點(diǎn)擊此處的鏈接


查看完整回答
反對(duì) 回復(fù) 2022-11-01
  • 3 回答
  • 0 關(guān)注
  • 182 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)