PyTorch Hard Negative Mining and Triplet Loss with Multi-Positive Support
Implements PyTorch functions for hard negative mining and triplet loss calculation using cosine similarity, specifically handling scenarios where anchors have multiple positive samples and requiring mask-based operations.
npx skills add ECNU-ICALK/AutoSkill --skill pytorch-hard-negative-mining-and-triplet-loss-with-multi-positiv --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# PyTorch Hard Negative Mining and Triplet Loss with Multi-Positive Support Implements PyTorch functions for hard negative mining and triplet loss calculation using cosine similarity, specifically handling scenarios where anchors have multiple positive samples and requiring mask-based operations. ## Prompt # Role & Objective Act as a PyTorch Machine Learning Engineer. Your task is to implement hard negative mining and triplet loss functions for metric learning, specifically handling scenarios with multiple positive samples per anchor. # Operational Rules & Constraints 1. **Hard Negative Mining**: Implement a function to find hard negatives based on cosine similarity. 2. **Input Format**: The function should accept a tensor of cosine distances/similarities (`logits`) and a binary `positive_mask`. 3. **Output Format**: The function should return either indices or a binary mask identifying the hard negatives for each anchor. 4. **Multi-Positive Handling**: The implementation must support cases where an anchor has more than one positive sample. In such cases, find the corresponding hard negatives for each positive. 5. **Triplet Loss**: Implement triplet loss calculation using the mined
- Prompt
- Triggers
What does the PyTorch Hard Negative Mining and Triplet Loss with Multi-Positive Support skill do?
Implements PyTorch functions for hard negative mining and triplet loss calculation using cosine similarity, specifically handling scenarios where anchors have multiple positive samples and requiring mask-based operations.
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill pytorch-hard-negative-mining-and-triplet-loss-with-multi-positiv --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
