Skip to content

brycewang-stanford/Auto-Empirical-Research-Skills / skills/33-Galaxy-Dawn-claude-scholar/skills/architecture-design

architecture-design

Verified

Use only when creating new registrable ML components that require Factory or Registry patterns.

examples/custom_dataset.py

View on GitHub
"""
Example: Creating a Custom Dataset

This example shows how to add a new dataset following the project architecture.
"""

from torch.utils.data import Dataset
from typing import Dict
import torch
from src.data_module.dataset import register_dataset


@register_dataset("time_series")
class TimeSeriesDataset(Dataset):
    """
    Time series dataset for sequence modeling.

    Args:
        sequences: List of time series sequences
        seq_length: Fixed sequence length (pad or truncate if needed)
    """

    def __init__(self, sequences: list, seq_length: int = 100):
        self.sequences = sequences
        self.seq_length = seq_length

    def __len__(self) -> int:
        return len(self.sequences)

    def __getitem__(self, i: int) -> Dict[str, torch.Tensor]:
        sequence = self.sequences[i]

        # Pad or truncate to fixed length
        if len(sequence) < self.seq_length:
            padding = torch.zeros(self.seq_length - len(sequence))
            sequence = torch.cat([sequence, padding])
        else:
            sequence = sequence[:self.seq_length]

        return {
            "input": sequence,
            "label": sequence,  # For autoencoder, etc.
            "length": torch.tensor(min(len(self.sequences[i]), self.seq_length))
        }


# Usage in training:
# from src.data_module.dataset import DatasetFactory
# dataset = DatasetFactory("time_series")(sequences=training_data, seq_length=128)
# dataloader = DataLoader(dataset, batch_size=32, shuffle=True)
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall