skills/cv/3d-mixup-augmentation/SKILL.md
Applies Mixup augmentation to 3D volumetric images and their segmentation masks, interpolating both inputs and loss targets.
npx skillsauth add wenmin-wu/ds-skills cv-3d-mixup-augmentationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Mixup creates virtual training samples by linearly interpolating pairs of inputs and their labels. For 3D medical imaging (CT, MRI), this regularizes the model by blending volumetric scans and their segmentation masks. The loss is computed against both original and shuffled targets, weighted by the interpolation factor lambda. Reduces overfitting on small 3D datasets where traditional augmentations (flip, rotate) are limited.
import torch
import numpy as np
def mixup_3d(images, masks, alpha=1.0):
"""Mixup for 3D volumes and segmentation masks.
Args:
images: (B, C, D, H, W) volumetric input
masks: (B, C, D, H, W) segmentation targets
alpha: Beta distribution parameter (1.0 = uniform)
"""
lam = np.random.beta(alpha, alpha)
indices = torch.randperm(images.size(0))
mixed_images = lam * images + (1 - lam) * images[indices]
return mixed_images, masks, masks[indices], lam
# In training loop:
if np.random.random() < 0.5: # 50% probability
images, masks_a, masks_b, lam = mixup_3d(images, masks)
logits = model(images)
loss = lam * criterion(logits, masks_a) + (1 - lam) * criterion(logits, masks_b)
else:
logits = model(images)
loss = criterion(logits, masks)
lam * img_A + (1-lam) * img_Bdata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF