Friday, December 27, 2024
Google search engine
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 Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments