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-dimentional tensor with shape \([batch\_size, n1, n2, ...]\) .

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

Examples

import paddle

input_tensor = paddle.randn(shape=[3, 2])
layer = paddle.nn.Identity()
out = layer(input_tensor)
# input_tensor: [[-0.32342386 -1.200079  ]
#                [ 0.7979031  -0.90978354]
#                [ 0.40597573  1.8095392 ]]
# out: [[-0.32342386 -1.200079  ]
#      [ 0.7979031  -0.90978354]
#      [ 0.40597573  1.8095392 ]]
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