On this page
torch.is_tensor
torch.is_tensor(obj)[source]-
Returns True if
objis a PyTorch tensor.Note that this function is simply doing
isinstance(obj, Tensor). Using thatisinstancecheck is better for typechecking with mypy, and more explicit - so it’s recommended to use that instead ofis_tensor.- Parameters
-
obj (Object) – Object to test
Example:
>>> x = torch.tensor([1, 2, 3]) >>> torch.is_tensor(x) True
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.is_tensor.html