- TensorFlow 2.0 Quick Start Guide
- Tony Holdroyd
- 65字
- 2021-06-24 16:02:03
Ranking (dimensions) of a tensor
The rank of a tensor is the number of dimensions it has, that is, the number of indices that are required to specify any particular element of that tensor.
The rank of a tensor can be ascertained with this, for example:
tf.rank(t2)
The output will be as follows:
<tf.Tensor: id=53, shape=(), dtype=int32, numpy=3>
(the shape is () because the output here is a scalar value)