Identity

class paddle.nn. Identity ( *args, **kwargs ) [source]

A placeholder identity operator that is argument-insensitive. For each input \(X\) , the output \(Out\) is:

\[Out = X\]
Parameters
  • args – any argument (unused)

  • kwargs – any keyword argument (unused)

Shape:
  • input: Multi-dimensional tensor with shape \([batch\_size, n1, n2, ...]\) .

  • output: Multi-dimensional tensor with shape \([batch\_size, n1, n2, ...]\) .

Examples

>>> import paddle
>>> paddle.seed(100)

>>> input_tensor = paddle.randn(shape=[3, 2])
>>> layer = paddle.nn.Identity()
>>> out = layer(input_tensor)
>>> print(input_tensor)
Tensor(shape=[3, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
[[-1.41661501,  0.25904641],
 [ 0.00979547, -0.30324230],
 [-1.34256756, -0.76540256]])
>>> print(out)
Tensor(shape=[3, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
[[-1.41661501,  0.25904641],
 [ 0.00979547, -0.30324230],
 [-1.34256756, -0.76540256]])
forward ( input )

forward

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments