JM:I have a dream,期待和你一起去实现!
原文及译文
JM
网友:Pim

        我正在使用TensorFlow做一个神经网络。我现在想导入我自己的图像作为数据集,在这些图像上训练神经网络。...

推荐:想去Google查资料?(你懂的)想建站?想测试?想挂机?想折腾?想要高性价比的服务器?点我!!


在TensorFlow中导入自己的数据集(Importing own dataset in TensorFlow)

我正在使用TensorFlow做一个神经网络。我现在想导入我自己的图像作为数据集,在这些图像上训练神经网络。

为此,我首先得到一个文件名和相应的标签列表。我正在用下面的代码做这个:

locations = {"chimpanzee":["G:Profielwerkstukchimpanzee"],
           "gorilla":["G:Profielwerkstukgorilla"],
           "howler monkey":["G:Profielwerkstukhowler_monkey"]}

files = []
labels = []
numberlabel = []

for label, folders in locations.items():
    numberlabel.append(label)
    filesperlabel = []
    for folder in folders:
        filesperlabel.extend([join(folder, f) for f in listdir(folder) if isfile(join(folder, f))])
    print(len(filesperlabel))
    files.extend(filesperlabel)
    labels.extend([len(numberlabel) - 1] * len(filesperlabel))

位置在这里是一个字典,其标签为键和文件夹为值。

这工作正常:我得到的文件位置列表,标签列表和一个列表中的猴子类型输出神经元数字。

然后我试图从这个TensorFlow数据集。我首先在TensorFlow常量中转换文件名和标签名的列表:

filenames = tf.constant(files)
labelnames = tf.constant(labels)

我第一次尝试在Tensorflow网站上的代码。但是,在解码图像后,我得到图像不包含任何形状的错误。如何正确导入图像?

而且,在创建数据集之后,我想分批循环。 MNIST数据集包含一个非常方便的功能,但它也可以用于自定义数据集?搜索这个问题并没有给我很多有用的提示。


I am making a neural network using TensorFlow. I now want to import my own images as dataset, to train the neural network on these images.

For this, I at first get a list of filenames and their corresponding label. I am doing this with the following code:

locations = {"chimpanzee":["G:Profielwerkstukchimpanzee"],
           "gorilla":["G:Profielwerkstukgorilla"],
           "howler monkey":["G:Profielwerkstukhowler_monkey"]}

files = []
labels = []
numberlabel = []

for label, folders in locations.items():
    numberlabel.append(label)
    filesperlabel = []
    for folder in folders:
        filesperlabel.extend([join(folder, f) for f in listdir(folder) if isfile(join(folder, f))])
    print(len(filesperlabel))
    files.extend(filesperlabel)
    labels.extend([len(numberlabel) - 1] * len(filesperlabel))

locations is here a dictionary with the label as key and their folder as value.

This works fine: I get a list of the file locations, a list of the labels and a list of which turns the output neuron number in a monkey type.

I am then trying to makes from this a TensorFlow dataset. I at first convert the list of the filenames and the labelnames in a TensorFlow constant:

filenames = tf.constant(files)
labelnames = tf.constant(labels)

I first tried the code on the Tensorflow website. However, I get the error that image contains no shape after decoding an image. How to correctly import images?

Further, after making an dataset, I want to loop through it in batches. The MNIST dataset contains a very handy function for it, but is it also possible for custom datasets? Searching for this problems doesn't give me a lot of useful tips.


解决方案

目前暂无解决方案,可以加群交流,有解决方案后,第一时间通知你哦!或者看看下面的相关问题吧~

推荐:想去Google查资料?(你懂的)想建站?想测试?想挂机?想折腾?想要高性价比的服务器?点我!!


关于站长

JMJavaMethod的缩写,苦逼码农一个,一直想有番作为,奈何人老力衰,只能四处膜拜大佬以获得动力。已经从单机、局域网、互联网、混到了移动互联网,未来希望能在AI世界里继续混下去。这辈子有个终极目标:财务自由,心灵自由。

近期公告

一个人苦逼开发多日,网站终于正式上线,求关注!!! 一个人苦逼多日,终于正式上线,求关注!!!

找他  
猜你喜欢
想建站?想测试?
想挂机?想折腾?
想去Google查资料?(你懂的)
想要高性价比的服务器?
搬瓦工VPS - 性价最高的美国便宜VPS主机
友情链接

冀ICP备17016304号 版权所有 © JavaMethod.com All Rights Reserved,Theme by 拼图