相关疑难解决方法(0)

输入平板机中的Tensorflow批量大小

我是Tensorflow的新手,我无法理解为什么输入占位符的大小通常与用于训练的批次大小相同.

在这个例子中,我在这里和官方的Mnist教程中发现它不是

from get_mnist_data_tf import read_data_sets
mnist = read_data_sets("MNIST_data/", one_hot=True)
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.placeholder("float", shape=[None, 784])
y_ = tf.placeholder("float", shape=[None, 10])
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))
sess.run(tf.initialize_all_variables())
y = tf.nn.softmax(tf.matmul(x,W) + b)
cross_entropy = -tf.reduce_sum(y_*tf.log(y))
train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)
for i in range(1000):
  batch = mnist.train.next_batch(50)
  train_step.run(feed_dict={x: batch[0], y_: batch[1]})
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))

print(accuracy.eval(feed_dict={x: mnist.test.images,
                               y_: mnist.test.labels}))
Run Code Online (Sandbox Code Playgroud)

那么,维度和创建模型输入并进行训练的最佳和正确方法是什么?

python machine-learning deep-learning tensorflow

4
推荐指数
1
解决办法
2万
查看次数