Does create a constant tensor?


I would like to understand the reason for using tf.constant command to create a tensor.
Why does it contain “constant” word in it?

If we had 2 tensors:

x0 = tf.constant(np.random.randn(3,1))


x1 = tf.ones(3)

would there be any particular operation permitted for x1 but not for x0?

Would x1 be a constant tensor too?

I hope I am not making confusion with the way I ask the question but I am new to TensorFlow and would really like to understand the basics.


Hi, @henrikh.

I think this answers your question:

All eager tf.Tensor values are immutable (in contrast to tf.Variable). There is nothing especially constant about the value returned from tf.constant. This function is not fundamentally different from tf.convert_to_tensor. The name tf.constant comes from the value being embedded in a Const node in the tf.Graph. tf.constant is useful for asserting that the value can be embedded that way.

You may find the Introduction to Variables helpful too.

Hope you’re enjoying the course :slight_smile:

Hi @nramon,

So creates an immutable variable in the same way tf.constant does.

I was guessing that but need a confirmation.

Thank you

1 Like