Skip to content

feat: load multiple cached datasets - #34

Merged
carshadi merged 3 commits into
mainfrom
refactor-load-dataset
Jul 24, 2026
Merged

carshadi merged 3 commits into
mainfrom
refactor-load-dataset

Conversation

@anna-grim

@anna-grim anna-grim commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

We now have cached datasets generated from alpha, beta, beta2 whole-brain images and would like to train a model using some or possibly all of them.

Summary

Refactored the cache-backed datasets to support loading multiple precomputed cache directories as a single dataset. Also reduced duplicated dataset logic between training and validation by refactoring validation to inherit from CachedPatchDataset.

Changes

  • Updated "CachedPatchDataset" to support a list of cache directories:

    • Multiple "raw.npy", "teacher.npy", and "fg.npy" cache shards can now be combined into one dataset.
    • Added global-to-local index mapping so DataLoader indexing remains unchanged while samples are loaded from the correct cache shard.
    • Preserved memory-mapped loading to avoid duplicating cached data in memory.
  • Added shared cache loading and validation utilities:

    • Centralized cache loading through "_load_cached_arrs".
    • Added "_validate_cache" checks to ensure:
      • raw/teacher/foreground arrays have matching numbers of examples.
      • patch shapes are consistent within and across cache directories.
  • Refactored "CachedValidateDataset" to inherit from "CachedPatchDataset":

    • Removed duplicate cache initialization and indexing logic.
    • Reuses the same cache access path while extending the output format to include raw counts required for validation metrics.

@anna-grim
anna-grim requested a review from carshadi July 23, 2026 22:46

@carshadi carshadi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anna-grim I just fixed the training script to use these changes. Otherwise looks good.

@carshadi
carshadi merged commit 0b2c6af into main Jul 24, 2026
0 of 3 checks passed
@carshadi
carshadi deleted the refactor-load-dataset branch July 24, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants