{"version":2,"relationshipURLBase":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html","relationshipResolution":"Resolve relative relationship URLs against relationshipURLBase; complete records and absolute URLs are in blocks.","title":"LAB 10 · 从 RGB 图像训练小型检测器","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html","markdown":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.md","pages":[{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":1},{"id":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","title":"选读热身：四维分类的参数更新","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":2},{"id":"reading-block-c99421410ab94ca7b487531b85fdabbd","title":"主实验的输入、目标和固定协议","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":3},{"id":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","title":"读源码时跟踪三种集合","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":4},{"id":"reading-block-487567d0bb1d40039f1f87805d46ee76","title":"固定锚框怎样变成待学习的偏移","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":5},{"id":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","title":"哪些锚框受哪一种监督","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":6},{"id":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","title":"从共享特征到两个输出头","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":7},{"id":"reading-block-8bcdc8923f8c411583dec053e8e89211","title":"实际训练与可复查的输出","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":8},{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":9},{"id":"reading-block-3dc8766f20144da28bbef37cade18a3d","title":"来源与下一条问题","unit":"LAB 10 · 从 RGB 图像训练小型检测器","unitId":"lab10-一个完整的小型检测器","chapter":"course","number":10}],"aliases":[{"oldId":"b-b6e9b3aee5a4411c12e9de05","targetId":"b-b6e9b3aee5a4411c12e9de05","page":"reading-opening","operation":"move","beforeSHA256":"a7b6ffb439439b1a9c61813cc32d9bb6766638ff7c32f53fe1f90b5b5699b7e6","afterSHA256":"a7b6ffb439439b1a9c61813cc32d9bb6766638ff7c32f53fe1f90b5b5699b7e6","reason":"Same source body in authored semantic page"},{"oldId":"b-5f1c976ea7362357367bac5a","targetId":"b-5f1c976ea7362357367bac5a","page":"reading-opening","operation":"move","beforeSHA256":"42cba31deccba2a350b9b23bd0ca1dcaa4c4c5cb9d35c773e1fcb89124788ccd","afterSHA256":"42cba31deccba2a350b9b23bd0ca1dcaa4c4c5cb9d35c773e1fcb89124788ccd","reason":"Same source body in authored semantic page"},{"oldId":"b-394caca18a925a6f63f6b45b","targetId":"b-394caca18a925a6f63f6b45b","page":"reading-opening","operation":"move","beforeSHA256":"b1c765d7bf903321abd36e75bae49048d61faec2aa3fd11922b328c5970003b1","afterSHA256":"b1c765d7bf903321abd36e75bae49048d61faec2aa3fd11922b328c5970003b1","reason":"Same source body in authored semantic page"},{"oldId":"b-a03dc1ec41f5550060e6b44b","targetId":"b-a03dc1ec41f5550060e6b44b","page":"reading-opening","operation":"move","beforeSHA256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","afterSHA256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","reason":"Same source body in authored semantic page"},{"oldId":"b-fba83e7ddef7dca3f8a6624b","targetId":"b-fba83e7ddef7dca3f8a6624b","page":"reading-opening","operation":"move","beforeSHA256":"93899883c4c044ee5171cc6d4515e67b10961c3d3e67eb507245ef30c5e625ce","afterSHA256":"93899883c4c044ee5171cc6d4515e67b10961c3d3e67eb507245ef30c5e625ce","reason":"Same source body in authored semantic page"},{"oldId":"b-6f8a2573c9b4442c48454ec7","targetId":"b-6f8a2573c9b4442c48454ec7","page":"reading-opening","operation":"move","beforeSHA256":"99184b1537bc896faedebae68565b052be2c69ffdc9946314dc7092a753c5622","afterSHA256":"99184b1537bc896faedebae68565b052be2c69ffdc9946314dc7092a753c5622","reason":"Same source body in authored semantic page"},{"oldId":"b-f986b856ca71a4edb90cd388","targetId":"b-f986b856ca71a4edb90cd388","page":"reading-opening","operation":"move","beforeSHA256":"04cfa1ff8e1742085ca04585521c1244613487b61fd22b7d51efd932ee304fd9","afterSHA256":"04cfa1ff8e1742085ca04585521c1244613487b61fd22b7d51efd932ee304fd9","reason":"Same source body in authored semantic page"},{"oldId":"b-b7b4840c8113581bced74dca","targetId":"b-b7b4840c8113581bced74dca","page":"reading-opening","operation":"move","beforeSHA256":"3e0b23c8d256a20ed5858aa95c1b6c141d1980a9f060c4bb3de202629f70c729","afterSHA256":"3e0b23c8d256a20ed5858aa95c1b6c141d1980a9f060c4bb3de202629f70c729","reason":"Same source body in authored semantic page"},{"oldId":"b-9963e0b12a8927317ff9553c","targetId":"b-9963e0b12a8927317ff9553c","page":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","operation":"move","beforeSHA256":"066354b453dde3217bcd20ad5d01ce820005f8fc5feccfc632cd5b0654640861","afterSHA256":"066354b453dde3217bcd20ad5d01ce820005f8fc5feccfc632cd5b0654640861","reason":"Same source body in authored semantic page"},{"oldId":"b-bf74493932282e6c1710e735","targetId":"b-bf74493932282e6c1710e735","page":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","operation":"move","beforeSHA256":"e8ad277d85a395f5bf9865b5dd05871aacf8206711048bac6576e583cf6f1390","afterSHA256":"e8ad277d85a395f5bf9865b5dd05871aacf8206711048bac6576e583cf6f1390","reason":"Same source body in authored semantic page"},{"oldId":"b-ca542edf65ddbc631c1d2b9c","targetId":"b-ca542edf65ddbc631c1d2b9c","page":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","operation":"move","beforeSHA256":"6b8fbfca4d74c9c6f3dcfbc8bed30c112c46a02181062c8b73b3f25bcc374be5","afterSHA256":"6b8fbfca4d74c9c6f3dcfbc8bed30c112c46a02181062c8b73b3f25bcc374be5","reason":"Same source body in authored semantic page"},{"oldId":"b-9ed1a13614a186896664b668","targetId":"b-9ed1a13614a186896664b668","page":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","operation":"move","beforeSHA256":"7a489a1dbdb096f6dd9e0d154c2feb4669ee28167270f3e4597c511c01e3df54","afterSHA256":"7a489a1dbdb096f6dd9e0d154c2feb4669ee28167270f3e4597c511c01e3df54","reason":"Same source body in authored semantic page"},{"oldId":"b-1c3ce5790546de01a23380aa","targetId":"b-1c3ce5790546de01a23380aa","page":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","operation":"move","beforeSHA256":"bad2300d993a83e0bd2f5f97d8bebdf04b9365e535f41eed4cdd34f598052b42","afterSHA256":"bad2300d993a83e0bd2f5f97d8bebdf04b9365e535f41eed4cdd34f598052b42","reason":"Same source body in authored semantic page"},{"oldId":"b-94a5327c54cdb14fe701e21d","targetId":"b-94a5327c54cdb14fe701e21d","page":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","operation":"move","beforeSHA256":"4b2db02d51801a2a049f21dd444b05dd5995a8f2d564735ec14e1a2a5ab275c7","afterSHA256":"4b2db02d51801a2a049f21dd444b05dd5995a8f2d564735ec14e1a2a5ab275c7","reason":"Same source body in authored semantic page"},{"oldId":"b-40c53a405e11e6f8ba7b4bd0","targetId":"b-40c53a405e11e6f8ba7b4bd0","page":"reading-block-c99421410ab94ca7b487531b85fdabbd","operation":"move","beforeSHA256":"5cf91b1bd6e8dbb97a18a51303b155264cb9c9793f934635926793ca3ddb530f","afterSHA256":"5cf91b1bd6e8dbb97a18a51303b155264cb9c9793f934635926793ca3ddb530f","reason":"Same source body in authored semantic page"},{"oldId":"b-b8d5707ab873e825a4d4bcdd","targetId":"b-b8d5707ab873e825a4d4bcdd","page":"reading-block-c99421410ab94ca7b487531b85fdabbd","operation":"move","beforeSHA256":"3c6452e4c68b2f2324c124daee215c8a9dc985cc3fb0c350e18ab3991d733610","afterSHA256":"3c6452e4c68b2f2324c124daee215c8a9dc985cc3fb0c350e18ab3991d733610","reason":"Same source body in authored semantic page"},{"oldId":"b-3115e90ebbc90b5dccbf51f5","targetId":"b-3115e90ebbc90b5dccbf51f5","page":"reading-block-c99421410ab94ca7b487531b85fdabbd","operation":"move","beforeSHA256":"cfd743c13ae92d0ece85b4c55233fbbbe3fd2d40b1bd5ae6f0dfebaeb5a4ee77","afterSHA256":"cfd743c13ae92d0ece85b4c55233fbbbe3fd2d40b1bd5ae6f0dfebaeb5a4ee77","reason":"Same source body in authored semantic page"},{"oldId":"b-0838d632921da7f8e2f98e14","targetId":"b-0838d632921da7f8e2f98e14","page":"reading-block-c99421410ab94ca7b487531b85fdabbd","operation":"move","beforeSHA256":"fc9f5970c600c75cd83829c08500cffc9061bb011a648732981e185f95ad1c61","afterSHA256":"fc9f5970c600c75cd83829c08500cffc9061bb011a648732981e185f95ad1c61","reason":"Same source body in authored semantic page"},{"oldId":"b-bd8164b0545947eceb4fbf3c","targetId":"b-bd8164b0545947eceb4fbf3c","page":"reading-block-c99421410ab94ca7b487531b85fdabbd","operation":"move","beforeSHA256":"3098d3eb8f780b33c1762433ec3a9ada3dfc16c7c7b446357e70e645c768b17f","afterSHA256":"3098d3eb8f780b33c1762433ec3a9ada3dfc16c7c7b446357e70e645c768b17f","reason":"Same source body in authored semantic page"},{"oldId":"b-3a16fda463a0c31b4464e16c","targetId":"b-3a16fda463a0c31b4464e16c","page":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","operation":"move","beforeSHA256":"1b34590d9915e96e8353f99924e08982a17b8e3144a1d25fe05967289af8d3d3","afterSHA256":"1b34590d9915e96e8353f99924e08982a17b8e3144a1d25fe05967289af8d3d3","reason":"Same source body in authored semantic page"},{"oldId":"b-149545596200b8d3a300e994","targetId":"b-149545596200b8d3a300e994","page":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","operation":"move","beforeSHA256":"39c691941ef6e08cdc882fb732b90d6f7d91fa1c76068b9dba317947729a7168","afterSHA256":"39c691941ef6e08cdc882fb732b90d6f7d91fa1c76068b9dba317947729a7168","reason":"Same source body in authored semantic page"},{"oldId":"b-ebc366c8aadcc5bfc625f76c","targetId":"b-ebc366c8aadcc5bfc625f76c","page":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","operation":"move","beforeSHA256":"86e85a001908dfa764ae7b719fbe872ac45b129a719084bd81161e73cbd67a12","afterSHA256":"86e85a001908dfa764ae7b719fbe872ac45b129a719084bd81161e73cbd67a12","reason":"Same source body in authored semantic page"},{"oldId":"b-25acc25a4ff2be7c507c77a0","targetId":"b-25acc25a4ff2be7c507c77a0","page":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","operation":"move","beforeSHA256":"037694098c36fa9e1f66ed918865df1f003d2a1bc7c2e6e11e61f3d1326a9c8c","afterSHA256":"037694098c36fa9e1f66ed918865df1f003d2a1bc7c2e6e11e61f3d1326a9c8c","reason":"Same source body in authored semantic page"},{"oldId":"b-64d672ffbb6f461303689105","targetId":"b-64d672ffbb6f461303689105","page":"reading-block-487567d0bb1d40039f1f87805d46ee76","operation":"move","beforeSHA256":"c18a731b0741ea5dc8455aa95ff4e3aa4cdbdd52147c2c754288882b966b2fff","afterSHA256":"c18a731b0741ea5dc8455aa95ff4e3aa4cdbdd52147c2c754288882b966b2fff","reason":"Same source body in authored semantic page"},{"oldId":"b-d198ca2dbb9558b2b7fa2d4f","targetId":"b-d198ca2dbb9558b2b7fa2d4f","page":"reading-block-487567d0bb1d40039f1f87805d46ee76","operation":"move","beforeSHA256":"f75c5092579fa19dfcbe964303c4293706d70207d65ae39daa074b9f9a326009","afterSHA256":"f75c5092579fa19dfcbe964303c4293706d70207d65ae39daa074b9f9a326009","reason":"Same source body in authored semantic page"},{"oldId":"b-e6bf0ced565bd4aeaadf2e49","targetId":"b-e6bf0ced565bd4aeaadf2e49","page":"reading-block-487567d0bb1d40039f1f87805d46ee76","operation":"move","beforeSHA256":"d38bb953c0f055c9c6edbfca55c4e07842898a4cd1866288229b4c401e4be5cf","afterSHA256":"d38bb953c0f055c9c6edbfca55c4e07842898a4cd1866288229b4c401e4be5cf","reason":"Same source body in authored semantic page"},{"oldId":"b-50d13b3966a5b4e1031779ca","targetId":"b-50d13b3966a5b4e1031779ca","page":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","operation":"move","beforeSHA256":"9f41499a557a00bd3d59d859558b46124bfb9b0c8f6789bae6ed79386186cc4f","afterSHA256":"9f41499a557a00bd3d59d859558b46124bfb9b0c8f6789bae6ed79386186cc4f","reason":"Same source body in authored semantic page"},{"oldId":"b-3a0fa04f5a61c09c02f3d546","targetId":"b-3a0fa04f5a61c09c02f3d546","page":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","operation":"move","beforeSHA256":"1f2040210dfc2c038361512a9e60e5e39863816685141e2d9ed1276eb3d56efb","afterSHA256":"1f2040210dfc2c038361512a9e60e5e39863816685141e2d9ed1276eb3d56efb","reason":"Same source body in authored semantic page"},{"oldId":"b-204466e62c807900ceeefcd4","targetId":"b-204466e62c807900ceeefcd4","page":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","operation":"move","beforeSHA256":"ab0b0e22587166aea5a9af4d6a3c23f74f6234fa00473516ddd3c922014699eb","afterSHA256":"ab0b0e22587166aea5a9af4d6a3c23f74f6234fa00473516ddd3c922014699eb","reason":"Same source body in authored semantic page"},{"oldId":"b-1833ab9273023de52d5edf94","targetId":"b-1833ab9273023de52d5edf94","page":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","operation":"move","beforeSHA256":"69910f0e843b76b0a9e207e1e13e524023bbfe037d0f6cd9c295e98abfdf64a5","afterSHA256":"69910f0e843b76b0a9e207e1e13e524023bbfe037d0f6cd9c295e98abfdf64a5","reason":"Same source body in authored semantic page"},{"oldId":"b-f6386c0872a9d49b2a1ba361","targetId":"b-f6386c0872a9d49b2a1ba361","page":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","operation":"move","beforeSHA256":"ae6109b950401193f5256036ea197169997c9abf6e09018367d63b1b3b9697af","afterSHA256":"ae6109b950401193f5256036ea197169997c9abf6e09018367d63b1b3b9697af","reason":"Same source body in authored semantic page"},{"oldId":"b-dfdbf00196f8fd6b2233593d","targetId":"b-dfdbf00196f8fd6b2233593d","page":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","operation":"move","beforeSHA256":"6f1f64585357fa0d50beee983ee99c16e80bdf6eff58262950001f171ab07a13","afterSHA256":"6f1f64585357fa0d50beee983ee99c16e80bdf6eff58262950001f171ab07a13","reason":"Same source body in authored semantic page"},{"oldId":"b-122d8f83b002180c3d90027f","targetId":"b-122d8f83b002180c3d90027f","page":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","operation":"move","beforeSHA256":"a8de3244286e583a34410f672ae0a8773ec99c72b4b883c1f41fab942e792874","afterSHA256":"a8de3244286e583a34410f672ae0a8773ec99c72b4b883c1f41fab942e792874","reason":"Same source body in authored semantic page"},{"oldId":"b-919f32f56e02a0e99186a75c","targetId":"b-919f32f56e02a0e99186a75c","page":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","operation":"move","beforeSHA256":"d248fdb1d8ed367c289941e0f3eb2ce08c9c0e843c28541e882f8d24050567f2","afterSHA256":"d248fdb1d8ed367c289941e0f3eb2ce08c9c0e843c28541e882f8d24050567f2","reason":"Same source body in authored semantic page"},{"oldId":"b-7ceb124d66e5083c7be21b4d","targetId":"b-7ceb124d66e5083c7be21b4d","page":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","operation":"move","beforeSHA256":"13aa6f19d1012ce26455856541869391d75585395369a37bff83c083c0b497a7","afterSHA256":"13aa6f19d1012ce26455856541869391d75585395369a37bff83c083c0b497a7","reason":"Same source body in authored semantic page"},{"oldId":"b-5dd10f5947cda70b27154fc3","targetId":"b-5dd10f5947cda70b27154fc3","page":"reading-block-8bcdc8923f8c411583dec053e8e89211","operation":"move","beforeSHA256":"04208d85b0663ccd5bb1af1e3d9db049d444d21356b79b70f11bbb00375d24f5","afterSHA256":"04208d85b0663ccd5bb1af1e3d9db049d444d21356b79b70f11bbb00375d24f5","reason":"Same source body in authored semantic page"},{"oldId":"b-e7f7708a5145fe4a757de526","targetId":"b-e7f7708a5145fe4a757de526","page":"reading-block-8bcdc8923f8c411583dec053e8e89211","operation":"move","beforeSHA256":"85752b6cc66a89e4b4b497d2fbbd60f747c5b25bf0e4c8b2176754d62f1ea4e3","afterSHA256":"85752b6cc66a89e4b4b497d2fbbd60f747c5b25bf0e4c8b2176754d62f1ea4e3","reason":"Same source body in authored semantic page"},{"oldId":"b-ea67066fd1b8dfc2bcc0a5e5","targetId":"b-ea67066fd1b8dfc2bcc0a5e5","page":"reading-block-8bcdc8923f8c411583dec053e8e89211","operation":"move","beforeSHA256":"0a748c53d9a4c3bfaa27b3278192fb7b8f6dd8e500e31fe3d83843c1683cb0d6","afterSHA256":"0a748c53d9a4c3bfaa27b3278192fb7b8f6dd8e500e31fe3d83843c1683cb0d6","reason":"Same source body in authored semantic page"},{"oldId":"b-37dea60746827d41dd31618d","targetId":"b-37dea60746827d41dd31618d","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"001a78ee1c513c635eb2d2b2e751bba8e86aa82d93f8ce78390f8a8f6a0bd517","afterSHA256":"001a78ee1c513c635eb2d2b2e751bba8e86aa82d93f8ce78390f8a8f6a0bd517","reason":"Same source body in authored semantic page"},{"oldId":"b-96b9fe73e6a67ce3404848b0","targetId":"b-96b9fe73e6a67ce3404848b0","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"d84d8dad59a6ffb108aeae91a8cb273eda4ff3f48305a027cdd932f6d8e5e8a0","afterSHA256":"d84d8dad59a6ffb108aeae91a8cb273eda4ff3f48305a027cdd932f6d8e5e8a0","reason":"Same source body in authored semantic page"},{"oldId":"b-2fd076e60bdf43f5335f9659","targetId":"b-2fd076e60bdf43f5335f9659","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"rewrite","beforeSHA256":"b57e8e1c35bec9f38a1c9369ffff51797ba77d85412241f19f82f6e51f05ba0c","afterSHA256":"73e6ee4f5bc1ec01e514c198ef41c666c445db1abd171363f941bba419e6f8f9","reason":"Same source identity with figure semantics or reading context enriched"},{"oldId":"b-2511c1834157f5eacc5de88e","targetId":"b-2511c1834157f5eacc5de88e","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"c6ec3f412fe5cfe2ca58ee848a30beb02149b91ff80161b42c3aac7fe2b1c45b","afterSHA256":"c6ec3f412fe5cfe2ca58ee848a30beb02149b91ff80161b42c3aac7fe2b1c45b","reason":"Same source body in authored semantic page"},{"oldId":"b-20999241cdd7e8a6c620bd8e","targetId":"b-20999241cdd7e8a6c620bd8e","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"a2ea14d57ad8a91c3ff6f2de6b8fb5038749dd9c2295538009a53248f585d5c0","afterSHA256":"fd311f09d4288da59a18a7ca0f10ad5b5822379eabf7929f5465b7c8885e410f","reason":"Same source body in authored semantic page"},{"oldId":"b-3496e93ea54df832853c9c09","targetId":"b-3496e93ea54df832853c9c09","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"026daa95e6894c51ebc29e21ccfa1bfaa2e2c46e9a58534d02d68b5106c9b5db","afterSHA256":"026daa95e6894c51ebc29e21ccfa1bfaa2e2c46e9a58534d02d68b5106c9b5db","reason":"Same source body in authored semantic page"},{"oldId":"b-b77843d07316617767ab3893","targetId":"b-b77843d07316617767ab3893","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"67452083274618b6205623f0809f280603d9c3f2fe7dc26259999b85be470111","afterSHA256":"de16d3aedb230c3d5dc38cc55d3da0065a5171215ac4a0d2e3bc2ce15c7a1484","reason":"Same source body in authored semantic page"},{"oldId":"b-c65415596544842eed4c7e67","targetId":"b-c65415596544842eed4c7e67","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"4fcb7db780784522fef94931035d003fe88b2ff55e490138423218f2ff38afd9","afterSHA256":"4fcb7db780784522fef94931035d003fe88b2ff55e490138423218f2ff38afd9","reason":"Same source body in authored semantic page"},{"oldId":"b-6b0d79b113d53d1a3d311166","targetId":"b-6b0d79b113d53d1a3d311166","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"81398a8272ebfd33a98a6d8cfb892a8aac61498685cefe8b23c82aa0cc21e4be","afterSHA256":"82f4a4726293f261553d8268be54092dc78ef60a488504fef74f563c52a2cab9","reason":"Same source body in authored semantic page"},{"oldId":"b-d69ce0fa30cdeff08dc75683","targetId":"b-d69ce0fa30cdeff08dc75683","page":"reading-block-21be8b44d55348839633cb13b2e148a4","operation":"move","beforeSHA256":"39f9891a8dd80a1c407f6f8ccac4397cb71a5bba5898a0e55f464f839f497514","afterSHA256":"39f9891a8dd80a1c407f6f8ccac4397cb71a5bba5898a0e55f464f839f497514","reason":"Same source body in authored semantic page"},{"oldId":"b-a0b62572aa03469c1da2bee6","targetId":"b-a0b62572aa03469c1da2bee6","page":"reading-block-3dc8766f20144da28bbef37cade18a3d","operation":"move","beforeSHA256":"26a7cbe49a363a14a248834129e6d61a20d9aa9861079f66efe0ecca0a3f9a6b","afterSHA256":"26a7cbe49a363a14a248834129e6d61a20d9aa9861079f66efe0ecca0a3f9a6b","reason":"Same source body in authored semantic page"},{"oldId":"b-0cede9806461b9b533a0fcd9","targetId":"b-0cede9806461b9b533a0fcd9","page":"reading-block-3dc8766f20144da28bbef37cade18a3d","operation":"move","beforeSHA256":"80d65a4fb686786c0f111c5580f2a1dc3c9a542aed8d416cdf9ab7f723b2f3eb","afterSHA256":"80d65a4fb686786c0f111c5580f2a1dc3c9a542aed8d416cdf9ab7f723b2f3eb","reason":"Same source body in authored semantic page"},{"oldId":"b-cf5c04a01802990808019e18","targetId":"b-cf5c04a01802990808019e18","page":"reading-block-3dc8766f20144da28bbef37cade18a3d","operation":"move","beforeSHA256":"54419b0c3585352e9f49dbf54b576784a7f8a9b5d3df629a511b72a9ef3055ec","afterSHA256":"54419b0c3585352e9f49dbf54b576784a7f8a9b5d3df629a511b72a9ef3055ec","reason":"Same source body in authored semantic page"},{"oldId":"block-a2ef0fcda60a4b44806ada2d2bccb2b3--选读热身四维分类的参数更新","targetId":"b-9963e0b12a8927317ff9553c","operation":"retain-source-identity"},{"oldId":"block-c99421410ab94ca7b487531b85fdabbd--主实验的输入目标和固定协议","targetId":"b-40c53a405e11e6f8ba7b4bd0","operation":"retain-source-identity"},{"oldId":"block-3f2817fbef024a0f9bc945dd0b1a1b81--读源码时跟踪三种集合","targetId":"b-3a16fda463a0c31b4464e16c","operation":"retain-source-identity"},{"oldId":"block-487567d0bb1d40039f1f87805d46ee76--固定锚框怎样变成待学习的偏移","targetId":"b-64d672ffbb6f461303689105","operation":"retain-source-identity"},{"oldId":"block-f702d0b00d7a4a37abd3a8da99a3cd39--哪些锚框受哪一种监督","targetId":"b-50d13b3966a5b4e1031779ca","operation":"retain-source-identity"},{"oldId":"block-950aab9e6fbf43b4aef8ee21b9268a87--从共享特征到两个输出头","targetId":"b-f6386c0872a9d49b2a1ba361","operation":"retain-source-identity"},{"oldId":"block-8bcdc8923f8c411583dec053e8e89211--实际训练与可复查的输出","targetId":"b-5dd10f5947cda70b27154fc3","operation":"retain-source-identity"},{"oldId":"block-21be8b44d55348839633cb13b2e148a4--已完成基准分数高哪里仍会错","targetId":"b-37dea60746827d41dd31618d","operation":"retain-source-identity"},{"oldId":"block-3dc8766f20144da28bbef37cade18a3d--来源与下一条问题","targetId":"b-a0b62572aa03469c1da2bee6","operation":"retain-source-identity"}],"blocks":[{"id":"b-b6e9b3aee5a4411c12e9de05","type":"h1","scope":"document","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-b6e9b3aee5a4411c12e9de05","content":"# LAB 10 · 从 RGB 图像训练小型检测器","sha256":"a7b6ffb439439b1a9c61813cc32d9bb6766638ff7c32f53fe1f90b5b5699b7e6","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","number":1},"sectionTitle":"LAB 10 · 从 RGB 图像训练小型检测器","currentQuestion":"LAB 10 · 从 RGB 图像训练小型检测器","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-5f1c976ea7362357367bac5a","prerequisites":[{"id":"b-5f1c976ea7362357367bac5a","url":"#b-5f1c976ea7362357367bac5a","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-5f1c976ea7362357367bac5a","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-5f1c976ea7362357367bac5a","content":"主线阅读与优先实验","sha256":"42cba31deccba2a350b9b23bd0ca1dcaa4c4c5cb9d35c773e1fcb89124788ccd","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","number":1},"sectionTitle":"LAB 10 · 从 RGB 图像训练小型检测器","currentQuestion":"LAB 10 · 从 RGB 图像训练小型检测器","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b6e9b3aee5a4411c12e9de05","nextBlock":"b-394caca18a925a6f63f6b45b","prerequisites":[{"id":"b-b6e9b3aee5a4411c12e9de05","url":"#b-b6e9b3aee5a4411c12e9de05","role":"section-title"}],"relatedBlocks":[]},{"id":"b-394caca18a925a6f63f6b45b","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-394caca18a925a6f63f6b45b","content":"RGB图像、单特征层锚框检测器、分类/位置损失、NMS、独立检测评价","sha256":"b1c765d7bf903321abd36e75bae49048d61faec2aa3fd11922b328c5970003b1","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","number":1},"sectionTitle":"LAB 10 · 从 RGB 图像训练小型检测器","currentQuestion":"LAB 10 · 从 RGB 图像训练小型检测器","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-5f1c976ea7362357367bac5a","nextBlock":"b-a03dc1ec41f5550060e6b44b","prerequisites":[{"id":"b-b6e9b3aee5a4411c12e9de05","url":"#b-b6e9b3aee5a4411c12e9de05","role":"section-title"},{"id":"b-5f1c976ea7362357367bac5a","url":"#b-5f1c976ea7362357367bac5a","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-a03dc1ec41f5550060e6b44b","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-a03dc1ec41f5550060e6b44b","content":"可先阅读已有结果，再决定是否运行。重算时请核对各节记录的数据、参数、环境与日期。","sha256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","number":1},"sectionTitle":"LAB 10 · 从 RGB 图像训练小型检测器","currentQuestion":"LAB 10 · 从 RGB 图像训练小型检测器","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-394caca18a925a6f63f6b45b","nextBlock":"b-fba83e7ddef7dca3f8a6624b","prerequisites":[{"id":"b-b6e9b3aee5a4411c12e9de05","url":"#b-b6e9b3aee5a4411c12e9de05","role":"section-title"},{"id":"b-5f1c976ea7362357367bac5a","url":"#b-5f1c976ea7362357367bac5a","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-fba83e7ddef7dca3f8a6624b","type":"p","scope":"block-63590d65568c4b639fa4997d22fa749c","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-fba83e7ddef7dca3f8a6624b","content":"**学习路径：** [一张图怎样变成一组框](/course/study/image-detection.html)","sha256":"93899883c4c044ee5171cc6d4515e67b10961c3d3e67eb507245ef30c5e625ce","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","number":1},"sectionTitle":"LAB 10 · 从 RGB 图像训练小型检测器","currentQuestion":"LAB 10 · 从 RGB 图像训练小型检测器","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-a03dc1ec41f5550060e6b44b","nextBlock":"b-6f8a2573c9b4442c48454ec7","prerequisites":[{"id":"b-b6e9b3aee5a4411c12e9de05","url":"#b-b6e9b3aee5a4411c12e9de05","role":"section-title"},{"id":"b-5f1c976ea7362357367bac5a","url":"#b-5f1c976ea7362357367bac5a","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-6f8a2573c9b4442c48454ec7","type":"p","scope":"block-63590d65568c4b639fa4997d22fa749c","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-6f8a2573c9b4442c48454ec7","content":"从 [P32–35 的检测流程](/course/pages/l3-r2-p32.html) 进入一项完整学习实验：48×48 RGB → 共享特征 → 类别与框偏移 → 解码/NMS → 保留图像评价。真值框只进入目标与评价，不进入模型输入。","sha256":"99184b1537bc896faedebae68565b052be2c69ffdc9946314dc7092a753c5622","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","number":1},"sectionTitle":"LAB 10 · 从 RGB 图像训练小型检测器","currentQuestion":"LAB 10 · 从 RGB 图像训练小型检测器","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-fba83e7ddef7dca3f8a6624b","nextBlock":"b-f986b856ca71a4edb90cd388","prerequisites":[{"id":"b-b6e9b3aee5a4411c12e9de05","url":"#b-b6e9b3aee5a4411c12e9de05","role":"section-title"},{"id":"b-5f1c976ea7362357367bac5a","url":"#b-5f1c976ea7362357367bac5a","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-f986b856ca71a4edb90cd388","type":"p","scope":"block-63590d65568c4b639fa4997d22fa749c","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-f986b856ca71a4edb90cd388","content":"先看 [已有结果与失败图](/course/blocks/detector-learning-evidence.html)，挑一张解释哪里没检好，再回到输入协议、匹配和两个输出头。四维逻辑回归只是可选分类热身；主实验是 TinySSD 闭环的单特征层教学变体。完整复跑按格顺序执行，另写 `lab10-results-rerun`，不覆盖历史证据。","sha256":"04cfa1ff8e1742085ca04585521c1244613487b61fd22b7d51efd932ee304fd9","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","number":1},"sectionTitle":"LAB 10 · 从 RGB 图像训练小型检测器","currentQuestion":"LAB 10 · 从 RGB 图像训练小型检测器","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6f8a2573c9b4442c48454ec7","nextBlock":"b-b7b4840c8113581bced74dca","prerequisites":[{"id":"b-b6e9b3aee5a4411c12e9de05","url":"#b-b6e9b3aee5a4411c12e9de05","role":"section-title"},{"id":"b-5f1c976ea7362357367bac5a","url":"#b-5f1c976ea7362357367bac5a","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-b7b4840c8113581bced74dca","type":"p","scope":"block-63590d65568c4b639fa4997d22fa749c","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-b7b4840c8113581bced74dca","content":"本册的产出是一条错误分析：它是漏检、错类、框偏还是重复？你会只改哪个条件来验证？遇到公式去 [LAB 09](https://deepnote.com/project/38755e4e-23f6-4f5f-8c68-8a2e4114b1c1/notebook/90d213b4e1e04c7e889ee6fc042b2358) 或 [CLS 07](https://deepnote.com/project/38755e4e-23f6-4f5f-8c68-8a2e4114b1c1/notebook/586e66e049764158a50747e69c219312)；想研究轮廓而非包围框，可另选 [LAB 11](https://deepnote.com/project/38755e4e-23f6-4f5f-8c68-8a2e4114b1c1/notebook/9e268706471944e3a59e6f568f9ce9a3)，不必为完成本册再训练第二项。","sha256":"3e0b23c8d256a20ed5858aa95c1b6c141d1980a9f060c4bb3de202629f70c729","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-opening","title":"LAB 10 · 从 RGB 图像训练小型检测器","number":1},"sectionTitle":"LAB 10 · 从 RGB 图像训练小型检测器","currentQuestion":"LAB 10 · 从 RGB 图像训练小型检测器","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-f986b856ca71a4edb90cd388","nextBlock":null,"prerequisites":[{"id":"b-b6e9b3aee5a4411c12e9de05","url":"#b-b6e9b3aee5a4411c12e9de05","role":"section-title"},{"id":"b-5f1c976ea7362357367bac5a","url":"#b-5f1c976ea7362357367bac5a","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9963e0b12a8927317ff9553c","type":"h2","scope":"block-a2ef0fcda60a4b44806ada2d2bccb2b3","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-9963e0b12a8927317ff9553c","content":"## 选读热身：四维分类的参数更新","sha256":"066354b453dde3217bcd20ad5d01ce820005f8fc5feccfc632cd5b0654640861","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","title":"选读热身：四维分类的参数更新","number":2},"sectionTitle":"选读热身：四维分类的参数更新","currentQuestion":"选读热身：四维分类的参数更新","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-bf74493932282e6c1710e735","prerequisites":[{"id":"b-bf74493932282e6c1710e735","url":"#b-bf74493932282e6c1710e735","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-bf74493932282e6c1710e735","type":"p","scope":"block-a2ef0fcda60a4b44806ada2d2bccb2b3","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-bf74493932282e6c1710e735","content":"四维向量 $x$ 经过 $p=\\sigma(x^T w)$，交叉熵梯度是 $X^T(p-y)/N$。这里确实有参数学习，但四个数不是图像，也没有框目标；准确率只能说明这个人为超平面能否被重获。预测先于运行：只把训练标签打乱，保留集仍按原超平面给真值，模型还能恢复原规则吗？随机标签不提供真实规律，但单次有限样本分数不必恰好等于 .5。这个对照检查的是监督关系，不涉及定位。","sha256":"e8ad277d85a395f5bf9865b5dd05871aacf8206711048bac6576e583cf6f1390","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","title":"选读热身：四维分类的参数更新","number":2},"sectionTitle":"选读热身：四维分类的参数更新","currentQuestion":"选读热身：四维分类的参数更新","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"x","definitionContext":"选读热身：四维分类的参数更新"},{"latex":"p=\\sigma(x^T w)","definitionContext":"选读热身：四维分类的参数更新"},{"latex":"X^T(p-y)/N","definitionContext":"选读热身：四维分类的参数更新"}],"previousBlock":"b-9963e0b12a8927317ff9553c","nextBlock":"b-ca542edf65ddbc631c1d2b9c","prerequisites":[{"id":"b-9963e0b12a8927317ff9553c","url":"#b-9963e0b12a8927317ff9553c","role":"section-title"}],"relatedBlocks":[]},{"id":"b-ca542edf65ddbc631c1d2b9c","type":"p","scope":"block-a2ef0fcda60a4b44806ada2d2bccb2b3","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-ca542edf65ddbc631c1d2b9c","content":"下格保留原数据、200 次更新与权重输出，补上独立保留样本及标签打乱条件；明确把原来的 “objectness accuracy” 改为四维分类热身的训练准确率。本次实跑：训练准确率 .953125，独立同规则保留集 .94921875，打乱训练标签后在同一保留集仅 .36328125；这个下降也不能变成检测能力的证据。","sha256":"6b8fbfca4d74c9c6f3dcfbc8bed30c112c46a02181062c8b73b3f25bcc374be5","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","title":"选读热身：四维分类的参数更新","number":2},"sectionTitle":"选读热身：四维分类的参数更新","currentQuestion":"选读热身：四维分类的参数更新","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-bf74493932282e6c1710e735","nextBlock":"b-9ed1a13614a186896664b668","prerequisites":[{"id":"b-9963e0b12a8927317ff9553c","url":"#b-9963e0b12a8927317ff9553c","role":"section-title"},{"id":"b-bf74493932282e6c1710e735","url":"#b-bf74493932282e6c1710e735","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9ed1a13614a186896664b668","type":"p","scope":"block-a2ef0fcda60a4b44806ada2d2bccb2b3","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-9ed1a13614a186896664b668","content":"若已经熟悉 sigmoid 与交叉熵，可直接阅读“主实验的输入、目标和固定协议”；完整复跑仍按格顺序执行即可。","sha256":"7a489a1dbdb096f6dd9e0d154c2feb4669ee28167270f3e4597c511c01e3df54","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","title":"选读热身：四维分类的参数更新","number":2},"sectionTitle":"选读热身：四维分类的参数更新","currentQuestion":"选读热身：四维分类的参数更新","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-ca542edf65ddbc631c1d2b9c","nextBlock":"b-1c3ce5790546de01a23380aa","prerequisites":[{"id":"b-9963e0b12a8927317ff9553c","url":"#b-9963e0b12a8927317ff9553c","role":"section-title"},{"id":"b-bf74493932282e6c1710e735","url":"#b-bf74493932282e6c1710e735","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-1c3ce5790546de01a23380aa","type":"pre","scope":"block-359eb6716e0e4a48b9c8477fcd25be5b","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-1c3ce5790546de01a23380aa","content":"```\nimport os, tempfile\nfrom pathlib import Path\n# Isolated ephemeral workspace supports detached runs with readonly project storage.\nSPATIAL_RUN_DIR = Path(tempfile.mkdtemp(prefix='lecture03-'))\nos.chdir(SPATIAL_RUN_DIR)\nprint('Ephemeral experiment directory:', SPATIAL_RUN_DIR)\n```","sha256":"bad2300d993a83e0bd2f5f97d8bebdf04b9365e535f41eed4cdd34f598052b42","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","title":"选读热身：四维分类的参数更新","number":2},"sectionTitle":"选读热身：四维分类的参数更新","currentQuestion":"选读热身：四维分类的参数更新","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-9ed1a13614a186896664b668","nextBlock":"b-94a5327c54cdb14fe701e21d","prerequisites":[{"id":"b-9963e0b12a8927317ff9553c","url":"#b-9963e0b12a8927317ff9553c","role":"section-title"},{"id":"b-bf74493932282e6c1710e735","url":"#b-bf74493932282e6c1710e735","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-94a5327c54cdb14fe701e21d","type":"pre","scope":"block-bec8290eec6f4d2099698e2e9a5971f7","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-94a5327c54cdb14fe701e21d","content":"```\nimport numpy as np\nrng=np.random.default_rng(7)\nX=rng.normal(size=(64,4)); true=np.array([.8,-.4,.3,.2]); y=(X@true>0).astype(float);w=np.zeros(4)\nfor step in range(200):\n    p=1/(1+np.exp(-X@w));w-=.2*(X.T@(p-y))/len(y)\nprint('four-dimensional logistic warm-up, training accuracy:',float(((X@w>0)==y).mean()))\nprint('learned weights:',w.round(3))\n# A fresh held-out matrix answers a different question from training accuracy.\nheld=np.random.default_rng(107).normal(size=(256,4));held_y=held@true>0\nprint('same-rule held-out accuracy:',float(((held@w>0)==held_y).mean()))\nshuffled=np.random.default_rng(17).permutation(y);ws=np.zeros(4)\nfor step in range(200):\n    ps=1/(1+np.exp(-X@ws));ws-=.2*(X.T@(ps-shuffled))/len(shuffled)\nprint('only training labels shuffled, held-out true-rule accuracy:',float(((held@ws>0)==held_y).mean()))\n```","sha256":"4b2db02d51801a2a049f21dd444b05dd5995a8f2d564735ec14e1a2a5ab275c7","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-a2ef0fcda60a4b44806ada2d2bccb2b3","title":"选读热身：四维分类的参数更新","number":2},"sectionTitle":"选读热身：四维分类的参数更新","currentQuestion":"选读热身：四维分类的参数更新","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-1c3ce5790546de01a23380aa","nextBlock":null,"prerequisites":[{"id":"b-9963e0b12a8927317ff9553c","url":"#b-9963e0b12a8927317ff9553c","role":"section-title"},{"id":"b-bf74493932282e6c1710e735","url":"#b-bf74493932282e6c1710e735","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-40c53a405e11e6f8ba7b4bd0","type":"h2","scope":"block-c99421410ab94ca7b487531b85fdabbd","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-40c53a405e11e6f8ba7b4bd0","content":"## 主实验的输入、目标和固定协议","sha256":"5cf91b1bd6e8dbb97a18a51303b155264cb9c9793f934635926793ca3ddb530f","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-c99421410ab94ca7b487531b85fdabbd","title":"主实验的输入、目标和固定协议","number":3},"sectionTitle":"主实验的输入、目标和固定协议","currentQuestion":"主实验的输入、目标和固定协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-b8d5707ab873e825a4d4bcdd","prerequisites":[{"id":"b-b8d5707ab873e825a4d4bcdd","url":"#b-b8d5707ab873e825a4d4bcdd","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-b8d5707ab873e825a4d4bcdd","type":"p","scope":"block-c99421410ab94ca7b487531b85fdabbd","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-b8d5707ab873e825a4d4bcdd","content":"每张输入是 `[3,48,48]` 浮点 RGB 图像。目标字典包含 `[M,4]` 的归一化 `xyxy` 框及 `[M]` 类别，$M\\in\\{0,1,2,3\\}$。红色矩形为 1，蓝色椭圆为 2，背景为 0。位置、尺寸、亮度和对象数变化；18% 的生成概率留给空图。空图要教模型输出“没有目标”，不是强迫每图选一个框。目标框只进入损失与评价，`model(images)` 的参数里没有坐标或标签。","sha256":"3c6452e4c68b2f2324c124daee215c8a9dc985cc3fb0c350e18ab3991d733610","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-c99421410ab94ca7b487531b85fdabbd","title":"主实验的输入、目标和固定协议","number":3},"sectionTitle":"主实验的输入、目标和固定协议","currentQuestion":"主实验的输入、目标和固定协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"M\\in\\{0,1,2,3\\}","definitionContext":"主实验的输入、目标和固定协议"}],"previousBlock":"b-40c53a405e11e6f8ba7b4bd0","nextBlock":"b-3115e90ebbc90b5dccbf51f5","prerequisites":[{"id":"b-40c53a405e11e6f8ba7b4bd0","url":"#b-40c53a405e11e6f8ba7b4bd0","role":"section-title"}],"relatedBlocks":[]},{"id":"b-3115e90ebbc90b5dccbf51f5","type":"p","scope":"block-c99421410ab94ca7b487531b85fdabbd","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-3115e90ebbc90b5dccbf51f5","content":"768 张训练图、96 张验证图、192 张保留图使用不同原始场景种子 1101/3101/5901。训练固定 28 epoch、Adam 学习率 .002、batch 32；验证集仅给固定方案的读数，没有用保留集反复挑最好超参数。本次保留集实际有 296 个对象、33 张空图、108 张多对象图。合成类别同时与颜色、轮廓相关，所以它适合验证图像到位置的学习链，不能证明自然图像的形状泛化。","sha256":"cfd743c13ae92d0ece85b4c55233fbbbe3fd2d40b1bd5ae6f0dfebaeb5a4ee77","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-c99421410ab94ca7b487531b85fdabbd","title":"主实验的输入、目标和固定协议","number":3},"sectionTitle":"主实验的输入、目标和固定协议","currentQuestion":"主实验的输入、目标和固定协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b8d5707ab873e825a4d4bcdd","nextBlock":"b-0838d632921da7f8e2f98e14","prerequisites":[{"id":"b-40c53a405e11e6f8ba7b4bd0","url":"#b-40c53a405e11e6f8ba7b4bd0","role":"section-title"},{"id":"b-b8d5707ab873e825a4d4bcdd","url":"#b-b8d5707ab873e825a4d4bcdd","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-0838d632921da7f8e2f98e14","type":"p","scope":"block-c99421410ab94ca7b487531b85fdabbd","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-0838d632921da7f8e2f98e14","content":"在同一个原始场景种子下将尺寸乘以 .5，背景、类别、颜色、中心、对象数不变，只重新光栅化尺寸及其框。它是可核验的尺度对照。下面源码完整可见；首格覆盖当前脚本，后续格顺序追加，因此请从上到下运行。","sha256":"fc9f5970c600c75cd83829c08500cffc9061bb011a648732981e185f95ad1c61","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-c99421410ab94ca7b487531b85fdabbd","title":"主实验的输入、目标和固定协议","number":3},"sectionTitle":"主实验的输入、目标和固定协议","currentQuestion":"主实验的输入、目标和固定协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-3115e90ebbc90b5dccbf51f5","nextBlock":"b-bd8164b0545947eceb4fbf3c","prerequisites":[{"id":"b-40c53a405e11e6f8ba7b4bd0","url":"#b-40c53a405e11e6f8ba7b4bd0","role":"section-title"},{"id":"b-b8d5707ab873e825a4d4bcdd","url":"#b-b8d5707ab873e825a4d4bcdd","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-bd8164b0545947eceb4fbf3c","type":"pre","scope":"block-7be8ac6a71494b79a0db46868b83e27f","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-bd8164b0545947eceb4fbf3c","content":"```\nimport importlib.util, subprocess, sys\nfrom pathlib import Path\n# The only download, if needed, is open-source Python packages, not model weights.\nif importlib.util.find_spec('torch') is None:\n    subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'torch', '--index-url', 'https://download.pytorch.org/whl/cpu'])\nmissing=[p for p in ['numpy','matplotlib'] if importlib.util.find_spec(p) is None]\nif missing: subprocess.check_call([sys.executable,'-m','pip','install',*missing])\nimport torch, numpy as np\nprint('Python',sys.version.split()[0], 'torch',torch.__version__, 'numpy',np.__version__, 'device: CPU')\n```","sha256":"3098d3eb8f780b33c1762433ec3a9ada3dfc16c7c7b446357e70e645c768b17f","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-c99421410ab94ca7b487531b85fdabbd","title":"主实验的输入、目标和固定协议","number":3},"sectionTitle":"主实验的输入、目标和固定协议","currentQuestion":"主实验的输入、目标和固定协议","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-0838d632921da7f8e2f98e14","nextBlock":null,"prerequisites":[{"id":"b-40c53a405e11e6f8ba7b4bd0","url":"#b-40c53a405e11e6f8ba7b4bd0","role":"section-title"},{"id":"b-b8d5707ab873e825a4d4bcdd","url":"#b-b8d5707ab873e825a4d4bcdd","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-3a16fda463a0c31b4464e16c","type":"h2","scope":"block-3f2817fbef024a0f9bc945dd0b1a1b81","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-3a16fda463a0c31b4464e16c","content":"## 读源码时跟踪三种集合","sha256":"1b34590d9915e96e8353f99924e08982a17b8e3144a1d25fe05967289af8d3d3","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","title":"读源码时跟踪三种集合","number":4},"sectionTitle":"读源码时跟踪三种集合","currentQuestion":"读源码时跟踪三种集合","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-149545596200b8d3a300e994","prerequisites":[{"id":"b-149545596200b8d3a300e994","url":"#b-149545596200b8d3a300e994","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-149545596200b8d3a300e994","type":"p","scope":"block-3f2817fbef024a0f9bc945dd0b1a1b81","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-149545596200b8d3a300e994","content":"数据生成器保存真实图像与坐标；固定锚框是一组与图像真值无关的预测模板；最终预测框才来自网络。不要把这三者混为一谈。第一段还定义 IoU、按类别 NMS 与 AP。它们共用同一种半开区间 `xyxy` 几何，不使用整数像素的“面积加一”约定。","sha256":"39c691941ef6e08cdc882fb732b90d6f7d91fa1c76068b9dba317947729a7168","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","title":"读源码时跟踪三种集合","number":4},"sectionTitle":"读源码时跟踪三种集合","currentQuestion":"读源码时跟踪三种集合","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-3a16fda463a0c31b4464e16c","nextBlock":"b-ebc366c8aadcc5bfc625f76c","prerequisites":[{"id":"b-3a16fda463a0c31b4464e16c","url":"#b-3a16fda463a0c31b4464e16c","role":"section-title"}],"relatedBlocks":[]},{"id":"b-ebc366c8aadcc5bfc625f76c","type":"p","scope":"block-3f2817fbef024a0f9bc945dd0b1a1b81","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-ebc366c8aadcc5bfc625f76c","content":"AP 对每个类别汇总全数据集预测、按分数递减排列；每个预测找当前图像同类真值的最大 IoU，达到阈值且该真值没用过才记 TP，否则记 FP。重复检测不会增加召回。代码把 precision 从右向左取包络，再对 recall 增量求和。这是 all-points AP，不是 COCO 的多个 IoU 阈值平均；我们分别报告 AP50、AP75。","sha256":"86e85a001908dfa764ae7b719fbe872ac45b129a719084bd81161e73cbd67a12","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","title":"读源码时跟踪三种集合","number":4},"sectionTitle":"读源码时跟踪三种集合","currentQuestion":"读源码时跟踪三种集合","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-149545596200b8d3a300e994","nextBlock":"b-25acc25a4ff2be7c507c77a0","prerequisites":[{"id":"b-3a16fda463a0c31b4464e16c","url":"#b-3a16fda463a0c31b4464e16c","role":"section-title"},{"id":"b-149545596200b8d3a300e994","url":"#b-149545596200b8d3a300e994","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-25acc25a4ff2be7c507c77a0","type":"pre","scope":"block-b7b5c924dcd44b9e9286614edc3fa329","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-25acc25a4ff2be7c507c77a0","content":"```\n%%writefile lab10_detector.py\n\"\"\"LAB10: train and evaluate an image-to-box anchor detector, CPU, no downloads.\nRun: python lab10_detector.py --out lab10-results --epochs 28\nDependencies: torch numpy matplotlib. This script is self-contained.\n\"\"\"\n\"\"\"Shared transparent geometry and image construction for LAB10/11; no downloads.\"\"\"\nimport json, hashlib, platform, sys, time\nfrom pathlib import Path\nfrom datetime import datetime, timezone\nimport numpy as np\nimport torch\nfrom torch import nn\nfrom torch.nn import functional as F\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import Rectangle\n\ndef seed_all(seed=7):\n    np.random.seed(seed); torch.manual_seed(seed); torch.set_num_threads(2)\n\ndef iou_matrix(a,b):\n    if len(a)==0 or len(b)==0: return torch.zeros((len(a),len(b)))\n    lo=torch.maximum(a[:,None,:2],b[None,:,:2]); hi=torch.minimum(a[:,None,2:],b[None,:,2:])\n    inter=(hi-lo).clamp(min=0).prod(-1)\n    area_a=(a[:,2:]-a[:,:2]).clamp(min=0).prod(-1)\n    area_b=(b[:,2:]-b[:,:2]).clamp(min=0).prod(-1)\n    return inter/(area_a[:,None]+area_b[None,:]-inter).clamp(min=1e-8)\n\ndef make_scenes(n,seed,size=48,scale=1.0):\n    \"\"\"Independent seed defines original sample, scale changes only object size.\n    Boxes xyxy normalized; red rectangle=1, blue ellipse=2; zero to three objects.\n    Images are rasterized from latent scene, labels are never a network input.\n    \"\"\"\n    rng=np.random.default_rng(seed); xs=[]; ys=[]; masks=[]\n    yy,xx=np.mgrid[:size,:size]\n    for index in range(n):\n        image=rng.uniform(.035,.095,(3,size,size)).astype('float32')\n        num=int(rng.choice([0,1,2,3],p=[.18,.30,.36,.16]))\n        boxes=[]; labels=[]; mask=np.zeros((size,size),np.int64)\n        original=[]\n        for obj in range(num):\n            for attempt in range(60):\n                w,h=rng.integers(9,19,size=2); x=rng.integers(2,size-w-2); y=rng.integers(2,size-h-2)\n                box=np.array([x,y,x+w,y+h],np.float32)/size\n                if not original or iou_matrix(torch.tensor(np.array(original)),torch.tensor(box[None])).max()<.08: break\n            original.append(box); label=int(rng.integers(1,3)); color=rng.uniform(.7,.98)\n            cx,cy=(box[0]+box[2])/2,(box[1]+box[3])/2\n            sw,sh=(box[2]-box[0])*scale,(box[3]-box[1])*scale\n            x1,y1,x2,y2=np.round(np.array([cx-sw/2,cy-sh/2,cx+sw/2,cy+sh/2])*size).astype(int)\n            x2=max(x2,x1+2); y2=max(y2,y1+2)\n            region=(xx>=x1)&(xx<x2)&(yy>=y1)&(yy<y2)\n            if label==2: region &= ((xx+.5-(x1+x2)/2)/((x2-x1)/2))**2+((yy+.5-(y1+y2)/2)/((y2-y1)/2))**2<=1\n            image[:,region]*=.2\n            image[0 if label==1 else 2,region]=color\n            image[1,region]=.15+color*.12\n            mask[region]=label\n            boxes.append([x1/size,y1/size,x2/size,y2/size]); labels.append(label)\n        xs.append(image); masks.append(mask)\n        ys.append({'boxes':torch.tensor(boxes,dtype=torch.float32).reshape(-1,4),'labels':torch.tensor(labels,dtype=torch.long),'sample_id':f'{seed}:{index}'})\n    return torch.from_numpy(np.stack(xs)),ys,torch.from_numpy(np.stack(masks))\n\ndef nms(boxes,scores,threshold=.35):\n    order=torch.argsort(scores,descending=True,stable=True); keep=[]\n    while len(order):\n        i=order[0]; keep.append(i.item()); order=order[1:]\n        if len(order): order=order[iou_matrix(boxes[i:i+1],boxes[order])[0]<=threshold]\n    return torch.tensor(keep,dtype=torch.long)\n\ndef average_precision(predictions,targets,iou_threshold=.5,score_threshold=0):\n    \"\"\"Per-class global score order, max-IoU GT then unused check; all-points AP.\"\"\"\n    result={}; all_tp=all_fp=all_gt=0\n    for cls in [1,2]:\n        gt={i:t['boxes'][t['labels']==cls] for i,t in enumerate(targets)}\n        used={i:set() for i in gt}; total=sum(len(v) for v in gt.values())\n        rows=[]\n        for i,p in enumerate(predictions):\n            for j in range(len(p['scores'])):\n                if int(p['labels'][j])==cls and float(p['scores'][j])>=score_threshold:\n                    rows.append((float(p['scores'][j]),i,j,p['boxes'][j]))\n        rows.sort(key=lambda r:(-r[0],r[1],r[2])); tp=[]; fp=[]\n        for score,i,j,b in rows:\n            ok=False\n            if len(gt[i]):\n                overlaps=iou_matrix(b[None],gt[i])[0]; best=int(overlaps.argmax())\n                ok=float(overlaps[best])>=iou_threshold and best not in used[i]\n                if ok:used[i].add(best)\n            tp.append(int(ok));fp.append(int(not ok))\n        tp=np.cumsum(tp);fp=np.cumsum(fp)\n        recall=tp/max(total,1); precision=tp/np.maximum(tp+fp,1)\n        mr=np.r_[0,recall,1];mp=np.r_[0,precision,0]\n        mp=np.maximum.accumulate(mp[::-1])[::-1];loc=np.where(mr[1:]!=mr[:-1])[0]\n        ap=float(((mr[loc+1]-mr[loc])*mp[loc+1]).sum()) if total else None\n        result[str(cls)]={'AP':ap,'GT':total,'TP':int(tp[-1]) if len(tp) else 0,'FP':int(fp[-1]) if len(fp) else 0}\n        all_tp+=result[str(cls)]['TP'];all_fp+=result[str(cls)]['FP'];all_gt+=total\n    return {'per_class':result,'mAP':float(np.mean([r['AP'] for r in result.values() if r['AP'] is not None])),\n            'precision':all_tp/max(all_tp+all_fp,1),'recall':all_tp/max(all_gt,1),'iou_threshold':iou_threshold,'score_threshold':score_threshold}\n\ndef provenance(path,started):\n    p=Path(path)\n    return {'utc_started':started,'utc_completed':datetime.now(timezone.utc).isoformat(),'execution':'CPU, complete script',\n            'python':sys.version,'torch':torch.__version__,'numpy':np.__version__,'platform':platform.platform(),'threads':torch.get_num_threads(),\n            'code_sha256':hashlib.sha256(p.read_bytes()).hexdigest(),\n            'device':'CPU', 'source_file':p.name}\n\ndef save_json(path,data):Path(path).write_text(json.dumps(data,indent=2,ensure_ascii=False))\n\ndef segmentation_metrics(pred,target):\n    valid=target!=255; t=target[valid];p=pred[valid]\n    cm=torch.bincount(t*3+p,minlength=9).reshape(3,3).double()\n    intersection=cm.diag();union=cm.sum(0)+cm.sum(1)-intersection\n    iou=intersection/union.clamp(min=1)\n    return {'IoU_background':float(iou[0]),'IoU_red_rectangle':float(iou[1]),'IoU_blue_ellipse':float(iou[2]),\n            'mIoU_3_classes':float(iou[union>0].mean()),'pixel_accuracy':float(intersection.sum()/cm.sum()),\n            'valid_pixels':int(valid.sum()),'ignored_pixels':int((~valid).sum()),'confusion_matrix_true_rows':cm.int().tolist()}\n\nimport argparse\n\n\n```","sha256":"037694098c36fa9e1f66ed918865df1f003d2a1bc7c2e6e11e61f3d1326a9c8c","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-3f2817fbef024a0f9bc945dd0b1a1b81","title":"读源码时跟踪三种集合","number":4},"sectionTitle":"读源码时跟踪三种集合","currentQuestion":"读源码时跟踪三种集合","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-ebc366c8aadcc5bfc625f76c","nextBlock":null,"prerequisites":[{"id":"b-3a16fda463a0c31b4464e16c","url":"#b-3a16fda463a0c31b4464e16c","role":"section-title"},{"id":"b-149545596200b8d3a300e994","url":"#b-149545596200b8d3a300e994","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-64d672ffbb6f461303689105","type":"h2","scope":"block-487567d0bb1d40039f1f87805d46ee76","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-64d672ffbb6f461303689105","content":"## 固定锚框怎样变成待学习的偏移","sha256":"c18a731b0741ea5dc8455aa95ff4e3aa4cdbdd52147c2c754288882b966b2fff","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-487567d0bb1d40039f1f87805d46ee76","title":"固定锚框怎样变成待学习的偏移","number":5},"sectionTitle":"固定锚框怎样变成待学习的偏移","currentQuestion":"固定锚框怎样变成待学习的偏移","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-d198ca2dbb9558b2b7fa2d4f","prerequisites":[{"id":"b-d198ca2dbb9558b2b7fa2d4f","url":"#b-d198ca2dbb9558b2b7fa2d4f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-d198ca2dbb9558b2b7fa2d4f","type":"p","scope":"block-487567d0bb1d40039f1f87805d46ee76","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-d198ca2dbb9558b2b7fa2d4f","content":"骨干把 $48\\times48$ 图像映射为 $12\\times12$ 特征；每格两个正方形锚框，边长 .23、.37，总共 288 个。这是 TinySSD 核心流程的单特征层教学变体，保留多尺寸锚框，没有照搬 D2L 的多层特征金字塔。","sha256":"f75c5092579fa19dfcbe964303c4293706d70207d65ae39daa074b9f9a326009","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-487567d0bb1d40039f1f87805d46ee76","title":"固定锚框怎样变成待学习的偏移","number":5},"sectionTitle":"固定锚框怎样变成待学习的偏移","currentQuestion":"固定锚框怎样变成待学习的偏移","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"48\\times48","definitionContext":"固定锚框怎样变成待学习的偏移"},{"latex":"12\\times12","definitionContext":"固定锚框怎样变成待学习的偏移"}],"previousBlock":"b-64d672ffbb6f461303689105","nextBlock":"b-e6bf0ced565bd4aeaadf2e49","prerequisites":[{"id":"b-64d672ffbb6f461303689105","url":"#b-64d672ffbb6f461303689105","role":"section-title"}],"relatedBlocks":[]},{"id":"b-e6bf0ced565bd4aeaadf2e49","type":"p","scope":"block-487567d0bb1d40039f1f87805d46ee76","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-e6bf0ced565bd4aeaadf2e49","content":"一个锚框的中心为 $(a_x,a_y)$、宽高 $(a_w,a_h)$，目标框为 $(b_x,b_y,b_w,b_h)$。回归目标为 $((b_x-a_x)/a_w,(b_y-a_y)/a_h,\\log(b_w/a_w),\\log(b_h/a_h))$。解码使用逆变换，所以网络在每个位置学四个实数，而不是直接从真值读取位置。`decode(anchors,encode(anchors,boxes))` 的往返检验在有效框上通过。","sha256":"d38bb953c0f055c9c6edbfca55c4e07842898a4cd1866288229b4c401e4be5cf","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-487567d0bb1d40039f1f87805d46ee76","title":"固定锚框怎样变成待学习的偏移","number":5},"sectionTitle":"固定锚框怎样变成待学习的偏移","currentQuestion":"固定锚框怎样变成待学习的偏移","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"(a_x,a_y)","definitionContext":"固定锚框怎样变成待学习的偏移"},{"latex":"(a_w,a_h)","definitionContext":"固定锚框怎样变成待学习的偏移"},{"latex":"(b_x,b_y,b_w,b_h)","definitionContext":"固定锚框怎样变成待学习的偏移"},{"latex":"((b_x-a_x)/a_w,(b_y-a_y)/a_h,\\log(b_w/a_w),\\log(b_h/a_h))","definitionContext":"固定锚框怎样变成待学习的偏移"}],"previousBlock":"b-d198ca2dbb9558b2b7fa2d4f","nextBlock":null,"prerequisites":[{"id":"b-64d672ffbb6f461303689105","url":"#b-64d672ffbb6f461303689105","role":"section-title"},{"id":"b-d198ca2dbb9558b2b7fa2d4f","url":"#b-d198ca2dbb9558b2b7fa2d4f","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-50d13b3966a5b4e1031779ca","type":"h2","scope":"block-f702d0b00d7a4a37abd3a8da99a3cd39","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-50d13b3966a5b4e1031779ca","content":"## 哪些锚框受哪一种监督","sha256":"9f41499a557a00bd3d59d859558b46124bfb9b0c8f6789bae6ed79386186cc4f","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","title":"哪些锚框受哪一种监督","number":6},"sectionTitle":"哪些锚框受哪一种监督","currentQuestion":"哪些锚框受哪一种监督","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-3a0fa04f5a61c09c02f3d546","prerequisites":[{"id":"b-3a0fa04f5a61c09c02f3d546","url":"#b-3a0fa04f5a61c09c02f3d546","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-3a0fa04f5a61c09c02f3d546","type":"p","scope":"block-f702d0b00d7a4a37abd3a8da99a3cd39","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-3a0fa04f5a61c09c02f3d546","content":"IoU≥.45 的锚框为正例，IoU<.25 为背景，中间区间为 ignore=-1。另用逐次全局最大 IoU 给每个真值保留一个不同的锚框；它可能低于 .45，目的是避免一个真值完全没有回归监督。这个训练强制匹配不能用于评价“凑足召回”。空图的所有锚框都是真背景。","sha256":"1f2040210dfc2c038361512a9e60e5e39863816685141e2d9ed1276eb3d56efb","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","title":"哪些锚框受哪一种监督","number":6},"sectionTitle":"哪些锚框受哪一种监督","currentQuestion":"哪些锚框受哪一种监督","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-50d13b3966a5b4e1031779ca","nextBlock":"b-204466e62c807900ceeefcd4","prerequisites":[{"id":"b-50d13b3966a5b4e1031779ca","url":"#b-50d13b3966a5b4e1031779ca","role":"section-title"}],"relatedBlocks":[]},{"id":"b-204466e62c807900ceeefcd4","type":"p","scope":"block-f702d0b00d7a4a37abd3a8da99a3cd39","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-204466e62c807900ceeefcd4","content":"分类损失取所有正例和最难负例，负例最多为正例数的 3 倍，每图至少 12 个；ignore 不参加。位置损失仅在正例上计算 Smooth L1，均值包含四个坐标。总损失 $L=L_{cls}+3L_{box}$。因此空图仍有分类梯度，没有位置梯度；一个忽略锚框的分类梯度也应为零，已用针对性检查确认。","sha256":"ab0b0e22587166aea5a9af4d6a3c23f74f6234fa00473516ddd3c922014699eb","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","title":"哪些锚框受哪一种监督","number":6},"sectionTitle":"哪些锚框受哪一种监督","currentQuestion":"哪些锚框受哪一种监督","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"L=L_{cls}+3L_{box}","definitionContext":"哪些锚框受哪一种监督"}],"previousBlock":"b-3a0fa04f5a61c09c02f3d546","nextBlock":"b-1833ab9273023de52d5edf94","prerequisites":[{"id":"b-50d13b3966a5b4e1031779ca","url":"#b-50d13b3966a5b4e1031779ca","role":"section-title"},{"id":"b-3a0fa04f5a61c09c02f3d546","url":"#b-3a0fa04f5a61c09c02f3d546","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-1833ab9273023de52d5edf94","type":"pre","scope":"block-b6e5552805db40308895eb423c00fff1","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-1833ab9273023de52d5edf94","content":"```\n%%writefile -a lab10_detector.py\ndef anchors_grid(grid=12,sizes=(.23,.37)):\n    boxes=[]\n    for y in range(grid):\n        for x in range(grid):\n            for s in sizes:boxes.append([(x+.5)/grid-s/2,(y+.5)/grid-s/2,(x+.5)/grid+s/2,(y+.5)/grid+s/2])\n    return torch.tensor(boxes)\n\ndef encode(anchors,boxes):\n    ac=(anchors[:,:2]+anchors[:,2:])/2;aw=anchors[:,2:]-anchors[:,:2]\n    bc=(boxes[:,:2]+boxes[:,2:])/2;bw=boxes[:,2:]-boxes[:,:2]\n    return torch.cat([(bc-ac)/aw,torch.log((bw/aw).clamp(min=1e-6))],1)\n\ndef decode(anchors,offset):\n    ac=(anchors[:,:2]+anchors[:,2:])/2;aw=anchors[:,2:]-anchors[:,:2]\n    bc=ac+offset[:,:2]*aw;bw=aw*torch.exp(offset[:,2:].clamp(-3,3))\n    return torch.cat([bc-bw/2,bc+bw/2],1).clamp(0,1)\n\ndef match_targets(anchors,target):\n    \"\"\"-1 ignore, 0 background, 1/2 object. Each GT gets a distinct forced anchor.\"\"\"\n    classes=torch.zeros(len(anchors),dtype=torch.long);offsets=torch.zeros_like(anchors)\n    if not len(target['boxes']): return classes,offsets\n    overlap=iou_matrix(anchors,target['boxes']);best,best_gt=overlap.max(1)\n    classes[(best>=.25)&(best<.45)]=-1\n    positive=best>=.45\n    # Greedy global maximum, invalidate its anchor and GT; guarantees all GT assigned.\n    work=overlap.clone()\n    for _ in range(len(target['boxes'])):\n        flat=int(work.argmax()); a=flat//work.shape[1];g=flat%work.shape[1]\n        positive[a]=True;best_gt[a]=g;work[a,:]=-1;work[:,g]=-1\n    classes[positive]=target['labels'][best_gt[positive]]\n    offsets[positive]=encode(anchors[positive],target['boxes'][best_gt[positive]])\n    return classes,offsets\n\n\n```","sha256":"69910f0e843b76b0a9e207e1e13e524023bbfe037d0f6cd9c295e98abfdf64a5","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-f702d0b00d7a4a37abd3a8da99a3cd39","title":"哪些锚框受哪一种监督","number":6},"sectionTitle":"哪些锚框受哪一种监督","currentQuestion":"哪些锚框受哪一种监督","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-204466e62c807900ceeefcd4","nextBlock":null,"prerequisites":[{"id":"b-50d13b3966a5b4e1031779ca","url":"#b-50d13b3966a5b4e1031779ca","role":"section-title"},{"id":"b-3a0fa04f5a61c09c02f3d546","url":"#b-3a0fa04f5a61c09c02f3d546","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-f6386c0872a9d49b2a1ba361","type":"h2","scope":"block-950aab9e6fbf43b4aef8ee21b9268a87","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-f6386c0872a9d49b2a1ba361","content":"## 从共享特征到两个输出头","sha256":"ae6109b950401193f5256036ea197169997c9abf6e09018367d63b1b3b9697af","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","title":"从共享特征到两个输出头","number":7},"sectionTitle":"从共享特征到两个输出头","currentQuestion":"从共享特征到两个输出头","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-dfdbf00196f8fd6b2233593d","prerequisites":[{"id":"b-dfdbf00196f8fd6b2233593d","url":"#b-dfdbf00196f8fd6b2233593d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-dfdbf00196f8fd6b2233593d","type":"p","scope":"block-950aab9e6fbf43b4aef8ee21b9268a87","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-dfdbf00196f8fd6b2233593d","content":"四个卷积层形成 45,806 参数的模型。分类 logits 为 `[B,288,3]`，框偏移为 `[B,288,4]`。两个头共享空间特征，分类头的“有目标”分数和框头的“偏移多少”要同时学好；分类分数接近 1 并不保证坐标足够准确。","sha256":"6f1f64585357fa0d50beee983ee99c16e80bdf6eff58262950001f171ab07a13","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","title":"从共享特征到两个输出头","number":7},"sectionTitle":"从共享特征到两个输出头","currentQuestion":"从共享特征到两个输出头","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-f6386c0872a9d49b2a1ba361","nextBlock":"b-122d8f83b002180c3d90027f","prerequisites":[{"id":"b-f6386c0872a9d49b2a1ba361","url":"#b-f6386c0872a9d49b2a1ba361","role":"section-title"}],"relatedBlocks":[]},{"id":"b-122d8f83b002180c3d90027f","type":"p","scope":"block-950aab9e6fbf43b4aef8ee21b9268a87","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-122d8f83b002180c3d90027f","content":"推理只接收 RGB，解码所有候选，对每一前景类别分别做 NMS，默认抑制 IoU>.35 的低分框。保存候选的分数下限为 .01，绘图与 precision/recall 的工作点为 .4。候选阈值、NMS 的 IoU 阈值、评价的 IoU 阈值是三个不同控制量。","sha256":"a8de3244286e583a34410f672ae0a8773ec99c72b4b883c1f41fab942e792874","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","title":"从共享特征到两个输出头","number":7},"sectionTitle":"从共享特征到两个输出头","currentQuestion":"从共享特征到两个输出头","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-dfdbf00196f8fd6b2233593d","nextBlock":"b-919f32f56e02a0e99186a75c","prerequisites":[{"id":"b-f6386c0872a9d49b2a1ba361","url":"#b-f6386c0872a9d49b2a1ba361","role":"section-title"},{"id":"b-dfdbf00196f8fd6b2233593d","url":"#b-dfdbf00196f8fd6b2233593d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-919f32f56e02a0e99186a75c","type":"pre","scope":"block-30839f038a25415ea1d0eb6e8fc1d456","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-919f32f56e02a0e99186a75c","content":"```\n%%writefile -a lab10_detector.py\nclass TinyAnchorDetector(nn.Module):\n    def __init__(self):\n        super().__init__()\n        self.backbone=nn.Sequential(nn.Conv2d(3,16,3,2,1),nn.ReLU(),nn.Conv2d(16,32,3,2,1),nn.ReLU(),\n                                    nn.Conv2d(32,48,3,1,1),nn.ReLU(),nn.Conv2d(48,48,3,1,1),nn.ReLU())\n        self.class_head=nn.Conv2d(48,2*3,3,padding=1);self.box_head=nn.Conv2d(48,2*4,3,padding=1)\n    def forward(self,x):\n        z=self.backbone(x);b=x.shape[0]\n        return self.class_head(z).permute(0,2,3,1).reshape(b,-1,3),self.box_head(z).permute(0,2,3,1).reshape(b,-1,4)\n\ndef detection_loss(logits,offsets,classes,targets):\n    ce=F.cross_entropy(logits.transpose(1,2),classes,ignore_index=-1,reduction='none')\n    positive=classes>0;chosen=positive.clone()\n    for i in range(len(classes)):\n        negatives=torch.where(classes[i]==0)[0]; k=min(len(negatives),max(12,3*int(positive[i].sum())))\n        chosen[i,negatives[torch.argsort(ce[i,negatives],descending=True)[:k]]]=True\n    cls=ce[chosen].mean()\n    loc=F.smooth_l1_loss(offsets[positive],targets[positive],reduction='mean') if positive.any() else offsets.sum()*0\n    return cls+3*loc,cls,loc\n\n@torch.no_grad()\ndef predict(model,images,anchors,score=.01,nms_iou=.35):\n    model.eval();result=[]\n    for batch in images.split(32):\n        logits,offsets=model(batch); probs=logits.softmax(-1)\n        for p,o in zip(probs,offsets):\n            boxes=decode(anchors,o); all_b=[];all_s=[];all_l=[]\n            for cls in [1,2]:\n                indices=torch.where(p[:,cls]>=score)[0]\n                keep=nms(boxes[indices],p[indices,cls],nms_iou);indices=indices[keep]\n                all_b.append(boxes[indices]);all_s.append(p[indices,cls]);all_l.append(torch.full((len(indices),),cls))\n            result.append({'boxes':torch.cat(all_b),'scores':torch.cat(all_s),'labels':torch.cat(all_l)})\n    return result\n\n\n```","sha256":"d248fdb1d8ed367c289941e0f3eb2ce08c9c0e843c28541e882f8d24050567f2","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","title":"从共享特征到两个输出头","number":7},"sectionTitle":"从共享特征到两个输出头","currentQuestion":"从共享特征到两个输出头","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-122d8f83b002180c3d90027f","nextBlock":"b-7ceb124d66e5083c7be21b4d","prerequisites":[{"id":"b-f6386c0872a9d49b2a1ba361","url":"#b-f6386c0872a9d49b2a1ba361","role":"section-title"},{"id":"b-dfdbf00196f8fd6b2233593d","url":"#b-dfdbf00196f8fd6b2233593d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7ceb124d66e5083c7be21b4d","type":"pre","scope":"block-143820f109ad427a91de6c9db85091b7","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-7ceb124d66e5083c7be21b4d","content":"```\n%%writefile -a lab10_detector.py\ndef report_predictions(pred,targets):\n    empties=[i for i,t in enumerate(targets) if not len(t['boxes'])]\n    multi=[i for i,t in enumerate(targets) if len(t['boxes'])>=2]\n    return {'AP50':average_precision(pred,targets,.5),'AP75':average_precision(pred,targets,.75),\n            'operating_point':average_precision(pred,targets,.5,.4),\n            'empty_images':len(empties),'empty_false_positive_images_score04':sum(int((pred[i]['scores']>=.4).any()) for i in empties),\n            'multi_object_images':len(multi),'multi_object_AP50':average_precision([pred[i] for i in multi],[targets[i] for i in multi],.5)}\n\ndef draw_predictions(images,targets,predictions,path,title,indices=None):\n    if indices is None:indices=[0,1,2,3,4,5]\n    fig,axes=plt.subplots(2,3,figsize=(11,7))\n    for ax,i in zip(axes.flat,indices):\n        ax.imshow(images[i].permute(1,2,0));ax.axis('off')\n        for b,c in zip(targets[i]['boxes'],targets[i]['labels']):\n            x,y,x2,y2=b.numpy()*48;ax.add_patch(Rectangle((x,y),x2-x,y2-y,fill=False,color='lime',lw=1.8))\n        count=0\n        for b,s,c in zip(predictions[i]['boxes'],predictions[i]['scores'],predictions[i]['labels']):\n            if s<.4:continue\n            x,y,x2,y2=b.numpy()*48;ax.add_patch(Rectangle((x,y),x2-x,y2-y,fill=False,color='yellow',ls='--',lw=1.1))\n            ax.text(x,y,f'{int(c)}:{s:.2f}',color='yellow',fontsize=7);count+=1\n        ax.set_title(f\"sample {i}: GT={len(targets[i]['boxes'])}, pred={count}\")\n    fig.suptitle(title+' | green=GT; yellow=prediction score>=0.4');fig.tight_layout();fig.savefig(path,dpi=150);plt.close(fig)\n\ndef run(out='lab10-results',epochs=28):\n    started=datetime.now(timezone.utc).isoformat();start=time.time();out=Path(out);out.mkdir(parents=True,exist_ok=True);seed_all(7)\n    train,ttrain,_=make_scenes(768,1101); val,tval,_=make_scenes(96,3101);test,ttest,_=make_scenes(192,5901)\n    small,tsmall,_=make_scenes(192,5901,scale=.5);anchors=anchors_grid()\n    matched=[match_targets(anchors,t) for t in ttrain];classes=torch.stack([m[0] for m in matched]);targets=torch.stack([m[1] for m in matched])\n    model=TinyAnchorDetector();random_pred=predict(model,test,anchors,score=.01)\n    baseline=report_predictions(random_pred,ttest);opt=torch.optim.Adam(model.parameters(),lr=.002);history=[]\n    for epoch in range(epochs):\n        model.train(); losses=[]; order=torch.randperm(len(train))\n        for ids in order.split(32):\n            logits,offset=model(train[ids]);loss,cls,loc=detection_loss(logits,offset,classes[ids],targets[ids])\n            opt.zero_grad();loss.backward();opt.step();losses.append([float(loss.detach()),float(cls.detach()),float(loc.detach())])\n        item={'epoch':epoch+1,'loss':float(np.mean(losses,axis=0)[0]),'classification_loss':float(np.mean(losses,axis=0)[1]),'box_loss':float(np.mean(losses,axis=0)[2])};history.append(item)\n        if (epoch+1)%7==0 or epoch==0:print(item,flush=True)\n    pred=predict(model,test,anchors);small_pred=predict(model,small,anchors);val_pred=predict(model,val,anchors)\n    loose_pred=predict(model,test,anchors,nms_iou=.65)\n    results={'provenance':provenance(__file__,started),'config':{'seed':7,'train_count':768,'validation_count':96,'heldout_count':192,\n             'split_seeds':[1101,3101,5901],'image_shape':[3,48,48],'num_anchors':len(anchors),'epochs':epochs,'batch_size':32,\n             'optimizer':'Adam lr=.002','matching':'positive IoU>=.45 plus distinct forced GT anchors; ignore [.25,.45); background<.25',\n             'loss':'hard-negative CE (3:1,min12) + 3*positive smoothL1','box_parameterization':'dx/dw,dy/dh,log width ratio,log height ratio',\n             'AP':'per-class global score sort; maximum-IoU GT, one match per GT; precision-envelope all-points integral',\n             'AP_candidate_score_floor':.01,'random_baseline_candidate_score_floor':.01,'NMS_IoU':.35,'display_score':.4,\n             'model_parameters':sum(p.numel() for p in model.parameters()),'data_identity':'generated images; color/shape correlated; distinct original sample seed splits; no external data'},\n             'target_counts':{'positive':int((classes>0).sum()),'ignore':int((classes==-1).sum()),'background':int((classes==0).sum())},\n             'random_initialization':baseline,'validation':report_predictions(val_pred,tval),'heldout':report_predictions(pred,ttest),\n             'condition_half_object_scale':report_predictions(small_pred,tsmall),'condition_NMS_065':report_predictions(loose_pred,ttest),\n             'training_history':history,'seconds':time.time()-start}\n    # Select actual worst examples by mean best GT overlap, plus an empty image.\n    failures=[]\n    for i,t in enumerate(ttest):\n        p=pred[i];b=p['boxes'][p['scores']>=.4]\n        quality=float(iou_matrix(t['boxes'],b).max(1).values.mean()) if len(t['boxes']) and len(b) else 0\n        if len(t['boxes']):failures.append((quality,i))\n    failures.sort();indices=[i for _,i in failures[:5]]+[next(i for i,t in enumerate(ttest) if not len(t['boxes']))]\n    results['failure_examples']=[{'sample_index':i,'mean_best_box_IoU_unconditioned_on_class':q} for q,i in failures[:5]]\n    torch.save({'state_dict':model.state_dict(),'anchors':anchors,'config':results['config']},out/'detector.pt')\n    np.savez_compressed(out/'heldout-inputs-and-targets.npz',images=test.numpy(),half_scale_images=small.numpy(),\n                        target_boxes=np.array([t['boxes'].numpy() for t in ttest],dtype=object),target_labels=np.array([t['labels'].numpy() for t in ttest],dtype=object))\n    serialize=lambda ps:[{k:v.tolist() for k,v in p.items()} for p in ps]\n    save_json(out/'predictions.json',{'heldout':serialize(pred),'half_scale':serialize(small_pred),'targets':serialize([{k:v for k,v in t.items() if k!='sample_id'} for t in ttest]),'half_scale_targets':serialize([{k:v for k,v in t.items() if k!='sample_id'} for t in tsmall])})\n    draw_predictions(test,ttest,pred,out/'heldout-predictions.png','Heldout image-to-box predictions')\n    draw_predictions(test,ttest,pred,out/'failure-predictions.png','Lowest geometric overlap examples',indices)\n    draw_predictions(small,tsmall,small_pred,out/'half-scale-predictions.png','Same original scenes, object size x0.5')\n    fig,ax=plt.subplots(figsize=(7,4));ax.plot([h['loss'] for h in history],label='total');ax.plot([h['classification_loss'] for h in history],label='classification');ax.plot([3*h['box_loss'] for h in history],label='3 x box');ax.set(xlabel='epoch (zero based)',ylabel='training loss');ax.legend();fig.tight_layout();fig.savefig(out/'training-curve.png',dpi=150);plt.close(fig)\n    save_json(out/'run.json',results)\n    print(json.dumps({'heldout_mAP50':results['heldout']['AP50']['mAP'],'half_scale_mAP50':results['condition_half_object_scale']['AP50']['mAP'],'seconds':results['seconds']},indent=2),flush=True)\n    return results\n\nif __name__=='__main__':\n    p=argparse.ArgumentParser();p.add_argument('--out',default='lab10-results');p.add_argument('--epochs',type=int,default=28);args=p.parse_args();run(args.out,args.epochs)\n\n```","sha256":"13aa6f19d1012ce26455856541869391d75585395369a37bff83c083c0b497a7","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-950aab9e6fbf43b4aef8ee21b9268a87","title":"从共享特征到两个输出头","number":7},"sectionTitle":"从共享特征到两个输出头","currentQuestion":"从共享特征到两个输出头","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-919f32f56e02a0e99186a75c","nextBlock":null,"prerequisites":[{"id":"b-f6386c0872a9d49b2a1ba361","url":"#b-f6386c0872a9d49b2a1ba361","role":"section-title"},{"id":"b-dfdbf00196f8fd6b2233593d","url":"#b-dfdbf00196f8fd6b2233593d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-5dd10f5947cda70b27154fc3","type":"h2","scope":"block-8bcdc8923f8c411583dec053e8e89211","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-5dd10f5947cda70b27154fc3","content":"## 实际训练与可复查的输出","sha256":"04208d85b0663ccd5bb1af1e3d9db049d444d21356b79b70f11bbb00375d24f5","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-8bcdc8923f8c411583dec053e8e89211","title":"实际训练与可复查的输出","number":8},"sectionTitle":"实际训练与可复查的输出","currentQuestion":"实际训练与可复查的输出","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-e7f7708a5145fe4a757de526","prerequisites":[{"id":"b-e7f7708a5145fe4a757de526","url":"#b-e7f7708a5145fe4a757de526","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-e7f7708a5145fe4a757de526","type":"p","scope":"block-8bcdc8923f8c411583dec053e8e89211","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-e7f7708a5145fe4a757de526","content":"下面在子进程运行完整脚本，既有随机初始化基准，也有训练后保留集、同图尺寸变化、同权重 NMS 阈值变化。脚本保存训练轨迹、权重 `detector.pt`、图像与目标 NPZ、逐预测 JSON、run.json 和四张图。图中绿实线是真值，黄虚线是 score≥.4 的预测；没有黄框的空图也是合法输出。","sha256":"85752b6cc66a89e4b4b497d2fbbd60f747c5b25bf0e4c8b2176754d62f1ea4e3","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-8bcdc8923f8c411583dec053e8e89211","title":"实际训练与可复查的输出","number":8},"sectionTitle":"实际训练与可复查的输出","currentQuestion":"实际训练与可复查的输出","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-5dd10f5947cda70b27154fc3","nextBlock":"b-ea67066fd1b8dfc2bcc0a5e5","prerequisites":[{"id":"b-5dd10f5947cda70b27154fc3","url":"#b-5dd10f5947cda70b27154fc3","role":"section-title"}],"relatedBlocks":[]},{"id":"b-ea67066fd1b8dfc2bcc0a5e5","type":"pre","scope":"block-e4979dd3569c4ce4855112dd4b062c23","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-ea67066fd1b8dfc2bcc0a5e5","content":"```\nimport subprocess,sys,json\nsubprocess.run([sys.executable,'lab10_detector.py','--out','lab10-results-rerun','--epochs','28'],check=True)\nR=json.loads(Path('lab10-results-rerun/run.json').read_text())\nfor setting in ['random_initialization','validation','heldout','condition_half_object_scale','condition_NMS_065']:\n    r=R[setting]\n    print(setting, 'mAP50=',round(r['AP50']['mAP'],4),'mAP75=',round(r['AP75']['mAP'],4),\n          'P@.4=',round(r['operating_point']['precision'],4),'R@.4=',round(r['operating_point']['recall'],4))\nprint(R['provenance'])\nfrom IPython.display import Image,display\nfor filename in ['heldout-predictions.png','failure-predictions.png','half-scale-predictions.png','training-curve.png']:\n    display(Image(filename='lab10-results-rerun/'+filename))\n```","sha256":"0a748c53d9a4c3bfaa27b3278192fb7b8f6dd8e500e31fe3d83843c1683cb0d6","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-8bcdc8923f8c411583dec053e8e89211","title":"实际训练与可复查的输出","number":8},"sectionTitle":"实际训练与可复查的输出","currentQuestion":"实际训练与可复查的输出","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-e7f7708a5145fe4a757de526","nextBlock":null,"prerequisites":[{"id":"b-5dd10f5947cda70b27154fc3","url":"#b-5dd10f5947cda70b27154fc3","role":"section-title"},{"id":"b-e7f7708a5145fe4a757de526","url":"#b-e7f7708a5145fe4a757de526","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-37dea60746827d41dd31618d","type":"h2","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-37dea60746827d41dd31618d","content":"## 已完成基准：分数高，哪里仍会错","sha256":"001a78ee1c513c635eb2d2b2e751bba8e86aa82d93f8ce78390f8a8f6a0bd517","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-96b9fe73e6a67ce3404848b0","prerequisites":[{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-96b9fe73e6a67ce3404848b0","type":"p","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-96b9fe73e6a67ce3404848b0","content":"本地 CPU 完整运行开始于 `2026-09-22T16:28:18.578466+00:00`，PyTorch `2.14.0+cpu`；源码 SHA-256 为 `6fe8ef2b4e80cc880f8df1f17333506aede144441d41672a6329b4bebe514f5e`。28 epoch 训练总损失从 .80512 降到 .00589；以下是该脚本的保留集结果，而非训练准确率。","sha256":"d84d8dad59a6ffb108aeae91a8cb273eda4ff3f48305a027cdd932f6d8e5e8a0","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-37dea60746827d41dd31618d","nextBlock":"b-2fd076e60bdf43f5335f9659","prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"}],"relatedBlocks":[]},{"id":"b-2fd076e60bdf43f5335f9659","type":"table","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-2fd076e60bdf43f5335f9659","content":"| 条件 | mAP50 | mAP75 | precision@score .4 | recall@score .4 |\n| --- | --- | --- | --- | --- |\n| 随机初始化 | .00746 | .00003 | .0000 | .0000 |\n| 训练后，默认 NMS .35 | .97303 | .70367 | .9417 | .9831 |\n| 同场景对象尺寸 ×.5 | .61490 | .17987 | .9548 | .5000 |\n| 同权重，NMS 改为 .65 | .95866 | .72143 | .4193 | 1.0000 |","sha256":"73e6ee4f5bc1ec01e514c198ef41c666c445db1abd171363f941bba419e6f8f9","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"table":{"headers":["条件","mAP50","mAP75","precision@score .4","recall@score .4"],"rows":[["条件","mAP50","mAP75","precision@score .4","recall@score .4"],["随机初始化",".00746",".00003",".0000",".0000"],["训练后，默认 NMS .35",".97303",".70367",".9417",".9831"],["同场景对象尺寸 ×.5",".61490",".17987",".9548",".5000"],["同权重，NMS 改为 .65",".95866",".72143",".4193","1.0000"]]},"previousBlock":"b-96b9fe73e6a67ce3404848b0","nextBlock":"b-2511c1834157f5eacc5de88e","prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"},{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-2511c1834157f5eacc5de88e","type":"p","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-2511c1834157f5eacc5de88e","content":"AP50 和 AP75 差约 .269，说明“找到附近的同类物体”和“框很精确”不是同一个成功标准。随机模型在 .4 工作点没有输出；它的低阈值候选偶然覆盖一些物体，所以低工作点的召回不代表已经学会检测。训练模型对 33 张空图在 .4 工作点均未报目标，这是本次合成背景范围内的观察。","sha256":"c6ec3f412fe5cfe2ca58ee848a30beb02149b91ff80161b42c3aac7fe2b1c45b","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-2fd076e60bdf43f5335f9659","nextBlock":"b-20999241cdd7e8a6c620bd8e","prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"},{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-20999241cdd7e8a6c620bd8e","type":"p","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-20999241cdd7e8a6c620bd8e","content":"![保留集预测](/assets/display/5e8c375a18c66134b952b7af.webp)","sha256":"fd311f09d4288da59a18a7ca0f10ad5b5822379eabf7929f5465b7c8885e410f","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-2511c1834157f5eacc5de88e","nextBlock":"b-3496e93ea54df832853c9c09","prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"},{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-3496e93ea54df832853c9c09","type":"p","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-3496e93ea54df832853c9c09","content":"最差几何重合示例 35、15、51、24、118 按“每个真值与预测框的最大 IoU 再平均”选出，这个选图指标不考虑类别，不能替代正式 AP。35 号图的两个红矩形相邻，部分预测框覆盖了两者之间的区域；类别正确、数量看似正确，面积仍分配错。15 号图中高分蓝框偏向红物体的区域，说明 confidence 不是定位保证。空图 12 作为参照保留。","sha256":"026daa95e6894c51ebc29e21ccfa1bfaa2e2c46e9a58534d02d68b5106c9b5db","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-20999241cdd7e8a6c620bd8e","nextBlock":"b-b77843d07316617767ab3893","prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"},{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-b77843d07316617767ab3893","type":"p","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-b77843d07316617767ab3893","content":"![真实失败图](/assets/display/88df211a98edfb7b00515441.webp)","sha256":"de16d3aedb230c3d5dc38cc55d3da0065a5171215ac4a0d2e3bc2ce15c7a1484","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-3496e93ea54df832853c9c09","nextBlock":"b-c65415596544842eed4c7e67","prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"},{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-c65415596544842eed4c7e67","type":"p","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-c65415596544842eed4c7e67","content":"缩小对象后，固定 .4 工作点的 precision 仍高而 recall 只有 .5：模型主要漏掉小物体，不能只报 precision 宣称鲁棒。放宽 NMS 到 .65 的意义也不同：同一批 logits 没变，但更多少删的重复框被留下；TP 增至全部 296，FP 从 18 增至 410，precision 因而显著下降。AP50 略降而 AP75 略升并不矛盾：更宽松的候选集合也可能保留一个定位更准但分数稍低的框。","sha256":"4fcb7db780784522fef94931035d003fe88b2ff55e490138423218f2ff38afd9","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b77843d07316617767ab3893","nextBlock":"b-6b0d79b113d53d1a3d311166","prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"},{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-6b0d79b113d53d1a3d311166","type":"p","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-6b0d79b113d53d1a3d311166","content":"![相同场景缩小对象](/assets/display/735d18643da4042bf639ef2c.webp)","sha256":"82f4a4726293f261553d8268be54092dc78ef60a488504fef74f563c52a2cab9","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-c65415596544842eed4c7e67","nextBlock":"b-d69ce0fa30cdeff08dc75683","prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"},{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-d69ce0fa30cdeff08dc75683","type":"p","scope":"block-21be8b44d55348839633cb13b2e148a4","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-d69ce0fa30cdeff08dc75683","content":"下一步只改锚框最小尺寸或增加更细特征层，先写下预期会改善哪一种漏检，再重新训练并保留旧 run；不要同时改尺度、学习率、阈值后把变化都归因于锚框。若把图中的颜色交换而语义标签仍按形状给，当前训练协议并没有支持这类泛化结论。","sha256":"39f9891a8dd80a1c407f6f8ccac4397cb71a5bba5898a0e55f464f839f497514","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-21be8b44d55348839633cb13b2e148a4","title":"已完成基准：分数高，哪里仍会错","number":9},"sectionTitle":"已完成基准：分数高，哪里仍会错","currentQuestion":"已完成基准：分数高，哪里仍会错","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6b0d79b113d53d1a3d311166","nextBlock":null,"prerequisites":[{"id":"b-37dea60746827d41dd31618d","url":"#b-37dea60746827d41dd31618d","role":"section-title"},{"id":"b-96b9fe73e6a67ce3404848b0","url":"#b-96b9fe73e6a67ce3404848b0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-a0b62572aa03469c1da2bee6","type":"h2","scope":"block-3dc8766f20144da28bbef37cade18a3d","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-a0b62572aa03469c1da2bee6","content":"## 来源与下一条问题","sha256":"26a7cbe49a363a14a248834129e6d61a20d9aa9861079f66efe0ecca0a3f9a6b","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-3dc8766f20144da28bbef37cade18a3d","title":"来源与下一条问题","number":10},"sectionTitle":"来源与下一条问题","currentQuestion":"来源与下一条问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-0cede9806461b9b533a0fcd9","prerequisites":[{"id":"b-0cede9806461b9b533a0fcd9","url":"#b-0cede9806461b9b533a0fcd9","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-0cede9806461b9b533a0fcd9","type":"p","scope":"block-3dc8766f20144da28bbef37cade18a3d","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-0cede9806461b9b533a0fcd9","content":"2026-09-22 实时核对 D2L 1.0.3：[Anchor Boxes §14.4.3–14.4.4](https://d2l.ai/chapter_computer-vision/anchor.html#labeling-anchor-boxes-in-training-data) 用于锚框分配、偏移与 NMS；[SSD §14.7.1–14.7.3](https://d2l.ai/chapter_computer-vision/ssd.html)用于共享骨干、分类/回归头与完整训练路径。这里独立实现单特征层、小合成场景、ignore 区间、hard-negative CE、Smooth L1 与全数据 AP；没有把 D2L 的香蕉数据或论文成绩说成本次结果。","sha256":"80d65a4fb686786c0f111c5580f2a1dc3c9a542aed8d416cdf9ab7f723b2f3eb","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-3dc8766f20144da28bbef37cade18a3d","title":"来源与下一条问题","number":10},"sectionTitle":"来源与下一条问题","currentQuestion":"来源与下一条问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-a0b62572aa03469c1da2bee6","nextBlock":"b-cf5c04a01802990808019e18","prerequisites":[{"id":"b-a0b62572aa03469c1da2bee6","url":"#b-a0b62572aa03469c1da2bee6","role":"section-title"}],"relatedBlocks":[]},{"id":"b-cf5c04a01802990808019e18","type":"p","scope":"block-3dc8766f20144da28bbef37cade18a3d","url":"https://codingai-lec03.pages.dev/course/lab10-一个完整的小型检测器.html#b-cf5c04a01802990808019e18","content":"分类给出“是什么”，检测再加“各在何处”。即使框完全正确，矩形框内仍包含椭圆四角的背景；LAB11 接着将每个像素列为分类位置，检查边界、细小对象和采样损失。","sha256":"54419b0c3585352e9f49dbf54b576784a7f8a9b5d3df629a511b72a9ef3055ec","chapter":{"id":"course","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"unit":{"id":"lab10-一个完整的小型检测器","title":"LAB 10 · 从 RGB 图像训练小型检测器"},"page":{"id":"reading-block-3dc8766f20144da28bbef37cade18a3d","title":"来源与下一条问题","number":10},"sectionTitle":"来源与下一条问题","currentQuestion":"来源与下一条问题","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-0cede9806461b9b533a0fcd9","nextBlock":null,"prerequisites":[{"id":"b-a0b62572aa03469c1da2bee6","url":"#b-a0b62572aa03469c1da2bee6","role":"section-title"},{"id":"b-0cede9806461b9b533a0fcd9","url":"#b-0cede9806461b9b533a0fcd9","role":"problem-context"}],"relatedBlocks":[]}]}
