MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / identity

Function identity

tensorflow/python/ops/array_ops.py:178–207  ·  view source on GitHub ↗

r"""Return a tensor with the same shape and contents as input. For example: ```python import tensorflow as tf val0 = tf.ones((1,), dtype=tf.float32) a = tf.atan2(val0, val0) a_identity = tf.identity(a) print(a.numpy()) #[0.7853982] print(a_identity.numpy()) #[0.7853982]

(input, name=None)

Source from the content-addressed store, hash-verified

176@tf_export("identity")
177@dispatch.add_dispatch_support
178def identity(input, name=None): # pylint: disable=redefined-builtin
179 r"""Return a tensor with the same shape and contents as input.
180
181 For example:
182
183 ```python
184 import tensorflow as tf
185 val0 = tf.ones((1,), dtype=tf.float32)
186 a = tf.atan2(val0, val0)
187 a_identity = tf.identity(a)
188 print(a.numpy()) #[0.7853982]
189 print(a_identity.numpy()) #[0.7853982]
190 ```
191
192 Args:
193 input: A `Tensor`.
194 name: A name for the operation (optional).
195
196 Returns:
197 A `Tensor`. Has the same type as `input`.
198 """
199 if context.executing_eagerly() and not hasattr(input, "graph"):
200 # Make sure we get an input with handle data attached from resource
201 # variables. Variables have correct handle data when graph building.
202 input = ops.convert_to_tensor(input)
203 ret = gen_array_ops.identity(input, name=name)
204 # Propagate handle data for happier shape inference for resource variables.
205 if hasattr(input, "_handle_data"):
206 ret._handle_data = input._handle_data # pylint: disable=protected-access
207 return ret
208
209
210# pylint: disable=redefined-builtin,protected-access

Callers 2

concatFunction · 0.70

Calls 2

executing_eagerlyMethod · 0.80
identityMethod · 0.45

Tested by 1