2.only one element tensors can be converted to Python scalars列表张量不能转换成np.array()
boxes = [
tensor([ 0.3170, -0.5204, 1.0137]),
tensor([-0.8448, -0.4247, 0.7249]),
tensor([-1.1847, 0.9768, 1.1339]),
tensor([-1.0586, -0.0341, -0.1651])
]
# 不能使用np.array(boxes),会报错误,显示上面的错误,这个是一个列表不能转换成张量
# 应该使用
torch.cat(boxes, dim=0)
# 或者
torch.stack(boxes, dim=0)