子不语面经(30min)
- 项目介绍
- 问:
- 为什么使用SwinT不使用ViT。窗口间attention是如何实现的?为什么不直接使用ViT。如果你只使用Vi 模型,并且想要增加非局域相关性,应该如何操作?:1.增加多层或更多头的注意力头部2.金字塔结构特征融合3.Non-Local Attention4.
- 有了解过其他Transformer在图像上的应用吗?:没有(BERT,DeiT,T2T-ViT)
- 代码题目:
- 给你一个非负整数 x ,计算并返回 x 的 算术平方根 。由于返回类型是浮点数,精度0.00001。
二分查找,复杂度:logn
2. NMS(非极大抑制)代码:说了实现原理,代码不会。
def non_max_suppression(boxes, scores, threshold): if len(boxes) == 0: return [] # 按得分从高到低排序 order = scores.argsort()[::-1] selected_indices = [] while len(order) > 0: # 选择得分最高的边界框 i = order[0] selected_indices.append(i) # 计算当前边界框与其余边界框的 IoU iou = calculate_iou(boxes[i], boxes[order[1:]]) # 保留IoU小于阈值的边界框 mask = iou <= threshold order = order[1:][mask] return selected_indices def calculate_iou(box, boxes): x_min = np.maximum(box[0], boxes[:, 0]) y_min = np.maximum(box[1], boxes[:, 1]) x_max = np.minimum(box[2], boxes[:, 2]) y_max = np.minimum(box[3], boxes[:, 3]) intersection = np.maximum(0, x_max - x_min) * np.maximum(0, y_max - y_min) area_box = (box[2] - box[0]) * (box[3] - box[1]) area_boxes = (boxes[:, 2] - boxes[:, 0]) * (boxes[:, 3] - boxes[:, 1]) iou = intersection / (area_box + area_boxes - intersection) return iou
反思:整体偏向于Transformer。我懂得不多...