【发布时间】:2017-02-23 15:26:32
【问题描述】:
我看了tf.matmul的官方文档 我理解第一个例子。 这是一个简单的 [2,3] x [3,2] 操作:
a = tf.constant([1, 2, 3, 4, 5, 6], shape=[2, 3])
b = tf.constant([7, 8, 9, 10, 11, 12], shape=[3, 2])
c = tf.matmul(a, b) => [[58 64]
[139 154]]
然而,第二个例子似乎很奇怪:
a = tf.constant(np.arange(1, 13, dtype=np.int32),
shape=[2, 2, 3])
b = tf.constant(np.arange(13, 25, dtype=np.int32),
shape=[2, 3, 2])
c = tf.matmul(a, b) => [[[ 94 100]
[229 244]],
[[508 532]
[697 730]]]
为什么形状为[2,2,3]的矩阵可以与[2,3,2]相乘?
【问题讨论】:
标签: python matrix tensorflow