All Projects → justheuristic → Prefetch_generator

justheuristic / Prefetch_generator

Licence: unlicense
Simple package that makes your generator work in background thread

Projects that are alternatives of or similar to Prefetch generator

Web Database Analytics
Web scrapping and related analytics using Python tools
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Astropy Tutorials
Tutorials for the Astropy Project
Stars: ✭ 174 (+0%)
Mutual labels:  jupyter-notebook
Research
Open sourced research notebooks by the QuantConnect team.
Stars: ✭ 176 (+1.15%)
Mutual labels:  jupyter-notebook
Muffin Cupcake
classifying muffin and cupcake recipes using support vector machines
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Deep Learning With Keras Notebooks
Jupyter notebooks for using & learning Keras
Stars: ✭ 2,077 (+1093.68%)
Mutual labels:  jupyter-notebook
Attentionn
All about attention in neural networks. Soft attention, attention maps, local and global attention and multi-head attention.
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Home Credit Default Risk
2nd Place Solution 💰🥈
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Debiaswe
Remove problematic gender bias from word embeddings.
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Intro Spacy Nlp
An introduction to using spaCy for NLP and machine learning
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Reinforcement learning ai video games
Code for each week's short video of Siraj Raval Course on Reinforcement Learning "AI for Video Games"
Stars: ✭ 176 (+1.15%)
Mutual labels:  jupyter-notebook
Recommendation
Recommendation System using ML and DL
Stars: ✭ 174 (+0%)
Mutual labels:  jupyter-notebook
Python Machine Learning Book 3rd Edition
The "Python Machine Learning (3rd edition)" book code repository
Stars: ✭ 2,883 (+1556.9%)
Mutual labels:  jupyter-notebook
Tech
Documentation of all collective action from tech workers.
Stars: ✭ 176 (+1.15%)
Mutual labels:  jupyter-notebook
Itwmm
In The Wild 3D Morphable Models
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Rnn For Joint Nlu
Pytorch implementation of "Attention-Based Recurrent Neural Network Models for Joint Intent Detection and Slot Filling" (https://arxiv.org/abs/1609.01454)
Stars: ✭ 176 (+1.15%)
Mutual labels:  jupyter-notebook
Poems generator keras
唐诗,藏头诗,按需自动生成古诗,基于Keras、LSTM-RNN。文档齐全。
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Analytical Tutorials
Tutorials for writing analytical scripts
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
S3contents
A S3 backed ContentsManager implementation for Jupyter
Stars: ✭ 175 (+0.57%)
Mutual labels:  jupyter-notebook
Neural image captioning
Neural image captioning (NIC) implementation with Keras 2.
Stars: ✭ 176 (+1.15%)
Mutual labels:  jupyter-notebook
Gluon Fashionai Attributes
Stars: ✭ 176 (+1.15%)
Mutual labels:  jupyter-notebook

prefetch_generator

Simple package that makes your generator work in background thread.

Quick usage example (ipython notebook)

Install:

  • pip install prefetch_generator
  • No dependencies apart from standard libraries
  • Works with both python2 and python3 (pip3 install)

Description:

This is a single-function package that transforms arbitrary generator into a background-thead generator that prefetches several batches of data in a parallel background thead.

This is useful if you have a computationally heavy process (CPU or GPU) that iteratively processes minibatches from the generator while the generator consumes some other resource (disk IO / loading from database / more CPU if you have unused cores).

By default these two processes will constantly wait for one another to finish. If you make generator work in prefetch mode (see examples below), they will work in parallel, potentially saving you your GPU time.

We personally use the prefetch generator when iterating minibatches of data for deep learning with tensorflow and theano ( lasagne, blocks, raw, etc.).

based on http://stackoverflow.com/questions/7323664/python-generator-pre-fetch

Usage:

This package contains two objects

  • BackgroundGenerator(any_other_generator[,max_prefetch = something])
  • @background([max_prefetch=somethind]) decorator

the usage is either

for batch in BackgroundGenerator(my_minibatch_iterator):
    doit()

or

@background()
def iterate_minibatches(some_param):
    while True:
        X = read_heavy_file()
        X = do_helluva_math(X)
        y = wget_from_pornhub()
        do_pretty_much_anything()
        yield X_batch, y_batch

More details are written in the BackgroundGenerator doc help(BackgroundGenerator)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].