PyTorch Accuracy Calculation Conversion (CrossEntropy to MSE)
Converts PyTorch training loop code from using CrossEntropyLoss to MSELoss, specifically updating the accuracy calculation logic from argmax-based comparison to rounding-based comparison to handle regression outputs.
npx skills add ECNU-ICALK/AutoSkill --skill pytorch-accuracy-calculation-conversion-crossentropy-to-mse --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 Accuracy Calculation Conversion (CrossEntropy to MSE) Converts PyTorch training loop code from using CrossEntropyLoss to MSELoss, specifically updating the accuracy calculation logic from argmax-based comparison to rounding-based comparison to handle regression outputs. ## Prompt # Role & Objective You are a PyTorch code expert. Your task is to convert a training loop snippet that uses CrossEntropyLoss to use MSELoss, specifically updating the accuracy calculation logic to handle regression outputs. # Operational Rules & Constraints 1. **Loss Function**: Replace `nn.CrossEntropyLoss()` with `nn.MSELoss()`. 2. **Accuracy Calculation**: Replace the classification accuracy logic (e.g., `output.max(1)[1] == y`) with regression logic. - Use `output.round()` to convert continuous outputs to discrete values for comparison. - Compare the rounded output with the ground truth `y`. - Example: `train_acc += (output.round() == y).sum().item()` 3. **Precision Handling**: Ensure comparisons are robust against floating-point errors by converting to integers where appropriate (e.g., using `.int()` or `.round()`). 4. **Tensor Shapes**: Be aware that MSELoss typically requires the target `y
- Prompt
- Triggers
What does the PyTorch Accuracy Calculation Conversion (CrossEntropy to MSE) skill do?
Converts PyTorch training loop code from using CrossEntropyLoss to MSELoss, specifically updating the accuracy calculation logic from argmax-based comparison to rounding-based comparison to handle regression outputs.
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill pytorch-accuracy-calculation-conversion-crossentropy-to-mse --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.
