简体   繁体   English

为什么keras中的model.fit函数会显着增加RAM内存?

[英]Why model.fit function in keras significantly increase RAM memory?

I load my data with open_memmap function and it takes 5GB RAM memory. 我使用open_memmap函数加载数据,它占用5GB RAM内存。 Then I compile the model which has params: 89,268,608 and it does not take any RAM memory. 然后,我编译具有参数的模型:89,268,608,它不占用任何RAM内存。 My batch size is 200 at the moment and the input image has shape (300,54,3). 我的批量大小目前为200,输入图像的形状为(300,54,3)。

My problem is when I call the model.fit function in keras my RAM memory increase from 5 GB to 24GB. 我的问题是当我在keras中调用model.fit函数时,我的RAM内存从5 GB增加到24GB。 My question is why? 我的问题是为什么?

When I try with different batch sizes nothing is changing and still 23 GB of RAM are occupied? 当我尝试使用不同的批处理大小时,没有任何变化,仍然占用了23 GB的RAM?

If somebody can explain me what is happening I would highly appreciate it, 如果有人可以解释我的情况,我将不胜感激,

Thanks! 谢谢!

Keras' fit method loads all the data into memory at once meaning changing your batch size will have no effect on the RAM it takes up. Keras的fit方法可一次将所有数据加载到内存中,这意味着更改批处理大小不会对其占用的RAM产生影响。 Have a look at using fit_generator which is designed for use with a large dataset. 看一下适合用于大型数据集的fit_generator

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

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