简体   繁体   中英

Replace MNIST data in Tensorflow CNN models

I am trying to train a CNN model on my own dataset in tensorflow. 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 .

Now I don't know how to replace the MNIST data with my own data. Is there a way to replace mnist data with my own data or import them in tensorflow?

You might have a look at this file especially at the lines where the import of the mnist data is programmed.

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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