مجموعة من الأدوات المفيدة التي أستخدمها في جميع أنحاء Codebases.
للتثبيت:
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.