Files
Obsidian-Main/20.01. Programming/Keras/Keras.tensorflow - Dataset.md

11 lines
706 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
可以使用 `tensorflow.keras.utils.image_dataset_from_directory` 來建立 dataset。
dataset 會有 `data_batch``label_batch` 這兩個 member分別代表資料與標籤。
可以用 `dataset.batch(32)` 改變 batch size。
還有一些其他的有用function:
- `shuffle(buffer_size)`: 打亂順序,可參考[[Keras.tensorflow - shuffle#^832c8c]]
- `prefetch(buffer_size)`: 設定預讀的大小
- `map(callback_func)`: 用 callback_func 來處理資料
- `take(N)`: 取出第N筆的批次資料注意這一筆是一個批次資料裡面可能有32筆資料或其他數量看你的 `dataset.batch(N)` 怎麼設定)。
打亂data的方法請看[[Keras.tensorflow - shuffle]]