簡體   English   中英

Tensorflow - 拋出批量大小問題

[英]Tensorflow - batch size issue thrown

我正在遵循來自 Colab 的本教程 ( https://colab.research.google.com/github/khanhlvg/tflite_raspberry_pi/blob/main/object_detection/Train_custom_model_tutorial.ipynb ) 並在我自己的 Windows 機器上運行它。

當我調試我的腳本時,它拋出這個錯誤 > The size of the train_data (0) couldn't be smaller than batch_size (4). To solve this problem, set the batch_size smaller or increase the size of the train_data. The size of the train_data (0) couldn't be smaller than batch_size (4). To solve this problem, set the batch_size smaller or increase the size of the train_data.

在我的代碼片段中

model = object_detector.create(train_data, model_spec=spec, batch_size=4, train_whole_model=True, epochs=20, validation_data=val_data)

我自己的訓練數據包含 101 張圖像,而來自 Colab 的示例在其訓練文件夾中僅包含 62 張。

我知道它在抱怨訓練數據不能小於批量大小,但我不明白為什么它首先將它扔掉,因為我的訓練數據不為空。

在我自己的機器上,我有 Tensorflow 版本:2.8.0 就像在 colab 中一樣。

我嘗試將批量大小從 0 一直增加到 100plus,但仍然給我同樣的錯誤。

我試過刪除一個樣本,這樣就有 100 張圖像,並將樣本大小設置為 2、4 等......但仍然會拋出錯誤。

我得出的結論是它沒有正確加載數據,但為什么呢?

對於遇到與我相同問題的任何人,這是我的解決方案。

好吧,發生這種情況的原因是因為 Python 的不同版本。

我試圖用 Python 3.8.10 在本地運行

Colab 正在運行 3.7.12。

我使用版本 (3.7.12) 在 colab 上運行了我的所有數據,並訓練了我的 model,沒有更多問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM