H13-311_V3.5 · Question #225
TensorFlow 2.0 The way to view tensor dimensions in is?
The correct answer is C. ndim. In TensorFlow 2.0, tensor.ndim returns the number of dimensions (rank) of a tensor - for example, a scalar has ndim=0, a vector has ndim=1, and a matrix has ndim=2. Option B (dtype) is wrong because it describes the data type of the tensor's elements (e.g., float32, int64), not…
Question
TensorFlow 2.0 The way to view tensor dimensions in is?
Options
- Adimens
- Bdtype
- Cndim
- Ddevice
How the community answered
(39 responses)- A5% (2)
- B5% (2)
- C79% (31)
- D10% (4)
Explanation
In TensorFlow 2.0, tensor.ndim returns the number of dimensions (rank) of a tensor - for example, a scalar has ndim=0, a vector has ndim=1, and a matrix has ndim=2. Option B (dtype) is wrong because it describes the data type of the tensor's elements (e.g., float32, int64), not its shape. Option D (device) is wrong because it indicates where the tensor is stored (CPU or GPU), which is unrelated to dimensions. Option A (dimens) is simply not a valid TensorFlow attribute and does not exist.
Memory tip: Think "number of dimensions = ndim" - the n stands for number, making it the natural choice for counting axes.
Topics
Community Discussion
No community discussion yet for this question.