python datasets用法_Python chainer.datasets方法代码示例

# 需要导入模块: import chainer [as 别名]

# 或者: from chainer import datasets [as 别名]

def get_svhn(withlabel=True, scale=1., dtype=None, label_dtype=numpy.int32,

add_extra=False):

"""Gets the SVHN dataset.

`The Street View House Numbers (SVHN) dataset

`_

is a dataset similar to MNIST but composed of cropped images of house

numbers.

The functionality of this function is identical to the counterpart for the

MNIST dataset (:func:`~chainer.datasets.get_mnist`),

with the exception that there is no ``ndim`` argument.

.. note::

`SciPy `_ is required to use this feature.

Args:

withlabel (bool): If ``True``, it returns datasets with labels. In this

case, each example is a tuple of an image and a label. Otherwise,

the datasets only contain images.

scale (float): Pixel value scale. If it is 1 (default), pixels are

scaled to the interval ``[0, 1]``.

dtype: Data type of resulting image arrays. ``chainer.config.dtype`` is

used by default (see :ref:`configuration`).

label_dtype: Data type of the labels.

add_extra: Use extra training set.

Returns:

If ``add_extra`` is ``False``, a tuple of two datasets (train and

test). Otherwise, a tuple of three datasets (train, test, and extra).

If ``withlabel`` is ``True``, all datasets are

:class:`~chainer.datasets.TupleDataset` instances. Otherwise, both

datasets are arrays of images.

"""

if not _scipy_available:

raise RuntimeError('SciPy is not available: %s' % _error)

train_raw = _retrieve_svhn_training()

dtype = chainer.get_dtype(dtype)

train = _preprocess_svhn(train_raw, withlabel, scale, dtype,

label_dtype)

test_raw = _retrieve_svhn_test()

test = _preprocess_svhn(test_raw, withlabel, scale, dtype,

label_dtype)

if add_extra:

extra_raw = _retrieve_svhn_extra()

extra = _preprocess_svhn(extra_raw, withlabel, scale, dtype,

label_dtype)

return train, test, extra

else:

return train, test

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值