Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Keras-用于大型图像和遮罩数据集的生成器_Python_Machine Learning_Computer Vision_Theano_Keras - Fatal编程技术网

Python Keras-用于大型图像和遮罩数据集的生成器

Python Keras-用于大型图像和遮罩数据集的生成器,python,machine-learning,computer-vision,theano,keras,Python,Machine Learning,Computer Vision,Theano,Keras,我试图建立一个模型,它的输入和输出都有图像(遮罩)。 由于数据集的大小和我有限的内存,我尝试使用: 除了代码到达这一行之外,其他一切似乎都正常工作: train_generator = zip(image_generator, mask_generator) 似乎压缩这两个列表的过程显式地让它们生成内容,系统开始消耗大量RAM,直到内存耗尽 使用生成器的目的是避免在这段代码执行相反操作时耗尽RAM 有没有办法解决这个问题?您可以使用itertools.izip()返回迭代器而不是列表 iter

我试图建立一个模型,它的输入和输出都有图像(遮罩)。 由于数据集的大小和我有限的内存,我尝试使用:

除了代码到达这一行之外,其他一切似乎都正常工作:

train_generator = zip(image_generator, mask_generator)
似乎压缩这两个列表的过程显式地让它们生成内容,系统开始消耗大量RAM,直到内存耗尽

使用生成器的目的是避免在这段代码执行相反操作时耗尽RAM


有没有办法解决这个问题?

您可以使用
itertools.izip()
返回迭代器而不是列表

itertools.izip(*iterables)

Make an iterator that aggregates elements from each of the iterables. Like zip() except that it returns an iterator instead of a list. Used for lock-step iteration over several iterables at a time.

您能否分享您的完整解决方案,包括
itertools.izip()
itertools.izip(*iterables)

Make an iterator that aggregates elements from each of the iterables. Like zip() except that it returns an iterator instead of a list. Used for lock-step iteration over several iterables at a time.