
我是按照将两个数组相加的方式计算TP的值,报出AttributeError: 'numpy.ndarray' object has no attribute 'byte'的错误,我以为是类型不对,做了从tensor到ndarray 的转换,用的是detach ().numpy (),报出 AttributeError: 'numpy.ndarray' object has no attribute 'detch'
NumPy 中没有 byte() 方法的。如果想把PyTorch 的张量转换为 NumPy 数组,可以使用 tensor.detach().numpy()