本文整理汇总了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))