diff --git a/torchvision/utils.py b/torchvision/utils.py index e82752ab28b..64e7b481ebf 100644 --- a/torchvision/utils.py +++ b/torchvision/utils.py @@ -57,7 +57,11 @@ def make_grid( if not torch.jit.is_scripting() and not torch.jit.is_tracing(): _log_api_usage_once(make_grid) if not (torch.is_tensor(tensor) or (isinstance(tensor, list) and all(torch.is_tensor(t) for t in tensor))): - raise TypeError(f"tensor or list of tensors expected, got {type(tensor)}") + if isinstance(tensor, list): + typ = "a list not containing only tensors" + else: + typ = repr(type(tensor)) + raise TypeError(f"tensor or list of tensors expected, got {typ}") if "range" in kwargs.keys(): warnings.warn(