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
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With