is_empty

paddle.fluid.layers.is_empty(x, cond=None)[source]

Test whether a Variable is empty.

Parameters
  • x (Variable) – The Variable to be tested.

  • cond (Variable, optional) – Output parameter. Default: None. If this parameter is given, it saves the test result of given ‘x’.

Returns

A bool scalar. True if ‘x’ is an empty Variable.

Return type

Variable

Raises

TypeError – If input cond is not a variable, or cond’s dtype is not bool.

Examples

import paddle.fluid as fluid
input = fluid.layers.data(name="input", shape=[4, 32, 32], dtype="float32")
res = fluid.layers.is_empty(x=input)
# or:
# fluid.layers.is_empty(x=input, cond=res)