0
0
TensorFlowml~5 mins

Tensor creation (constant, variable, zeros, ones) in TensorFlow - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a constant tensor in TensorFlow?
A constant tensor is a fixed value tensor that cannot be changed after creation. It holds data that stays the same during the program run.
Click to reveal answer
beginner
How does a variable tensor differ from a constant tensor?
A variable tensor can change its values during program execution, useful for model parameters that update during training.
Click to reveal answer
beginner
What does tf.zeros(shape) do?
It creates a tensor filled with zeros of the specified shape. For example, tf.zeros([2,3]) creates a 2x3 tensor filled with zeros.
Click to reveal answer
beginner
What is the use of tf.ones(shape)?
It creates a tensor filled with ones of the given shape. Useful for initializing tensors where all values start as one.
Click to reveal answer
intermediate
How do you create a variable tensor initialized with ones in TensorFlow?
Use tf.Variable(tf.ones(shape)) to create a variable tensor filled with ones that can be updated later.
Click to reveal answer
Which TensorFlow function creates a tensor that cannot be changed after creation?
Atf.zeros()
Btf.Variable()
Ctf.constant()
Dtf.ones()
What does tf.zeros([3,2]) produce?
AA 3x2 tensor filled with ones
BA 3x2 tensor filled with zeros
CA 2x3 tensor filled with zeros
DA variable tensor with zeros
Which tensor type allows changing its values during training?
AConstant tensor
BOnes tensor
CZeros tensor
DVariable tensor
How do you create a tensor filled with ones in TensorFlow?
Atf.ones(shape)
Btf.zeros(shape)
Ctf.constant(shape)
Dtf.Variable(shape)
Which code creates a variable tensor initialized with zeros?
Atf.Variable(tf.zeros(shape))
Btf.zeros(shape)
Ctf.constant(tf.zeros(shape))
Dtf.ones(shape)
Explain the difference between tf.constant and tf.Variable tensors and when to use each.
Think about whether the tensor values need to change during training.
You got /4 concepts.
    Describe how to create tensors filled with zeros and ones and why these might be useful.
    Consider initialization in neural networks.
    You got /4 concepts.