Python – tensorflow.constant_initializer()
Last Updated :
10 Jul, 2020
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning neural networks.
constant_initializer() is initializer that generate a Tensor with constant value.
Syntax: tensorflow.constant_initializer( value )
Parameters:
- value: It is the value that needed to be converted to Tensor. It can be Python scalar, list or tuple of values, or a N-dimensional numpy array
Returns: It returns an Initializer instance.
Example 1: From Python list
Python3
import tensorflow as tf
l = [ 1 , 2 , 3 , 4 ]
print ( 'l: ' , l)
x = tf.constant_initializer(l)
print ( 'x: ' , x)
|
Output:
l: [1, 2, 3, 4]
x: tensorflow.python.ops.init_ops_v2.Constant object at 0x7fa7f2e1ab00
Example 2: From Python tuple
Python3
import tensorflow as tf
l = ( 1 , 2 , 3 , 4 )
print ( 'l: ' , l)
x = tf.constant_initializer(l )
print ( 'x: ' , x)
|
Output:
l: (1, 2, 3, 4)
x: tensorflow.python.ops.init_ops_v2.Constant object at 0x7fa7f2e1ab00
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...