skit
1.0.0
コードベース全体で使用する便利なツールのセット。
インストールするには:
git clone [email protected]:Shamdan17/skit.git
pip install -e .
DataSetPreloaderは、 torch.utils.data.Datasetの周りのラッパーであり、データセットをディスクにキャッシュします。これは、バッチが要求されたときにインスタンス化時に行われるか、ゆっくりと行われます。これは、特に単一のインスタンスが複数のファイルからロードされている場合、毎回ディスクからのロードのオーバーヘッドを回避するためです。さらに重要なことは、これにより、1回だけ行うことで、おそらく高価な前処理手順をスキップできるようにすることです。
警告:現在、テンソルのdictまたはタプルを返すデータセットのみをサポートしています。
使用法:
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を持っています。