Lecture 03四条件的规则预期 · 实现代码
四条件的规则预期 · 实现代码
主线阅读与优先实验
caption历史、VQA、CLIP候选、关系控制、GLIP/LLaVA与生成桥梁
展开完整实现代码
# 独立 CPU 规则对照;输出 A/B 来自明确规则,不是 CLIP。
conditions=[('1','red','blue','left'),('2','blue','red','left'),
('3','red','blue','right'),('4','blue','red','right')]
answer_of={'red':'A','blue':'B'}
rows=[]
for cid,left,right,holder_side in conditions:
holder_color=left if holder_side=='left' else right
relation=answer_of[holder_color]
shortcut=answer_of[left]
rows.append((cid,relation,shortcut))
print('条件',cid,'持球者规则',relation,'左侧规则',shortcut,'一致?',relation==shortcut)
assert rows==[('1','A','A'),('2','B','B'),('3','B','A'),('4','A','B')]