Skip to content
Back to skills

Mixup Sequence Augmentation

ASecurity

Apply MixUp augmentation to padded time-series batches with Beta-distributed lambda and soft label mixing

  • 61 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 12, 2026
documentationpython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill mixup-sequence-augmentation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mixup Sequence Augmentation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mixup Sequence Augmentation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-mixup-sequence-augmentation/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-mixup-sequence-augmentation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: timeseries-mixup-sequence-augmentation
description: Apply MixUp augmentation to padded time-series batches with Beta-distributed lambda and soft label mixing
domain: timeseries
---

# MixUp Sequence Augmentation

## Overview

MixUp linearly interpolates between pairs of training samples and their labels using a Beta-distributed lambda. For time series classification, apply it to padded/fixed-length sequences. Reduces overfitting and improves calibration, especially with small datasets.

## Quick Start

```python
import numpy as np
import torch
import torch.nn.functional as F

def mixup_batch(x, y, alpha=0.2):
    """MixUp augmentation for time-series batches.
    
    Args:
        x: (B, T, C) input sequences
        y: (B, num_classes) one-hot labels
        alpha: Beta distribution parameter
    """
    lam = np.random.beta(alpha, alpha) if alpha > 0 else 1.0
    perm = torch.randperm(x.size(0), device=x.device)
    x_mix = lam * x + (1 - lam) * x[perm]
    y_mix = lam * y + (1 - lam) * y[perm]
    return x_mix, y_mix

def soft_cross_entropy(pred, soft_targets):
    """Cross-entropy loss for soft (mixed) labels."""
    return -torch.sum(soft_targets * F.log_softmax(pred, dim=1), dim=1).mean()
```

## Key Decisions

- **alpha=0.2**: mild mixing — lambda typically near 0 or 1, preserving sample identity
- **Soft CE loss required**: standard CE expects hard labels; use manual log_softmax + weighted sum
- **Shuffle per-epoch**: re-permute mixing pairs each epoch for diversity

## References

- Source: [cmi25-imu-thm-tof-tf-blendingmodel-lb-82](https://www.kaggle.com/code/hideyukizushi/cmi25-imu-thm-tof-tf-blendingmodel-lb-82)
- Competition: CMI - Detect Behavior with Sensor Data

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…