Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paddle.vision.datasets.MNIST API文档和源代码以及官方使用示例不一致 #43194

Closed
Pt-11111 opened this issue Jun 4, 2022 · 3 comments · Fixed by PaddlePaddle/docs#4944
Assignees
Labels
status/close 已关闭 type/question 用户提问

Comments

@Pt-11111
Copy link

Pt-11111 commented Jun 4, 2022

请提出你的问题 Please ask your question

MNIST文档内容如下:
image
可是我在一些官方实例中看到多了个transform参数,

from paddle.vision.transforms import Normalize

# 定义图像归一化处理方法,这里的CHW指图像格式需为 [C通道数,H图像高度,W图像宽度]
transform = Normalize(mean=[127.5], std=[127.5], data_format='CHW')
# 下载数据集并初始化 DataSet
train_dataset = paddle.vision.datasets.MNIST(mode='train', transform=transform)
test_dataset = paddle.vision.datasets.MNIST(mode='test', transform=transform)
print('train images: ',len(train_dataset),', test images: ',len(test_dataset))

我知道这个是用来处理图像,但是API文档里没有这个。

我看了下class paddle.vision.datasets.MNIST[源代码]
这里面是有这个参数的,API文档里应该是忘了加上相应的描述?

 def __init__(self,
                 image_path=None,
                 label_path=None,
                 mode='train',
                 transform=None,
                 download=True,
                 backend=None):
        assert mode.lower() in ['train', 'test'], \
                "mode should be 'train' or 'test', but got {}".format(mode)

        if backend is None:
            backend = paddle.vision.get_image_backend()
        if backend not in ['pil', 'cv2']:
            raise ValueError(
                "Expected backend are one of ['pil', 'cv2'], but got {}"
                .format(backend))
        self.backend = backend

        self.mode = mode.lower()
        self.image_path = image_path
        if self.image_path is None:
            assert download, "image_path is not set and downloading automatically is disabled"
            image_url = self.TRAIN_IMAGE_URL if mode == 'train' else self.TEST_IMAGE_URL
            image_md5 = self.TRAIN_IMAGE_MD5 if mode == 'train' else self.TEST_IMAGE_MD5
            self.image_path = _check_exists_and_download(
                image_path, image_url, image_md5, self.NAME, download)

        self.label_path = label_path
        if self.label_path is None:
            assert download, "label_path is not set and downloading automatically is disabled"
            label_url = self.TRAIN_LABEL_URL if self.mode == 'train' else self.TEST_LABEL_URL
            label_md5 = self.TRAIN_LABEL_MD5 if self.mode == 'train' else self.TEST_LABEL_MD5
            self.label_path = _check_exists_and_download(
                label_path, label_url, label_md5, self.NAME, download)

        self.transform = transform

我是一个刚接触paddle和python的小白,不知道理解的对不对。

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jun 4, 2022

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

@SigureMo
Copy link
Member

SigureMo commented Jun 4, 2022

看了一下,确实,VOC2012 也存在相同问题,如果有兴趣欢迎一起贡献呀~可以参考 PFCC 文档方向里的部分指南修复一下~

#42620 (comment)

@SigureMo
Copy link
Member

已于 PaddlePaddle/docs#4944 修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/close 已关闭 type/question 用户提问
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants