trainlint静态检查机器学习训练错误
开发者Satvik-jain创建了trainlint,用于静态检查不会导致程序崩溃的机器学习训练与评估错误,包括预处理泄漏、评估模式误用和logits损失错误。该工具通过解析代码和匹配名称工作,无需数据、模型或GPU,但作者称目前仅支持PyTorch和scikit-learn。作者人工检查pytorch/examples中的22项发现后,认定其中20项是真实问题,另外2项结果正确但无害,但其未提供召回率数据。
trainlint为训练代码中的高风险错误提供了一种轻量级静态检查方式,不过其基于名称匹配的实现以及对PyTorch和scikit-learn的有限支持限制了可靠适用范围。
I wrote a small checker for training and evaluation code. It looks for mistakes that do not raise
errors. The classic one is leakage through preprocessing. With 5,000 random features and random
labels, picking the top 20 features on the full dataset and then running 5-fold cross-validation
gives 85% accuracy (87.7% averaged over 20 seeds). Doing the selection inside a Pipeline gives 48%
(50.0%). Nothing can beat 50% on that data, so the whole gap is leakage.
trainlint finds that pattern statically, along with thirteen others: eval() left on during