Skip to content

Implement PyTorch DataLoader for exoskeleton dataset#28

Merged
DylanG5 merged 2 commits into
mainfrom
feat/pytorch-dataloader
Jan 6, 2026
Merged

Implement PyTorch DataLoader for exoskeleton dataset#28
DylanG5 merged 2 commits into
mainfrom
feat/pytorch-dataloader

Conversation

@DylanG5

@DylanG5 DylanG5 commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

Summary

  • Implements PyTorch Dataset and DataLoader for exoskeleton Phase1 data from HuggingFace
  • Adds comprehensive test suite with 44 unit tests
  • Provides configuration and helper utilities

Changes

Core Components

  • ExoskeletonDataset (datasets.py): PyTorch Dataset with auto-download

    • Two-layer caching (HF cache + preprocessed tensor cache)
    • Participant-based filtering for LOSO cross-validation
    • Optional feature normalization with computed statistics
    • Variable-length sequence handling with padding
  • download.py: Dataset download and cache management

    • Automatic download from HuggingFace Hub
    • Data integrity verification (fields, dimensions, sequence lengths)
    • Cache info and clear cache functions
  • create_dataloaders(): Helper for train/val/test DataLoaders

    • Consistent normalization across splits
    • Configurable batch size, workers, shuffling
  • collate_fn: Custom collation for variable-length sequences

    • Pads to max sequence length in batch
    • Returns mask for valid timesteps
    • Preserves metadata (participant, trial name, mass)

Configuration

  • configs/data/phase1.yaml: YAML config with participant splits, features, and settings

Testing

  • 44 unit tests covering:
    • Dataset initialization and caching
    • Download and integrity verification
    • DataLoader iteration and batching
    • Normalization and padding
    • Edge cases (empty filters, single samples)

Dependencies

  • Added datasets>=2.14.0 and huggingface-hub>=0.17.0

Test plan

  • All 44 unit tests pass: pytest tests/test_data/ -v
  • Linting passes: ruff check src/ tests/
  • Type checking passes: mypy src/
  • Formatting passes: black --check src/ tests/

Usage Example

from exoskeleton_ml.data import ExoskeletonDataset, create_dataloaders

# Create train/val/test DataLoaders
train_loader, val_loader, test_loader = create_dataloaders(
    hf_repo="macexo/exoskeleton-phase1",
    train_participants=["BT01", "BT02", "BT03"],
    val_participants=["BT14"],
    test_participants=["BT15"],
    batch_size=32,
    normalize=True,
)

for batch in train_loader:
    inputs = batch["inputs"]    # (batch, seq_len, 28)
    targets = batch["targets"]  # (batch, seq_len, 4)
    mask = batch["mask"]        # (batch, seq_len)

🤖 Generated with Claude Code

@DylanG5
DylanG5 requested a review from a team as a code owner December 30, 2025 22:14
DylanG5 and others added 2 commits January 5, 2026 20:51
Adds a complete PyTorch Dataset and DataLoader implementation for the
exoskeleton Phase1 dataset from HuggingFace:

Core Components:
- ExoskeletonDataset: PyTorch Dataset with auto-download from HuggingFace
  - Two-layer caching (HF cache + preprocessed tensor cache)
  - Participant-based filtering for train/val/test splits
  - Optional feature normalization with computed statistics
  - Variable-length sequence handling with padding

- download.py: Dataset download and cache management utilities
  - Automatic download from HuggingFace Hub
  - Data integrity verification (field presence, dimensions, sequence lengths)
  - Cache info and clear cache functions

- create_dataloaders(): Helper function for train/val/test DataLoaders
  - Consistent normalization across splits
  - Configurable batch size, workers, shuffling

- collate_fn: Custom collation for variable-length sequences
  - Pads to max sequence length in batch
  - Returns mask for valid timesteps
  - Preserves metadata (participant, trial name, mass)

Configuration:
- configs/data/phase1.yaml: YAML config with splits, features, and settings

Testing:
- 44 unit tests covering datasets, download, and dataloader functionality
- Tests for caching, normalization, padding, metadata, edge cases

Dependencies:
- Added datasets>=2.14.0 and huggingface-hub>=0.17.0 to pyproject.toml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@DylanG5
DylanG5 force-pushed the feat/pytorch-dataloader branch from 3dbee23 to 14b2191 Compare January 6, 2026 01:51
@DylanG5
DylanG5 merged commit e9a1362 into main Jan 6, 2026
3 checks passed
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.

1 participant