skills/cv/dual-view-reshape-forward/SKILL.md
Reshape dual-view stacked channels into doubled batch dimension for shared backbone, then concatenate with tabular features for classification
npx skillsauth add wenmin-wu/ds-skills cv-dual-view-reshape-forwardInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When two camera views (e.g., Endzone + Sideline) are stacked as channels in a single tensor, a shared backbone can process both views by reshaping: split channels in half, double the batch size, run the backbone once, then reshape back. This avoids duplicating the backbone while preserving view-specific features. Tabular features (tracking data, distances) are processed through a separate MLP and concatenated before the final classifier.
import torch
import torch.nn as nn
import timm
class DualViewModel(nn.Module):
def __init__(self, model_name='tf_efficientnetv2_s', n_frames=13, n_features=18):
super().__init__()
self.backbone = timm.create_model(model_name, pretrained=True,
num_classes=500, in_chans=n_frames)
self.mlp = nn.Sequential(
nn.Linear(n_features, 64), nn.LayerNorm(64),
nn.ReLU(), nn.Dropout(0.2))
self.fc = nn.Linear(500 * 2 + 64, 1)
def forward(self, img, feature):
b, c, h, w = img.shape
img = img.reshape(b * 2, c // 2, h, w) # split views
img = self.backbone(img).reshape(b, -1) # (B, 500*2)
feature = self.mlp(feature) # (B, 64)
return self.fc(torch.cat([img, feature], dim=1))
pred = model(dual_view_tensor, tracking_features)
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF