当前位置: 首页>>代码示例>>Python>>正文


Python datasets.CIFAR10属性代码示例

本文整理汇总了Python中fuel.datasets.CIFAR10属性的典型用法代码示例。如果您正苦于以下问题:Python datasets.CIFAR10属性的具体用法?Python datasets.CIFAR10怎么用?Python datasets.CIFAR10使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在fuel.datasets的用法示例。


在下文中一共展示了datasets.CIFAR10属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_cifar10_streams

# 需要导入模块: from fuel import datasets [as 别名]
# 或者: from fuel.datasets import CIFAR10 [as 别名]
def create_cifar10_streams(training_batch_size, monitoring_batch_size):
    """Creates CIFAR10 data streams.

    Parameters
    ----------
    training_batch_size : int
        Batch size for training.
    monitoring_batch_size : int
        Batch size for monitoring.

    Returns
    -------
    rval : tuple of data streams
        Data streams for the main loop, the training set monitor,
        the validation set monitor and the test set monitor.

    """
    train_set = CIFAR10(('train',), sources=('features',),
                     subset=slice(0, 45000))
    valid_set = CIFAR10(('train',), sources=('features',),
                     subset=slice(45000, 50000))
    test_set = CIFAR10(('test',), sources=('features',))

    return create_streams(train_set, valid_set, test_set, training_batch_size,
                          monitoring_batch_size) 
开发者ID:vdumoulin,项目名称:discgen,代码行数:27,代码来源:utils.py

示例2: test_cifar10

# 需要导入模块: from fuel import datasets [as 别名]
# 或者: from fuel.datasets import CIFAR10 [as 别名]
def test_cifar10():
    train = CIFAR10(('train',), load_in_memory=False)
    assert train.num_examples == 50000
    handle = train.open()
    features, targets = train.get_data(handle, slice(49990, 50000))
    assert features.shape == (10, 3, 32, 32)
    assert targets.shape == (10, 1)
    train.close(handle)

    test = CIFAR10(('test',), load_in_memory=False)
    handle = test.open()
    features, targets = test.get_data(handle, slice(0, 10))
    assert features.shape == (10, 3, 32, 32)
    assert targets.shape == (10, 1)
    assert features.dtype == numpy.uint8
    assert targets.dtype == numpy.uint8
    test.close(handle)

    stream = DataStream.default_stream(
        test, iteration_scheme=SequentialScheme(10, 10))
    data = next(stream.get_epoch_iterator())[0]
    assert data.min() >= 0.0 and data.max() <= 1.0
    assert data.dtype == config.floatX

    assert_raises(ValueError, CIFAR10, ('valid',))

    assert_raises(ValueError, CIFAR10,
                  ('train',), subset=slice(50000, 60000)) 
开发者ID:rizar,项目名称:attention-lvcsr,代码行数:30,代码来源:test_cifar10.py


注:本文中的fuel.datasets.CIFAR10属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。