當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。