How to use list of images as input of CNN in TensorFlow?

I'm a newbie of TensorFlow, I have a problem when using list as inputs for CNN.

Let say that I have 4 list:

I don't know how to use it as inputd for CNN in TensorFlow. I'm using the following code, each image has size 68 x 68 x 3, I have 17 object, each object I have 64 images for training, 16 images for testing.

with tf.Session() as sess:

data_initializer = tf.placeholder(tf.float32,
                                  (1088, 68, 68, 3))
label_initializer = tf.placeholder(tf.float32,
                                   (1088, 17))
input_data = tf.Variable(data_initializer, trainable=False, collections=[])
input_labels = tf.Variable(label_initializer, trainable=False, collections=[])

sess.run(input_data.initializer, feed_dict={data_initializer: TrainingImage})
sess.run(input_labels.initializer, feed_dict={label_initializer: TrainingLabel})

So now input_data and input_labels is my new input for CNN but I'm not sure this is a right way? I'm using those above code by following this TensorFlow instruction https://www.tensorflow.org/programmers_guide/reading_data#preloaded_data, treat 4 lists as variables.

Upvotes: 0

Views: 1140

Answers (1)

Anton Panchishin
Anton Panchishin

Reputation: 3773

Yeah, that'll work. May I recommend that instead of

data_initializer = tf.placeholder(tf.float32,(1088, 68, 68, 3))

you use

data_initializer = tf.placeholder(tf.float32,(None, 68, 68, 3))

This will allow you to send in different amounts of images instead of always having to send in 1088 images. At some point you way want to process just 1 image.

Upvotes: 0

Related Questions