简单的CNN二进制分类网络,该网络具有由100000多个图像文件组成的数据集

发布于 2025-02-07 22:37:18 字数 122 浏览 4 评论 0原文

我正在尝试为二进制分类构建一个简单的CNN模型,但培训数据集由超过100K的“ .png”文件组成。如果我通过一次加载所有数据来训练模型,它将创建MemoryExhustion错误。有人可以帮助我建立网络来处理如此庞大的数据集吗?

I am trying to build a simple CNN model for binary classification but the training dataset consists of over 100k of '.png' file. If I train the model by loading all the data at once, it will create a MemoryExhaustion Error. Can somebody help me to build the network to deal with such huge dataset?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坚持沉默 2025-02-14 22:37:18

您可以使用收益语句流式传输。

def load_at_once(image_names):
    return [load(image_name) for image_name in image_names] # memory exhaust

def load_stream(image_names):
    for image_name in image_names:
        yield load(image_name)

您可以使用语句的迭代图像。 load_stream功能将一一加载图像,如果您不尝试将所有图像保存在内存中,则可以防止内存排气。

当然,流媒体比将图像多次多次加载到内存时要慢,因为它每次要使用时都会读取图像。

You can stream with yield statement.

def load_at_once(image_names):
    return [load(image_name) for image_name in image_names] # memory exhaust

def load_stream(image_names):
    for image_name in image_names:
        yield load(image_name)

You can iterate images with for statement. load_stream function will load image one by one and prevent memory exhaust if you don't try saving all images in memory.

Of course streaming is slower than loading everything to memory when you use images more than one time, because it will read image every time you want to use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文