3
Iam對使用張量流應用卷積神經網絡感興趣。但是,我看到的唯一的教程是加載MNIST數據集。我已經嘗試複製在那裏完成的過程,並閱讀大量的教程圍繞interwebs,但它不工作。這是到目前爲止我的代碼將其他圖像加載到tensorflow中,除了MNIST
import tensorflow as tf
import os
import numpy as np
filename = os.getcwd() + '/sample_images/*.png'
filename_queue = tf.train.string_input_producer(tf.train.match_filenames_once(filename))
image_reader = tf.WholeFileReader()
_, image_file = image_reader.read(filename_queue)
image = tf.image.decode_png(image_file, 3)
image = tf.image.rgb_to_grayscale(image, name=None)
image = tf.image.resize_images(image, 28, 28, method=0, align_corners=False)
data = []
with tf.Session() as sess:
tf.initialize_all_variables().run()
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
image_tensor = sess.run([image])
data.append(image_tensor)
#print(image_tensor)
coord.request_stop()
coord.join(threads)
xx = np.asarray(data)
print xx[0].shape
基本上,我要做到以下幾點: - - 在加載圖像從文件夾中有他們的名字
調整每個圖像以28 * 28
將其更改爲灰度
把它變成一個張量,並把它添加到訓練集
創建它的目標(從它的標籤,並把它添加到numpy的陣列)的文件夾
當我做過
重複所有圖像,通過數據集和目標的tensorflow RNN
所有幫助將不勝感激