错误返回
TypeError Traceback (most recent call last)
<ipython-input-3-4b01de57c05d> in <module>
83 correct=0
84 total=0
---> 85 for images,labels in test_loader:
86 outputs = model(images)
87 outputs = model(images)
D:\Program Files (x86)\python3.6\lib\site-packages\torch\utils\data\dataloader.py in __next__(self)
613 if self.num_workers == 0: # same-process loading
614 indices = next(self.sample_iter) # may raise StopIteration
--> 615 batch = self.collate_fn([self.dataset[i] for i in indices])
616 if self.pin_memory:
617 batch = pin_memory_batch(batch)
D:\Program Files (x86)\python3.6\lib\site-packages\torch\utils\data\dataloader.py in <listcomp>(.0)
613 if self.num_workers == 0: # same-process loading
614 indices = next(self.sample_iter) # may raise StopIteration
--> 615 batch = self.collate_fn([self.dataset[i] for i in indices])
616 if self.pin_memory:
617 batch = pin_memory_batch(batch)
D:\Program Files (x86)\python3.6\lib\site-packages\torchvision\datasets\mnist.py in __getitem__(self, index)
74
75 if self.transform is not None:
---> 76 img = self.transform(img)
77
78 if self.target_transform is not None:
TypeError: object() takes no parameters
本来以为是torch版本或者torchvision的问题,换了几个版本依旧没有解决。
后面才发现原来少了个括号
加上就没有报错了