torchvision.utils.make_grid(tensor: Union[torch.Tensor, List[torch.Tensor]], nrow: int = 8, padding: int = 2, normalize: bool = False, value_range: Optional[Tuple[int, int]] = None, scale_each: bool = False, pad_value: float = 0.0, **kwargs)torch.Tensor[source]

Make a grid of images.

  • tensor (Tensor or list) – 4D mini-batch Tensor of shape (B x C x H x W) or a list of images all of the same size.

  • nrow (int, optional) – Number of images displayed in each row of the grid. The final grid size is (B / nrow, nrow). Default: 8.

  • padding (int, optional) – amount of padding. Default: 2.

  • normalize (bool, optional) – If True, shift the image to the range (0, 1), by the min and max values specified by value_range. Default: False.

  • value_range (tuple, optional) – tuple (min, max) where min and max are numbers, then these numbers are used to normalize the image. By default, min and max are computed from the tensor.

  • range (tuple. optional) –


    This parameter was deprecated in 0.12 and will be removed in 0.14. Please use value_range instead.

  • scale_each (bool, optional) – If True, scale each image in the batch of images separately rather than the (min, max) over all images. Default: False.

  • pad_value (float, optional) – Value for the padded pixels. Default: 0.


the tensor containing grid of images.

Return type

grid (Tensor)

Examples using make_grid:

Visualization utilities

Visualization utilities

Visualization utilities


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources