HomeLanguagesPython – tensorflow.guarantee_const()

Python – tensorflow.guarantee_const()

TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. 

guarantee_const() is used to assure TensorFlow runtime that input tensor is constant.

Syntax: tensorflow.guarantee_const( input, name)

Parameters: 

  • input: It is a Tensor.
  • name(optional): It defines the name for the operation

Returns: It returns a Tensor same as input Tensor.

Example 1:

Python3




# Importing the library
import tensorflow as tf
 
# Initializing the Tensor
x = tf.guarantee_const(5)
 
# Printing the result
print("x: ", x)


Output:

x:  tf.Tensor(5, shape=(), dtype=int32)

Example 2:

Python3




# Importing the library
import tensorflow as tf
 
# Initializing the Tensor
x = tf.Variable(2.0, name ="x")
z = tf.Variable(4.0, name ="z")
 
# Using guarantee_const
y = tf.guarantee_const([x, z])
 
# Printing the result
print("y: ", y)


Output:

y:  tf.Tensor([2. 4.], shape=(2, ), dtype=float32)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32683 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7051 POSTS0 COMMENTS
Nicole Veronica
12190 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12291 POSTS0 COMMENTS
Shaida Kate Naidoo
7177 POSTS0 COMMENTS
Ted Musemwa
7444 POSTS0 COMMENTS
Thapelo Manthata
7155 POSTS0 COMMENTS
Umr Jansen
7145 POSTS0 COMMENTS