关于TypeError: can’t convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool. 报错问题的处理
原代码:
Map = torch.from_numpy(np.copy(self.map_img_np))
程序会在这行代码上报错
经过修改后的代码如下:
b = np.copy(self.map_img_np)
b = b.astype(float)
Map = torch.from_numpy(b)
对numpy数组进行强制类型转换之后就会解决这个问题