Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between tf.constant and tf.convert_to_tensor

tf.to_float(tf.convert_to_tensor(python_object)) used many times in Tensorflow object detection api like grid_anchor_generator. normaly I'll use tf.constant(python_object, dtype=tf.float32). I'm wondering the difference between them. Thanks

like image 747
BugKiller Avatar asked May 01 '18 00:05

BugKiller


People also ask

What is the difference between tf constant and tf variable?

A variable can be assigned to, it's value can be changed. A constant is constant. More subtly: A constant's value is stored in the graph and its value is replicated wherever the graph is loaded. A variable is stored separately, and may live on a parameter server.

What does tf constant mean?

tf. constant is useful for asserting that the value can be embedded that way. If the argument dtype is not specified, then the type is inferred from the type of value . # Constant 1-D Tensor from a python list. tf.

What is the difference between Eagertensor and tensor?

EagreTensor represents a tensor who's value has been calculated in eager mode whereas Tensor represents a tensor node in a graph that may not yet have been calculated.

What are constants in TensorFlow?

constant() TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks. constant() is used to create a Tensor from tensor like objects like list.


1 Answers

For tf.constant, the input value must be a static non-tensor type. For example a numpy array.

For tf.convert_to_tensor, the value "an object whose type has a registered Tensor conversion function." This means input types like Tensors or tf.Variables can also be provided as inputs. For example, see the tensor conversion function for Variables here: https://github.com/tensorflow/tensorflow/blob/r1.8/tensorflow/python/ops/variables.py#L762

like image 183
suharshs Avatar answered Sep 20 '22 03:09

suharshs