报错
出错代码
target_locs_array = locs_array[target_idx.detach().cpu().numpy().astype(np.int)].squeeze()
其实真的很离谱,好多论文代码中都报这个问题
解决
numpy中没有int属性,直接删除np或者用np.int32、64等即可
target_locs_array = locs_array[target_idx.detach().cpu().numpy().astype(int)].squeeze()
实际上numpy().astype(int) 都可以不用,因为在从 PyTorch 张量转换到 NumPy 数组的过程中,索引通常已经是整数类型