Friday, September 5, 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
32265 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS