nerdexam
Huawei

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…

Deep Learning Basics

Question

TensorFlow 2.0 The way to view tensor dimensions in is?

Options

  • Adimens
  • Bdtype
  • Cndim
  • Ddevice

How the community answered

(39 responses)
  • A
    5% (2)
  • B
    5% (2)
  • C
    79% (31)
  • D
    10% (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

#TensorFlow 2.0#Tensor attributes#Tensor dimensions#ndim

Community Discussion

No community discussion yet for this question.

Full H13-311_V3.5 Practice