2 回答

TA貢獻1804條經驗 獲得超3個贊
嘗試在plt.figure(figsize=[width, height])之前插入plt.imshow并選擇width, height 會讓您滿意的。
因此,例如,imshow函數可能是:
def imshow(inp, title=None):
"""Imshow for Tensor."""
inp = inp.numpy().transpose((1, 2, 0))
mean = np.array(mean_nums)
std = np.array(std_nums)
inp = std * inp + mean
inp = np.clip(inp, 0, 1)
plt.figure(figsize=[20, 20])
plt.imshow(inp)
if title is not None:
plt.title(title)
plt.pause(0.001) # pause a bit so that plots are updated

TA貢獻1784條經驗 獲得超9個贊
這不是關于插入plt.figure(figsize=[20, 20]),而是關于在調用之前 makegrid插入它。
plt.figure(figsize=[20, 20])
out = torchvision.utils.make_grid(inputs,nrow=2)
# ... do whatever you want after ...
plt.imshow(out)
添加回答
舉報