Skip to content

Instantly share code, notes, and snippets.

@thenomemac
thenomemac / cloudSettings
Last active June 10, 2019 17:20
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-06-10T03:11:38.927Z","extensionVersion":"v3.2.9"}
@thenomemac
thenomemac / BatchGenSharedmem.py
Created August 10, 2016 01:20
use of numpy memory maps for generating a list of ndarray's without pickle overhead and metadata pass through
# By Josiah Olson
# Context manager to generate batches in the background via a process pool
# Returns float32 minibatch tensors and metadata using numpy sharedmem to avoid
# the thread blocking compute time needed to de-pickle large minibatches passed
# through multiprocessing.Queue: ~0.3 sec for 1gb minibatch
# This context manager will bring blocking time to ~300 microseconds per minibatch
# Usage:
#
# def batchFxn(seed, sharedArr):
# .... # generate iterable of float32 tensors in minibatch: batchArrs
@thenomemac
thenomemac / batchgenArray.py
Created July 7, 2016 20:14
batchgen implemented with multiprocessing.Array
# Modified 2016-06-30 by Josiah Olson to add python3 support
# Context manager to generate batches in the background via a process pool
# Usage:
#
# def batch(seed):
# .... # generate minibatch
# return minibatch
#
# with BatchGenCM(batch) as bg:
# minibatch = next(bg)
@thenomemac
thenomemac / batchgenSharedmem.py
Created July 7, 2016 20:14
batchgen implemented with sharedmem
# Modified by Josiah Olson to add python3 support
# Context manager to generate batches in the background via a process pool
# Returns minibatch of fixed shape as shared memory to avoid de-pickling compute time
# Usage:
#
# def batch(seed, arr):
# .... # generate minibatch
# arr[:] = minibatch.ravel()
# return minibatch.shape()
#
@thenomemac
thenomemac / batchgen.py
Last active June 30, 2016 04:43 — forked from ebenolson/batchgen.py
Mini Batch Generation Using Parallel Queue: Lasagne, Neural Networks, python3
# Modified 2016-06-30 by Josiah Olson to add python3 support
# Context manager to generate batches in the background via a process pool
# Usage:
#
# def batch(seed):
# .... # generate minibatch
# return minibatch
#
# with BatchGenCM(batch) as bg:
# minibatch = next(bg)