Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pytorch plot batch

In [107]: import torchvision

# sample input (10 RGB images containing just Gaussian Noise)
In [108]: batch_tensor = torch.randn(*(10, 3, 256, 256))   # (N, C, H, W)

# make grid (2 rows and 5 columns) to display our 10 images
In [109]: grid_img = torchvision.utils.make_grid(batch_tensor, nrow=5)

# check shape
In [110]: grid_img.shape
Out[110]: torch.Size([3, 518, 1292])

# reshape and plot (because MPL needs channel as the last dimension)
In [111]: plt.imshow(grid_img.permute(1, 2, 0))
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Out[111]: <matplotlib.image.AxesImage at 0x7f62081ef080>
Comment

PREVIOUS NEXT
Code Example
Python :: groupby and assign number to each group pandas 
Python :: how to import modules from upper or previous dir in py 
Python :: create empty dataframe and concat 
Python :: newton backward interpolation python code 
Python :: Custom x, y-ticks using ax 
Python :: insert key in binary tree recursively 
Python :: extract arabic text from image python 
Python :: how to increase width of line in graph of linear regression in matplotlib 
Python :: np.column_sytaxck 
Python :: 5.2.5: Counting 10 to 100 by ... 
Python :: captcha.image install in python 
Python :: give colour to the font in python email message 
Python :: what is sklearn.base 
Python :: hwoto neglect if any exception happening in python 
Python :: numpy get length of list 
Python :: numpy documentation realpython 
Python :: how to create datetime from negative epoch in python 
Python :: how to def a variable in python 
Python :: pop function second argument in python 
Python :: difference in django project view and app view 
Python :: python how to initialize wikipediaapi 
Python :: Applies a function to all elements of this RDD. 
Python :: pydrive list shared folder 
Python :: couple legend from twin axes python 
Python :: using list comprehension to filter out age group pandas 
Python :: how to print anything in python 
Python :: height and width of colorbar 
Python :: h==gmail 
Python :: python list comprehension with filter example 
Python :: replace special from beginning of string 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =