本文整理匯總了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)
示例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))