Reputation: 69
I'm a newbie of TensorFlow, I have a problem when using list as inputs for CNN.
Let say that I have 4 list:
TrainingImage
: This is a list that has all images that I want to train, each image I is BGR channels,, so i put image I to this list by using TrainingImage.append(I)
.TrainingLabel
: This is a list for labeling image in TrainingImage
, each row is a one-hot vector. For example if I have 3 object (1, 2, 3), each object has 2 images (which mean TrainingImage
has 3 x 2 = 6 images), then I have a list of label like: 1, 0, 0; 1, 0, 0; 0, 1, 0; 0, 1, 0; 0, 0, 1; 0, 0, 1TestingImage
: List that has all images for test, similar to TrainingImage
but fewer images.TestingLabel
: List that has all label of TestingImage
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
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