Skip to content
Back to skills

Dataset Sampling

ASecurity

"Routes dataset-wrapper and batch-sampling tasks for SiameseMNIST,

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
testingapi

Works with

  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill dataset-sampling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dataset Sampling?

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

Security grade badge for Dataset Sampling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-dataset-sampling/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-dataset-sampling)

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: dataset-sampling
description: "Routes dataset-wrapper and batch-sampling tasks for SiameseMNIST,
  TripletMNIST, and BalancedBatchSampler in the Siamese-triplet repository."
metadata:
  disco-role: operating
disable-model-invocation: true
license: BSD 3-Clause
---

# Dataset Sampling

Use this sub-skill when the task is about how the repository builds pair and triplet examples, how it samples balanced mini-batches, or how it adapts MNIST-like datasets to the repository's legacy torchvision conventions.

## Covered surface

- `SiameseMNIST`
- `TripletMNIST`
- `BalancedBatchSampler`
- Legacy MNIST/FashionMNIST attribute names used by the notebooks
- Tiny synthetic fixtures that mimic the notebook data contract

## When to route here

Read this sub-skill for tasks that mention:

- positive/negative pairs
- anchor/positive/negative triplets
- test-time fixed pairs or triplets
- balanced batches for online mining
- legacy `train_data` / `train_labels` / `test_data` / `test_labels` compatibility
- PIL conversion from MNIST-like tensors

## What to do first

1. Read `references/api-reference.md` for the wrapper contracts and returned shapes.
2. Read `references/troubleshooting.md` if a fixture or dataset does not expose the attributes this repo expects.
3. Run `scripts/check_dataset_wrappers.py` when you want a tiny no-download smoke.

## Evidence signals

- Source evidence comes from `datasets.py` and the loader cells in both notebooks.
- The wrappers are generic enough for MNIST-like grayscale datasets, but their attribute names are legacy torchvision-specific.
- The smoke script intentionally uses a tiny fake fixture so verification does not depend on a network download.

## Short workflow

- Build or adapt a dataset object that exposes the legacy MNIST attributes.
- Attach `transform=None` for the smoke check, or attach the same transforms the notebook would use.
- Verify the returned object shapes:
  - `SiameseMNIST` -> `(img1, img2), target`
  - `TripletMNIST` -> `(img1, img2, img3), []` for the test fixture path
  - `BalancedBatchSampler` -> `n_classes × n_samples` indices per batch
- Check that class balance is sufficient for the chosen batch shape.

## Decision points

- Use `SiameseMNIST` when the downstream loss is contrastive and the model expects exactly two inputs.
- Use `TripletMNIST` when the downstream loss is triplet-based and the model expects three inputs.
- Use `BalancedBatchSampler` only when the next stage mines pairs or triplets inside a mini-batch.
- Prefer a tiny fake MNIST-like object for verification; do not download the full datasets just to prove the wrapper contract.

## Common failure modes

- The wrapped dataset has `data` and `targets` instead of `train_data` and `train_labels`.
- The sample tensor is not grayscale `28×28` `uint8` data before PIL conversion.
- The label distribution is too sparse for the selected batch sampler shape.
- A custom transform changes the image size or number of channels and breaks the downstream embedding network.

## Acceptance checks

- A pair wrapper returns two grayscale PIL images plus a binary target.
- A triplet wrapper returns three grayscale PIL images and an empty target placeholder.
- A balanced sampler emits exactly `n_classes × n_samples` indices.
- The downstream model still receives `1×28×28` tensors after transforms are applied.

## Read next

- `references/api-reference.md` for exact return values and sampler behavior.
- `references/troubleshooting.md` for legacy torchvision compatibility and batch-shape issues.
- `../embedding-losses-mining/SKILL.md` if the next step is a loss or mining check.
- `../training-experiments/SKILL.md` if the next step is an end-to-end fit loop.

Files in this skill

  • SKILL.md3.6 KB
  • references/api-reference.md1.2 KB
  • references/troubleshooting.md839 B
  • scripts/check_dataset_wrappers.py2.2 KB

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…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.