skills/cv/cnn-metadata-fusion-head/SKILL.md
Fuse CNN image features with a small tabular MLP branch via concat before a final classifier, training both branches end-to-end
npx skillsauth add wenmin-wu/ds-skills cv-cnn-metadata-fusion-headInstall 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.
Many image-classification tasks ship with tabular metadata (patient age, sex, anatomic site, device model) that is independently predictive. The cleanest way to use both is a two-branch network: a CNN processes the image, a small MLP processes normalized tabular features, and the two feature vectors are concatenated before the final classifier. Everything trains end-to-end with a single loss. Reported lift on SIIM-ISIC Melanoma: ~0.5-1 AUC point over image-only baselines, and the tabular branch is tiny (~0.1M params).
import torch
import torch.nn as nn
from efficientnet_pytorch import EfficientNet
class ImageMetaNet(nn.Module):
def __init__(self, n_meta_features, arch='efficientnet-b0'):
super().__init__()
self.cnn = EfficientNet.from_pretrained(arch)
self.cnn._fc = nn.Linear(self.cnn._fc.in_features, 500)
self.meta = nn.Sequential(
nn.Linear(n_meta_features, 500),
nn.BatchNorm1d(500), nn.ReLU(), nn.Dropout(0.2),
nn.Linear(500, 250),
nn.BatchNorm1d(250), nn.ReLU(), nn.Dropout(0.2),
)
self.classifier = nn.Linear(750, 1) # 500 + 250 concat
def forward(self, inputs):
x, meta = inputs # x: image, meta: (B, n_meta_features)
img_feat = self.cnn(x)
meta_feat = self.meta(meta)
fused = torch.cat((img_feat, meta_feat), dim=1)
return self.classifier(fused)
__getitem__ returns a tuple (image_tensor, meta_tensor, label)(x, meta) and runs both branches in paralleldata-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