torch.is_tensor

torch.is_tensor(obj) [source]

Returns True if obj is a PyTorch tensor.

Note that this function is simply doing isinstance(obj, Tensor). Using that isinstance check is better for typechecking with mypy, and more explicit - so it’s recommended to use that instead of is_tensor.

Parameters

obj (Object) – Object to test

© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.is_tensor.html