Skip to content
Back to skills

Dual Contrastive Loss

ASecurity

Compute and inspect a DCL-style contrastive proxy loss with same-latent positives and real-target anti-collapse negatives.

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

Security analysis

A100/100

Scanned September 9, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Dual Contrastive Loss?

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

Security grade badge for Dual Contrastive Loss
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-dual-contrastive-loss/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-dual-contrastive-loss)

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

SKILL.md
---
name: dual_contrastive_loss
description: Compute and inspect a DCL-style contrastive proxy loss with same-latent positives and real-target anti-collapse negatives.
---

# Dual Contrastive Loss

Use this skill when a recovery needs a deterministic feature-level version of the paper's DCL objective. It accepts a latent-paired batch and produces an InfoNCE-like scalar loss plus mechanism checks. Do not use it as a replacement for full StyleGAN training when full models are available.

## Inputs
- Batch from `latent_pair_protocol`.
- Temperature scalar.
- Optional real-target negative weight.

## Outputs
- Mean contrastive proxy loss.
- Positive and negative similarity diagnostics.
- Checks showing same-latent positives and real-target negatives were used.

## Workflow
1. Compute dot-product similarity divided by temperature.
2. For each source feature, treat the same-latent target feature as the positive.
3. Treat other generated target features and real-target exemplars as negatives.
4. Average the negative log softmax probability assigned to the positive.

## Validation
Run `python tests/test_dual_contrastive_loss.py` from this skill directory.

## Limitations
The script uses small numeric vectors and standard-library math; it preserves objective structure but not neural feature extraction.


## Refinement Note
A shuffled-positive stress check should produce higher loss than aligned same-latent positives; see `cycle1_shuffled_stress.json` in recovery logs.

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…