2
我有輸入到一個tensorflow convnet作爲秩4張量(32,32,3,73257)(73257來自IMGS的數目),這是numpy的陣列,但我的x輸入的佔位符變量是2-d,(None,3072)。 3072來自img height x img width x channels。我的問題是,如何重塑或使用圖像,以便它們與佔位符兼容?如何使用numpy的數組作爲輸入到Tensorflow CNN無錯配的尺寸
P.S.這些圖像是從SVHN裁剪32×32的數據集
images = np.array(features, dtype=np.float32)
...
x = tf.placeholder(tf.float32, shape=[None, 3072])
...
for _ in range(1000):
batch = next_batch(50, images, labels)
train_step.run(feed_dict={x: batch[0], y_: batch[1]})
...
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(20000):
batch = next_batch(50, images, labels)
if i % 100 == 0:
train_accuracy = accuracy.eval(feed_dict={
x: batch[0], y_: batch[1], keep_prob: 1.0})
print('step %d, training accuracy %g' % (i, train_accuracy))
train_step.run(feed_dict={x: images, y_: labels, keep_prob: 0.5})
明白了!感謝您的幫助 – Meka
請您接受我的回答嗎?謝謝。 – pgross
是的,我的壞!再次感謝 – Meka