Identity

class paddle.nn. Identity ( *args, **kwargs ) [源代码]

等效层。对于输入 Tensor X,计算公式为:

Out=X

参数

  • args - 任意的参数(没有使用)

  • kwargs – 任意的关键字参数(没有使用)

形状

  • 输入:形状为 [batch_size,n1,n2,...] 的多维 Tensor。

  • 输出:形状为 [batch_size,n1,n2,...] 的多维 Tensor。

代码示例

>>> 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]])