繁体   English   中英

我如何重塑我的数据集以训练 CNN

[英]How do i reshape my dataset to train a CNN

您好,我有一个 80x60 的 32FC1 图像数据集,我正在做的是重塑数据集以对其进行转换和标记,以便它可以用于训练 CNN,但是当我重塑数据集时,出现以下错误:

arraynegativos= ds_negatives.reshape(( n_negatives_img, img_width, img_height))
arraypositivos= ds_positives.reshape((n_positives_img, img_width, img_height))

AttributeError: 'list' object has no attribute 'reshape'

所以我将我的 ds_negative 转换为 numpy 数组,如下所示:

ds_negatives1 = np.array(ds_negatives)

但它给了我这个错误:

cannot reshape array of size 1 into shape (26308,80,60)

所以现在我有点困惑,我如何将我的数据集转换成这样?

这是脚本的链接,所以你可以更好地看到它。

https://colab.research.google.com/drive/1KzoHXA8Y6lcyvq7K7segFfJp2AIw9P45?usp=sharing

当您说ds_negatives = ["/content/drive/MyDrive/Colab Notebooks/negative_depth.txt"]您不是将ds_negatives设置ds_negatives文件的内容,而只是将其设置为包含文件路径的字符串。 因此列表(以及您从中创建的 np 数组)仅包含一项。 根据您想如何阅读文本文件,您应该使用open("path", "r").read().readlines()

您需要将图像加载到列表或数组中。 尝试在以下脚本中使用“imread”和“append”函数:

imagesWithLabels = []
for filename in listdir('C:/AI/images/cats'):
    # load image
    img_data =   image.imread('C:/AI/images/cats/' +\
    filename)
    # store loaded image in a list
    imagesWithLabels.append((img_data,0))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM