MNIST 教程中的 Tensorflow tf.matmul
Tensorflow tf.matmul in MNIST tutorial
我是 tensorflow 的新手。这是我的问题:
在 MNIST 教程中:https://www.tensorflow.org/versions/master/get_started/mnist/beginners#mnist-for-ml-beginners:
First, we multiply x by W with the expression tf.matmul(x, W). This is flipped from when we multiplied them in our equation, where we had Wx, as a small trick to deal with x being a 2D tensor with multiple inputs. We then add b, and finally apply tf.nn.softmax.
我的问题是:
为什么 b 被初始化为向量:b = tf.Variable(tf.zeros([10]))
不像
b = tf.Variable(tf.zeros([None,10]))
或 b = tf.Variable(tf.zeros([1,10]))
?
因为 x * W + b 的形状是:[None , 784] * [784 , 10] + [None,10]
感谢您的回答。
这是因为,我们对批处理中的每个 "image" 应用相同的操作,而不是批处理。因此 x * W + b
不是
[None , 784] * [784 , 10] + [None,10]
但是
results = merge(None, [784] * [784, 10] + [10])
我是 tensorflow 的新手。这是我的问题:
在 MNIST 教程中:https://www.tensorflow.org/versions/master/get_started/mnist/beginners#mnist-for-ml-beginners:
First, we multiply x by W with the expression tf.matmul(x, W). This is flipped from when we multiplied them in our equation, where we had Wx, as a small trick to deal with x being a 2D tensor with multiple inputs. We then add b, and finally apply tf.nn.softmax.
我的问题是:
为什么 b 被初始化为向量:b = tf.Variable(tf.zeros([10]))
不像
b = tf.Variable(tf.zeros([None,10]))
或 b = tf.Variable(tf.zeros([1,10]))
?
因为 x * W + b 的形状是:[None , 784] * [784 , 10] + [None,10]
感谢您的回答。
这是因为,我们对批处理中的每个 "image" 应用相同的操作,而不是批处理。因此 x * W + b
不是
[None , 784] * [784 , 10] + [None,10]
但是
results = merge(None, [784] * [784, 10] + [10])