- TensorFlow 2.0 Quick Start Guide
- Tony Holdroyd
- 79字
- 2021-06-24 16:02:04
Transposing TensorFlow and matrix multiplication
To transpose a matrix and matrix multiplication eagerly, use the following:
u = tf.constant([[3,4,3]])
v = tf.constant([[1,2,1]])
tf.matmul(u, tf.transpose(a=v))
The output will be as follows:
<tf.Tensor: id=555345, shape=(1, 1), dtype=int32, numpy=array([[14]], dtype=int32)>
Note, again, that the default integer type is tf.int32 and the default float type is tf.float32.
All of the operations that are available for tensors that form part of a computational graph are also available for eager execution variables.
There is a complete list of these operations at https://www.tensorflow.org/api_guides/python/math_ops.