Jump to content

TensorFlow: Difference between revisions

Line 128: Line 128:
===Matrix Multiplication===
===Matrix Multiplication===
The two matrix multiplication operators are:
The two matrix multiplication operators are:
* <code>tf.linalg.matmul</code> (also aliased as <code>tf.matmul</code>)
* [https://www.tensorflow.org/api_docs/python/tf/linalg/matmul <code>tf.linalg.matmul</code>] (also aliased as <code>tf.matmul</code>)
* <code>tf.linalg.matvec</code>
* [https://www.tensorflow.org/api_docs/python/tf/linalg/matvec <code>tf.linalg.matvec</code>]


New: With both operators, the first few dimensions can now be the batch size.   
New: With both operators, the first few dimensions can now be the batch size.   
E.g. If A is \(b_1 \times b_2 \times 3 \times 3\) and \(B\) is \(b_1 \times b_2 \times 3\), you can multiply them with \(C = \operatorname{tf.linalg.matvec}(A,B)\) and \(C\) will be \(b_1 \times b_2 \times 3\).   
E.g. If \(A\) is \(b_1 \times b_2 \times 3 \times 3\) and \(B\) is \(b_1 \times b_2 \times 3\), you can multiply them with \(C = \operatorname{tf.linalg.matvec}(A,B)\) and \(C\) will be \(b_1 \times b_2 \times 3\).   
Also the batch size in A can be 1 and it will properly broadcast to the same size as \(B\).
Also the batch size in A can be 1 and it will properly broadcast to the same size as \(B\).