Skip to content

Instantly share code, notes, and snippets.

View bw4sz's full-sized avatar

Benjamin Weinstein bw4sz

View GitHub Profile
@bw4sz
bw4sz / train.py
Created December 14, 2018 19:00 — forked from renexu/train.py
Keras HDF5Matrix and fit_generator for huge hdf5 dataset
import threading
from keras.applications.inception_v3 import InceptionV3
from keras.optimizers import Adam
from keras.utils.io_utils import HDF5Matrix
class threadsafe_iter:
"""Takes an iterator/generator and makes it thread-safe by
serializing call to the `next` method of given iterator/generator.
@bw4sz
bw4sz / rioarray.py
Created May 14, 2018 21:36 — forked from lpinner/rioarray.py
rasterio and dask for multithreaded chunked raster operations
import numpy as np
import rasterio as rio
import dask
import dask.array as da
class RioDataset():
def __init__(self, filepath, band=1):
self.band = band
self.dataset = rio.open(filepath)
self.dtype = self.dataset.dtypes[band-1]