iT邦幫忙

0

DCGAN教程範例

  • 分享至 

  • xImage

https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html
至次我想實現上列網址的範例,但我遇到一個我看不懂的錯誤,請問有人知道那是甚麼意思嗎??
錯誤內容如下:

  File "C:\Users\tenpyai\Anaconda3\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)

PicklingError: Can't pickle <class 'torchvision.datasets.folder.ImageFolder'>: it's not the same object as torchvision.datasets.folder.ImageFolder

我發現在我執行下列coed時回觸發上述問題

dataset = dset.ImageFolder(root=dataroot,
                           transform=transforms.Compose([
                               transforms.Resize(image_size),
                               transforms.CenterCrop(image_size),
                               transforms.ToTensor(),
                               transforms.Normalize((0.5, 0.5, 0.5), (0.5,  0.5, 0.5)),
                           ]))
dataloader = torch.utils.data.DataLoader(dataset, batch_size=batch_size,
                                         shuffle=True, num_workers=workers)

# Decide which device we want to run on
device = torch.device("cuda:0" if (torch.cuda.is_available() and ngpu > 0) else "cpu")
real_batch = next(iter(dataloader))
plt.figure(figsize=(8,8))
plt.axis("off")
plt.title("Training Images")
plt.imshow(np.transpose(vutils.make_grid(real_batch[0].to(device)[:64], padding=2, normalize=True).cpu(),(1,2,0)))

而錯誤卻指向reduction.py內的coed(如下)

def dump(obj, file, protocol=None):
    '''Replacement for pickle.dump() using ForkingPickler.'''   
    ForkingPickler(file, protocol).dump(obj)  <<錯誤指向這
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答