小编Gio*_*ano的帖子

RuntimeError: 形状 [1, 224, 224] 的输出与广播形状 [3, 224, 224] 不匹配

这是我尝试训练网络时遇到的错误。

我们用来存储来自 Caltech 101 数据集的图像的类是由我们的老师提供的。

from torchvision.datasets import VisionDataset

from PIL import Image

import os
import os.path
import sys


def pil_loader(path):
    # open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
    with open(path, 'rb') as f:
        img = Image.open(f)
        return img.convert('RGB')


class Caltech(VisionDataset):
    def __init__(self, root, split='train', transform=None, target_transform=None):
        super(Caltech, self).__init__(root, transform=transform, target_transform=target_transform)

        self.split = split # This defines the split you are going to use
                           # (split files are called 'train.txt' and 'test.txt')

        '''
        - Here you should implement the …
Run Code Online (Sandbox Code Playgroud)

python mnist pytorch

5
推荐指数
1
解决办法
8342
查看次数

标签 统计

mnist ×1

python ×1

pytorch ×1