序列数据(1)的大小不能小于批量数据(32)

2024-04-26 18:42:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我的结构资产到培训(tflite)

!ls  /root/.keras/datasets/model_test/
!ls  /root/.keras/datasets/model_test/abrasive/
abrasive  adhesive
'abrasive (1).jpg'  'abrasive (2).jpg'  'abrasive (3).jpg'

初始化ImageClassifierDataLoader

data = ImageClassifierDataLoader.from_folder(image_path)
train_data, test_data = data.split(0.3)
INFO:tensorflow:Load image with size: 6, num_label: 2, labels: abrasive, adhesive.
INFO:tensorflow:Load image with size: 6, num_label: 2, labels: abrasive, adhesive.

当我尝试使用自定义模型时

model = image_classifier.create(train_data)

我得到

ValueError: The size of the train_data (1) couldn't be smaller than batch_size (32). To solve this problem, set the batch_size smaller or increase the size of the train_data.

这是什么意思?数据测试必须为>;32 ?? 批量大小在哪里

我发现了同样的东西,但完全不同,我没有得到它(不简单)Increasing batch_size of dataset for Pytorch neural network


Tags: ofthetestimagedatasizemodelbatch
2条回答

不要使用批次大小,因为当数据集非常大,并且您希望通过将数据拆分为批次来训练数据以改进训练过程时,会使用批次大小

创建模型时,create()函数提供了定义batch_size(默认值为32)的可能性。要重用您的示例,您可以编写:

model = image_classifier.create(train_data, batch_size=1)

另见Change the training hyperparameters

相关问题 更多 >