简体   繁体   English

在Tensorflow CNN模型中替换MNIST数据

[英]Replace MNIST data in Tensorflow CNN models

I am trying to train a CNN model on my own dataset in tensorflow. 我正在尝试在张量流中的自己的数据集上训练CNN模型。 I transformed my data in the same MNIST format with this code https://github.com/gskielian/JPG-PNG-to-MNIST-NN-Format/blob/master/convert-images-to-mnist-format.py . 我使用以下代码https://github.com/gskielian/JPG-PNG-to-MNIST-NN-Format/blob/master/convert-images-to-mnist-format.py将数据转换为相同的MNIST格式。

Now I don't know how to replace the MNIST data with my own data. 现在我不知道如何用我自己的数据替换MNIST数据。 Is there a way to replace mnist data with my own data or import them in tensorflow? 有没有办法用我自己的数据替换mnist数据或将它们导入tensorflow?

You might have a look at this file especially at the lines where the import of the mnist data is programmed. 您可能会看一下文件,特别是在mnist数据导入的编程行中。

from tensorflow.examples.tutorials.mnist import input_data    
mnist = input_data.read_data_sets(FLAGS.data_dir, one_hot=True)

This function imports the mnist data. 此函数导入mnist数据。 According to the function's sourcecode (line 229 ff.) your files should have the following names so you need to rewrite the function you've linked to so there is a test set. 根据函数的源代码 (229 ff行),您的文件应具有以下名称,因此您需要重写链接到的函数,以提供一个测试集。

TRAIN_IMAGES = 'train-images-idx3-ubyte.gz'
TRAIN_LABELS = 'train-labels-idx1-ubyte.gz'
TEST_IMAGES = 't10k-images-idx3-ubyte.gz'
TEST_LABELS = 't10k-labels-idx1-ubyte.gz'

Alternatively you could adapt the function's source to your needs and write your own import function. 另外,您可以根据需要调整函数的来源,并编写自己的导入函数。

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

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