本文整理匯總了Python中chainer.iterators方法的典型用法代碼示例。如果您正苦於以下問題:Python chainer.iterators方法的具體用法?Python chainer.iterators怎麽用?Python chainer.iterators使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類chainer
的用法示例。
在下文中一共展示了chainer.iterators方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_iterator
# 需要導入模塊: import chainer [as 別名]
# 或者: from chainer import iterators [as 別名]
def create_iterator(train_data, test_data, config, devices, updater_name):
Iterator = getattr(chainer.iterators, config['name'])
args = parse_dict(config, 'args', {})
if 'MultiprocessParallelUpdater' in updater_name:
train_iter = [
chainer.iterators.MultiprocessIterator(i,
config['train_batchsize'],
**args)
for i in chainer.datasets.split_dataset_n_random(train_data, len(devices))]
else:
train_iter = Iterator(train_data, config['train_batchsize'], **args)
test_iter = None
if test_data is not None:
args['repeat'] = False
test_iter = Iterator(test_data, config['test_batchsize'], **args)
return train_iter, test_iter
示例2: __init__
# 需要導入模塊: import chainer [as 別名]
# 或者: from chainer import iterators [as 別名]
def __init__(self, iterators):
"""Inits the ShufflingEnabler
:param list[Iterator] iterators: The iterators to enable shuffling on
"""
self.set = False
self.iterators = iterators
示例3: __call__
# 需要導入模塊: import chainer [as 別名]
# 或者: from chainer import iterators [as 別名]
def __call__(self, trainer):
"""Calls the enabler on the given iterator
:param trainer: The iterator
"""
if not self.set:
for iterator in self.iterators:
iterator.start_shuffle()
self.set = True
示例4: create_iterator_test
# 需要導入模塊: import chainer [as 別名]
# 或者: from chainer import iterators [as 別名]
def create_iterator_test(test_data, config):
Iterator = getattr(chainer.iterators, config['name'])
args = parse_dict(config, 'args', {})
args['repeat'] = False
args['shuffle'] = False
test_iter = Iterator(test_data, config['test_batchsize'], **args)
return test_iter