Commit 1919f600 authored by Ilya Ovodov's avatar Ilya Ovodov

CachedDataSet

parent 981c0a29
from .threading_dataloader import BatchThreadingDataLoader, ThreadingDataLoader
\ No newline at end of file
from .threading_dataloader import BatchThreadingDataLoader, ThreadingDataLoader
from .cached_dataset import CachedDataSet
\ No newline at end of file
class CachedDataSet:
'''
provides caching dataset items in memory
'''
def __init__(self, dataset):
self.dataset = dataset
self.cache = [None] * len(dataset)
def __len__(self):
return len(self.dataset)
def __getitem__(self, index):
if self.cache[index] is None:
self.cache[index] = self.dataset[index]
return self.cache[index]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment