size

paddle.fluid.layers.nn. size ( input ) [source]

Warning: API “paddle.fluid.layers.nn.size” is deprecated since 2.0.0, and will be removed in future versions. Please use “paddle.numel” instead.

Size Layer

Returns the number of elements for a tensor, which is a int64 Tensor with shape [1].

Args:

input (Tensor): The input Tensor, it’s data type can be bool, float16, float32, float64, int32, int64.

Returns:

Tensor: The number of elements for the input Tensor.

Raises:

TypeError: input must be a Tensor and the data type of input must be one of bool, float16, float32, float64, int32, int64.

Examples:
import paddle.fluid.layers as layers

input = layers.data(
    name="input", shape=[3, 100], dtype="float32", append_batch_size=False)
rank = layers.size(input) # 300