skit
1.0.0
코드베이스 전체에서 사용하는 유용한 도구 세트.
설치하려면 :
git clone [email protected]:Shamdan17/skit.git
pip install -e .
DataSetPreloader는 torch.utils.data.Dataset 주변의 래퍼입니다. 데이터 세트를 디스크로 캐시합니다. 이것은 인스턴스화에서 또는 배치를 요청할 때 게으르게 수행됩니다. 이는 특히 여러 파일에서 단일 인스턴스가로드되는 경우 매번 디스크로드 오버 헤드를 피하는 것입니다. 더 중요한 것은, 이것은 우리가 한 번만 수행함으로써 비싼 전처리 단계를 건너 뛸 수 있다는 것입니다.
경고 : 현재 텐서의 튜플 또는 튜플을 반환하는 데이터 세트 만 지원합니다.
용법:
from skit . data import DatasetPreloader
dataset = myTorchDataset ()
cache_path = 'path/to/cache'
# Wrap the dataset
dataset = DatasetPreloader (
dataset ,
cache_path = cache_path ,
wipe_cache = False , # If the cache exists, use it. Otherwise, create it. If true, delete the cache if it exists.
lazy_loading = True , # Load the entire dataset into memory on instantiation or lazily when a batch is requested
compress = True , # Compress the cache. This can save a lot of disk space. However, it can be slower to load.
block_size = 2000 , # The number of samples to store in a single folder. This is to avoid having too many files in a single directory, which can cause performance issues. Set to 0 to disable.
preloading_workers = 10 , # The number of workers to use when preloading the dataset. Does not affect lazy loading.
samples_to_confirm_cache = 100 # The number of samples to check when confirming the cache. If your dataset has many instances, increase the number of samples to confirm the cache. Please note this process is only a heuristic and is not 100% accurate. If in doubt, wipe the cache.
)
# Access the dataset as normalInmemoryDatasetPreloader는 전체 데이터 세트를 메모리에로드하는 DataSetPreloader 위에있는 래퍼입니다. 이것은 작은 데이터 세트가 있고 매번 디스크로드 오버 헤드를 피하려는 경우 유용합니다. DataSetPreloader와 정확히 동일한 API가 있습니다.