Saturday, February 14, 2026
HomeLanguagesPython – tensorflow.identity_n()

Python – tensorflow.identity_n()

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

identity_n() is used get a list of Tensor with same shape and content as input Tensor.

Syntax: tensorflow.identity_n( input, name)

Parameters:

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

Returns:  It returns a list of Tensors with same shape and content as input. 

Example 1:

Python3




# Importing the library
import tensorflow as tf
  
# Initializing the input
data = tf.constant([[1, 2, 3], [3, 4, 5], [5, 6, 7]])
  
# Printing the input
print('data: ', data)
  
# Calculating result
res = tf.identity_n(data)
  
# Printing the result
print('res: ', res)


Output:

data:  tf.Tensor(
[[1 2 3]
 [3 4 5]
 [5 6 7]], shape=(3, 3), dtype=int32)
res:  [<tf.Tensor: shape=(3, ), dtype=int32, numpy=array([1, 2, 3], dtype=int32)>,
     <tf.Tensor: shape=(3, ), dtype=int32, numpy=array([3, 4, 5], dtype=int32)>, 
     <tf.Tensor: shape=(3, ), dtype=int32, numpy=array([5, 6, 7], dtype=int32)>]

Example 2:

Python3




# Importing the library
import tensorflow as tf
  
# Initializing the input
data = tf.constant([1, 2, 3])
  
# Printing the input
print('data: ', data)
  
# Calculating result
res = tf.identity_n(data)
  
# Printing the result
print('res: ', res)


Output:

data:  tf.Tensor([1 2 3], shape=(3, ), dtype=int32)
res:  [<tf.Tensor: shape=(), dtype=int32, numpy=1>,
     <tf.Tensor: shape=(), dtype=int32, numpy=2>, 
     <tf.Tensor: shape=(), dtype=int32, numpy=3>]


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

Most Popular

Dominic
32504 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6880 POSTS0 COMMENTS
Nicole Veronica
12003 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12097 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6966 POSTS0 COMMENTS
Umr Jansen
6954 POSTS0 COMMENTS