简体   繁体   English

Tensorflow - 抛出批量大小问题

[英]Tensorflow - batch size issue thrown

I am following along this tutorial ( https://colab.research.google.com/github/khanhlvg/tflite_raspberry_pi/blob/main/object_detection/Train_custom_model_tutorial.ipynb ) from Colab and running it on my own Windows machine.我正在遵循来自 Colab 的本教程 ( https://colab.research.google.com/github/khanhlvg/tflite_raspberry_pi/blob/main/object_detection/Train_custom_model_tutorial.ipynb ) 并在我自己的 Windows 机器上运行它。

When I debug my script it throws me this error > 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. 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.

On this snippet of my code在我的代码片段中

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

My own train data contains 101 images and the example from Colab only contains 62 in their training folder.我自己的训练数据包含 101 张图像,而来自 Colab 的示例在其训练文件夹中仅包含 62 张。

I understand it's complaining about training data can't be smaller than batch size but I don't understand why its throwing it in the first place since my training data is not empty.我知道它在抱怨训练数据不能小于批量大小,但我不明白为什么它首先将它扔掉,因为我的训练数据不为空。

On my own machine I have Tensorflow Version: 2.8.0 just like in the colab.在我自己的机器上,我有 Tensorflow 版本:2.8.0 就像在 colab 中一样。

I've tried increasing batch sizes all the way from 0 to 100plus but stil gives me the same error.我尝试将批量大小从 0 一直增加到 100plus,但仍然给我同样的错误。

I've tried dropping one sample so there are 100 images and setting sample size to 2, 4 etc... but still throws the error.我试过删除一个样本,这样就有 100 张图像,并将样本大小设置为 2、4 等......但仍然会抛出错误。

I'm leading to the conclusion that it is not loading in the data correctly but why?我得出的结论是它没有正确加载数据,但为什么呢?

For anybody running into the same issue as I was, here was my solution.对于遇到与我相同问题的任何人,这是我的解决方案。

Okay so the reason this is happening is because of different versions of Python.好吧,发生这种情况的原因是因为 Python 的不同版本。

I was trying to run this locally with Python 3.8.10我试图用 Python 3.8.10 在本地运行

Colab is running 3.7.12. Colab 正在运行 3.7.12。

I ran all of my data on colab using version (3.7.12) and trained my model with no more further issues.我使用版本 (3.7.12) 在 colab 上运行了我的所有数据,并训练了我的 model,没有更多问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM