创建好自己的数据集后,在跑CNN代码的时候出现了这个错误:RuntimeError: Input type (double) and bias type (float) should be the same,指的是数据类型不同
我的数据类型是64,但是卷积网络默认是32
解决办法:在自定义数据集的类中,在
def __getitem__(self, item)这个函数中,将数据先转换成32,然后再转换成张量形式就可以了
也就是这行代码: data=np.array(data).astype(np.float32)