Friday, October 24, 2025
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
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS