MCPcopy Create free account
hub / github.com/pytorch/tutorials / matplotlib_imshow

Function matplotlib_imshow

beginner_source/introyt/tensorboardyt_tutorial.py:103–111  ·  view source on GitHub ↗
(img, one_channel=False)

Source from the content-addressed store, hash-verified

101
102# Helper function for inline image display
103def matplotlib_imshow(img, one_channel=False):
104 if one_channel:
105 img = img.mean(dim=0)
106 img = img / 2 + 0.5 # unnormalize
107 npimg = img.numpy()
108 if one_channel:
109 plt.imshow(npimg, cmap="Greys")
110 else:
111 plt.imshow(np.transpose(npimg, (1, 2, 0)))
112
113# Extract a batch of 4 images
114dataiter = iter(training_loader)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected