[LAB 04 · CLIP:候选、提示与关系检验](/course/notebooks/0ba963931ddf4866b507b210d93a43bf.html) # 同一对象只交换左右,真实 CLIP 是否跟着关系改变? · 实现代码 [独立阅读](/course/notebook-blocks/880250bb392141d3b60ed38535b8d073.html) 主线阅读与优先实验 真实CLIP输入/权重/分数、候选改动、四条件规则与独立关系推理 展开完整实现代码 ``` # 重做缓存后的关系排序;可改排序/显示,不能改真值去迎合模型。 cos=a['relation_images']@a['relation_text'].T print('关系 cosine:',cos) print('预测:',cos.argmax(1),'真值:',[0,1]) assert cos.argmax(1).tolist()==[1,1] # 当前已核验缓存的实际反例 for r in manifest['relation']: from IPython.display import display from PIL import Image display(Image.open(RETRIEVAL_ROOT/r['path'])) ```