Skip to content
Back to skills

Training Evaluation

ASecurity

"Use segmentation_models_pytorch losses, metrics, tensor modes, and

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 9, 2026
toolspythonbashdebugginggit

Security analysis

A100/100

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

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill training-evaluation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Training Evaluation?

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

Security grade badge for Training Evaluation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-training-evaluation-54313910/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-training-evaluation-54313910)

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: training-evaluation
description: "Use segmentation_models_pytorch losses, metrics, tensor modes, and
  safe training/evaluation loops for segmentation."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# training-evaluation

Use this sub-skill when an agent needs to train or evaluate segmentation with `segmentation_models_pytorch` (SMP) losses and metrics, diagnose mask/logit shape errors, or adapt a short training loop without downloads or long-running training.

## Use When

- Selecting `DiceLoss`, `JaccardLoss`, `TverskyLoss`, `FocalLoss`, `LovaszLoss`, `SoftBCEWithLogitsLoss`, `SoftCrossEntropyLoss`, or `MCCLoss`.
- Deciding between `BINARY_MODE`, `MULTICLASS_MODE`, and `MULTILABEL_MODE` for logits, masks, losses, and metrics.
- Calling `smp.metrics.get_stats` followed by `iou_score`, `f1_score`, `accuracy`, `precision`, or `recall`.
- Building a minimal PyTorch training/evaluation loop around an SMP model.
- Debugging shape, dtype, threshold, `from_logits`, `ignore_index`, or `class_weights` failures.

## Route Elsewhere

- Choose architectures, `classes`, `in_channels`, decoder options, or `smp.create_model` in [model-building](../model-building/SKILL.md).
- Choose encoder weights and input normalization in [encoders-preprocessing](../encoders-preprocessing/SKILL.md).
- Save, trace, script, ONNX-export, or package trained models in [model-export](../model-export/SKILL.md).

## Core Contract

- Binary segmentation: model output is usually `(N, 1, H, W)` and target masks are `0/1`, preferably `(N, 1, H, W)` for metrics and either `(N, H, W)` or `(N, 1, H, W)` for most losses.
- Multiclass segmentation: model output is `(N, C, H, W)`, target is integer class ids `(N, H, W)`, and classes are mutually exclusive.
- Multilabel segmentation: model output and target are `(N, C, H, W)`, each channel is an independent `0/1` label, and classes may overlap.
- Losses usually consume logits with `from_logits=True`; metrics consume hard integer masks or floating binary/multilabel scores plus a threshold.

## References

- [Losses and metrics](references/losses-and-metrics.md) covers modes, signatures, tensor shapes, reductions, and metric thresholds.
- [Training workflows](references/training-workflows.md) gives compact binary, multiclass, and multilabel loop skeletons.
- [Troubleshooting](references/troubleshooting.md) maps common SMP errors to fixes.
- [validate_training_shapes.py](scripts/validate_training_shapes.py) validates tiny deterministic shape/mode/loss/metric combinations and prints JSON.

## Safe Smoke Check

Run the bundled validator before changing a real loop:

```bash
python sub-skills/training-evaluation/scripts/validate_training_shapes.py --mode binary --batch 2 --classes 1 --height 8 --width 8 --from-logits --metric-threshold 0.5
python sub-skills/training-evaluation/scripts/validate_training_shapes.py --mode multiclass --classes 3 --loss soft-ce
python sub-skills/training-evaluation/scripts/validate_training_shapes.py --mode multilabel --classes 4 --metric-threshold 0.5
```

The helper constructs tiny tensors only; it does not download data, build a model, or train.

Files in this skill

  • SKILL.md3.1 KB
  • references/losses-and-metrics.md7.3 KB
  • references/training-workflows.md6.5 KB
  • references/troubleshooting.md5.5 KB
  • scripts/validate_training_shapes.py14.8 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.