# Saving GAN generated images

**URL:** <https://discuss.pytorch.org/t/saving-gan-generated-images/147599>\
**Category:** Uncategorized\
**Created:** [March 28, 2022, 7:06am UTC](https://discuss.pytorch.org/t/saving-gan-generated-images/147599 "2022-03-28T07:06:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Matias\_Vasquez](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/matias_vasquez/32/47847_2.png) [@Matias\_Vasquez](https://discuss.pytorch.org/u/Matias_Vasquez)\
**Post date:** [March 28, 2022, 10:50am UTC](https://discuss.pytorch.org/t/saving-gan-generated-images/147599/2 "2022-03-28T10:50:28Z")

</div>

Torchvision has a function called `save_image()`. [Here](https://pytorch.org/vision/stable/generated/torchvision.utils.save_image.html#torchvision.utils.save_image) is the documentation.

You might want to take a look at [this old discussion](https://discuss.pytorch.org/t/how-to-save-image/48808/7) to see some examples.

Here is also a minimal example.

```python
from torchvision.utils import save_image

# Batch x Channel x Height x Width = BxCxHxW = 64x3x28x28
rand_tensor= torch.rand(64, 3,28,28) 

# Taking the first image from the batch (B)
# Img size CxHxW
img1 = rand_tensor[0]           
save_image(img1, 'img1.png')

```

---

_[View the full topic](https://discuss.pytorch.org/t/saving-gan-generated-images/147599)._
