Keras model.fit_generator () is several times slower than model.fit ()

Even in the case of Keras 1.2.2, referring to merge , it includes multiprocessing, but model.fit_generator() is still about 4-5x slower than model.fit() due to disk read speed limitations. How can this be accelerated, say, by additional multiprocessing?

+8
source share
3 answers

You can check the workers and max_queue_size fit_generator() parameters in the documentation. Essentially, more workers create more threads to load data into a queue that transfers data to your network. There is a possibility that filling the queue can cause memory problems, so you can reduce max_queue_size to avoid this.

+2
source

I had a similar problem when I switched to dask to load data into memory, and not using the generator where I used pandas. Thus, depending on your data size, if possible, load the data into memory and use the matching function.

+1
source

Try a solid state drive if you can afford it. There is no other way, no matter how much parallel processing you use.

0
source

Source: https://habr.com/ru/post/1015552/


All Articles