{"version":2,"relationshipURLBase":"https://codingai-lec03.pages.dev/course/notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d.html","relationshipResolution":"Resolve relative relationship URLs against relationshipURLBase; complete records and absolute URLs are in blocks.","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d.html","markdown":"https://codingai-lec03.pages.dev/course/notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d.md","pages":[{"id":"reading-opening","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码","unit":"同一组对象换了排列，损失不该凭空变大 · 实现代码","unitId":"notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d","chapter":"course","number":1}],"aliases":[{"oldId":"b-77edb5f134185f3e400fec29","targetId":"b-77edb5f134185f3e400fec29","page":"reading-opening","operation":"move","beforeSHA256":"962425885e26bc1e84f9788b6bdc0dd3408627135c1a8e3676b481715723b29f","afterSHA256":"962425885e26bc1e84f9788b6bdc0dd3408627135c1a8e3676b481715723b29f","reason":"Same source body in authored semantic page"},{"oldId":"b-75b1bc42003db96db6306876","targetId":"b-75b1bc42003db96db6306876","page":"reading-opening","operation":"move","beforeSHA256":"e0179c88d699378783b7da731264a7eb1f88d2094aa11c669ff2e582ed41f612","afterSHA256":"e0179c88d699378783b7da731264a7eb1f88d2094aa11c669ff2e582ed41f612","reason":"Same source body in authored semantic page"},{"oldId":"b-c45c7135824f9a98f5c303de","targetId":"b-c45c7135824f9a98f5c303de","page":"reading-opening","operation":"move","beforeSHA256":"e91f24e4e4ca40e2099a0d81d30db6568f4bf2074b499eeee6e3959617bd97ac","afterSHA256":"e91f24e4e4ca40e2099a0d81d30db6568f4bf2074b499eeee6e3959617bd97ac","reason":"Same source body in authored semantic page"},{"oldId":"b-4ab187a8df8c1db2c18897f4","targetId":"b-4ab187a8df8c1db2c18897f4","page":"reading-opening","operation":"move","beforeSHA256":"1d7535d0c02cc7bae4e9740472c8fa2e46f9a3b9067705762875bccfe9114541","afterSHA256":"1d7535d0c02cc7bae4e9740472c8fa2e46f9a3b9067705762875bccfe9114541","reason":"Same source body in authored semantic page"},{"oldId":"b-6da2a7f25ec0764d191120da","targetId":"b-6da2a7f25ec0764d191120da","page":"reading-opening","operation":"move","beforeSHA256":"5714c01e6f12168c1ae96d2c020af303805871c916cd8e924051dbea3aa808d3","afterSHA256":"5714c01e6f12168c1ae96d2c020af303805871c916cd8e924051dbea3aa808d3","reason":"Same source body in authored semantic page"}],"blocks":[{"id":"b-77edb5f134185f3e400fec29","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d.html#b-77edb5f134185f3e400fec29","content":"[LAB 20 · 尺度跨度与两对象匹配](/course/notebooks/9315996660f54e92847770355b648f9e.html)","sha256":"962425885e26bc1e84f9788b6bdc0dd3408627135c1a8e3676b481715723b29f","chapter":{"id":"course","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"unit":{"id":"notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"page":{"id":"reading-opening","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码","number":1},"sectionTitle":"同一组对象换了排列，损失不该凭空变大 · 实现代码","currentQuestion":"同一组对象换了排列，损失不该凭空变大 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-75b1bc42003db96db6306876","prerequisites":[],"relatedBlocks":[]},{"id":"b-75b1bc42003db96db6306876","type":"h1","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d.html#b-75b1bc42003db96db6306876","content":"# 同一组对象换了排列，损失不该凭空变大 · 实现代码","sha256":"e0179c88d699378783b7da731264a7eb1f88d2094aa11c669ff2e582ed41f612","chapter":{"id":"course","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"unit":{"id":"notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"page":{"id":"reading-opening","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码","number":1},"sectionTitle":"同一组对象换了排列，损失不该凭空变大 · 实现代码","currentQuestion":"同一组对象换了排列，损失不该凭空变大 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-77edb5f134185f3e400fec29","nextBlock":"b-c45c7135824f9a98f5c303de","prerequisites":[{"id":"b-77edb5f134185f3e400fec29","url":"#b-77edb5f134185f3e400fec29","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-c45c7135824f9a98f5c303de","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d.html#b-c45c7135824f9a98f5c303de","content":"按问题继续","sha256":"e91f24e4e4ca40e2099a0d81d30db6568f4bf2074b499eeee6e3959617bd97ac","chapter":{"id":"course","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"unit":{"id":"notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"page":{"id":"reading-opening","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码","number":1},"sectionTitle":"同一组对象换了排列，损失不该凭空变大 · 实现代码","currentQuestion":"同一组对象换了排列，损失不该凭空变大 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-75b1bc42003db96db6306876","nextBlock":"b-4ab187a8df8c1db2c18897f4","prerequisites":[{"id":"b-75b1bc42003db96db6306876","url":"#b-75b1bc42003db96db6306876","role":"section-title"},{"id":"b-77edb5f134185f3e400fec29","url":"#b-77edb5f134185f3e400fec29","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-4ab187a8df8c1db2c18897f4","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d.html#b-4ab187a8df8c1db2c18897f4","content":"步幅占格、两对象排列、分类/位置/IoU联合匹配代价","sha256":"1d7535d0c02cc7bae4e9740472c8fa2e46f9a3b9067705762875bccfe9114541","chapter":{"id":"course","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"unit":{"id":"notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"page":{"id":"reading-opening","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码","number":1},"sectionTitle":"同一组对象换了排列，损失不该凭空变大 · 实现代码","currentQuestion":"同一组对象换了排列，损失不该凭空变大 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-c45c7135824f9a98f5c303de","nextBlock":"b-6da2a7f25ec0764d191120da","prerequisites":[{"id":"b-75b1bc42003db96db6306876","url":"#b-75b1bc42003db96db6306876","role":"section-title"},{"id":"b-77edb5f134185f3e400fec29","url":"#b-77edb5f134185f3e400fec29","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-6da2a7f25ec0764d191120da","type":"pre","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d.html#b-6da2a7f25ec0764d191120da","content":"```\n# Writable ephemeral workspace for detached readonly cloud runs.\nimport os, tempfile\nos.chdir(tempfile.mkdtemp(prefix='lec03_lab23_'))\n\nimport numpy as np\nfrom itertools import permutations\nboxes=np.array([[.61,.12,.91,.43],[.08,.10,.32,.40]])\ntruth=np.array([[.10,.10,.35,.42],[.60,.10,.90,.45]])\nprob=np.array([[.15,.85],[.9,.1]]); labels=np.array([0,1])\ndef iou(a,b):\n    wh=np.maximum(0,np.minimum(a[2:],b[2:])-np.maximum(a[:2],b[:2])); inter=wh.prod()\n    return inter/(np.prod(a[2:]-a[:2])+np.prod(b[2:]-b[:2])-inter)\nC=np.array([[-np.log(prob[i,labels[j]])+2*abs(boxes[i]-truth[j]).sum()+1-iou(boxes[i],truth[j]) for j in range(2)] for i in range(2)])\ncosts={str(p):sum(C[i,j] for i,j in enumerate(p)) for p in permutations(range(2))}\nprint('cost matrix',C.round(4).tolist(),'assignment costs',costs,'selected',min(costs,key=costs.get))\nassert min(costs,key=costs.get)=='(1, 0)'\nfor stride in [4,8,16,32]: print('stride',stride,'target span',16/stride,'cells')\nprint('with 3 predictions/2 targets, unmatched slot needs no-object classification, not an invented third target')\n```","sha256":"5714c01e6f12168c1ae96d2c020af303805871c916cd8e924051dbea3aa808d3","chapter":{"id":"course","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"unit":{"id":"notebook-blocks/0f45eba379c5437685bb52cf7ae38a2d","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码"},"page":{"id":"reading-opening","title":"同一组对象换了排列，损失不该凭空变大 · 实现代码","number":1},"sectionTitle":"同一组对象换了排列，损失不该凭空变大 · 实现代码","currentQuestion":"同一组对象换了排列，损失不该凭空变大 · 实现代码","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-4ab187a8df8c1db2c18897f4","nextBlock":null,"prerequisites":[{"id":"b-75b1bc42003db96db6306876","url":"#b-75b1bc42003db96db6306876","role":"section-title"},{"id":"b-77edb5f134185f3e400fec29","url":"#b-77edb5f134185f3e400fec29","role":"problem-context"}],"relatedBlocks":[]}]}
