Thursday, February 5, 2026
HomeLanguagesPython – tensorflow.constant_initializer()

Python – tensorflow.constant_initializer()

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




# Importing the library
import tensorflow as tf
  
# Initializing the input
l = [1, 2, 3, 4]
  
# Printing the input
print('l: ', l)
  
# Calculating result
x = tf.constant_initializer(l)
  
  
# Printing the result
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




# Importing the library
import tensorflow as tf
  
# Initializing the input
l = (1, 2, 3, 4)
  
# Printing the input
print('l: ', l)
  
# Calculating result
x = tf.constant_initializer(l )
  
# Printing the result
print('x: ', x)


Output:

l:  (1, 2, 3, 4)
x:  tensorflow.python.ops.init_ops_v2.Constant object at 0x7fa7f2e1ab00



Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32487 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6861 POSTS0 COMMENTS
Nicole Veronica
11983 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12071 POSTS0 COMMENTS
Shaida Kate Naidoo
6994 POSTS0 COMMENTS
Ted Musemwa
7233 POSTS0 COMMENTS
Thapelo Manthata
6944 POSTS0 COMMENTS
Umr Jansen
6926 POSTS0 COMMENTS