Lecture 03 学习讲义
正文
工具
按问题查找
Lecture 035. 第二条视觉路线:只看四块,预测其余位置 · 实现代码

5. 第二条视觉路线:只看四块,预测其余位置 · 实现代码

独立阅读

主线阅读与优先实验

标签供给、文本目标接口、视图/队列/MAE图与表示迁移证据

展开完整实现代码
# 独立 CPU 练习:改变 visible 或 crop,观察位置与目标集合。
visible = {0,3,9,14}
crop = (0,0,4,4)  # 网格坐标 (左,上,右,下),右/下边界不含;可改为 (0,0,2,4)
assert visible <= set(range(16))
left,top,right,bottom = crop
assert 0 <= left < right <= 4 and 0 <= top < bottom <= 4
retained = {4*r+c for r in range(top,bottom) for c in range(left,right)}
encoder_positions = sorted(visible & retained)
masked_positions = sorted(retained-visible)
print('编码器读入位置:',encoder_positions)
print('损失比较位置:',masked_positions)
print('解码器位置表:')
for r in range(4):
    print(['OUT' if 4*r+c not in retained else (str(4*r+c) if 4*r+c in visible else 'MASK') for c in range(4)])
if crop == (0,0,4,4):
    assert len(encoder_positions)==4 and len(masked_positions)==12
print('这些是输入/目标位置;这里没有训练或执行重建模型。')