dataset.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:fxnn 作者: khaotik 项目源码 文件源码
def download(self, local_dir_=None, url_=None):
        '''
        Args:
            local_dir_: where to save downloaded file
            url_: where to download dataset, if None, use default 'http://yann.lecun.com/exdb/mnist/'
        '''
        # TODO check whether file exists
        if url_ is None:
            url_ = 'http://yann.lecun.com/exdb/mnist/'
        if local_dir_ is None:
            local_dir = self.DEFAULT_DIR
        else:
            local_dir = Path(local_dir_)
        local_dir.mkdir(parents=True, exist_ok=True)
        in_filename = '%(subset)s-%(type_s)s-idx%(ndim)s-ubyte.gz'
        for subset, (type_s, ndim) in product(
            ('train', 't10k'), zip(('images', 'labels'), (3,1))):
            filename = in_filename % locals()
            urllib.request.urlretrieve( url_ + filename, str(local_dir / filename))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号