is_tensor

paddle. is_tensor ( x: Any ) TypeGuard[Tensor] [source]

Tests whether input object is a paddle.Tensor.

Note

Alias Support: The parameter name obj can be used as an alias for x. For example, is_tensor(obj=tensor_x) is equivalent to is_tensor(x=tensor_x).

Parameters

x (object) – Object to test. alias: obj.

Returns

A boolean value. True if x is a paddle.Tensor, otherwise False.

Examples

>>> import paddle

>>> input1 = paddle.rand(shape=[2, 3, 5], dtype='float32')
>>> check = paddle.is_tensor(input1)
>>> print(check)
True

>>> input3 = [1, 4]
>>> check = paddle.is_tensor(input3)
>>> print(check)
False