Skip to content

Commit

Permalink
Copy updater_creator
Browse files Browse the repository at this point in the history
  • Loading branch information
mitmul committed Aug 14, 2017
1 parent b103335 commit 5aa5956
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions chainercmd/init.py
Expand Up @@ -9,6 +9,8 @@ def init_basic(args):
dataset_template = os.path.abspath(template.dataset.__file__)
loss_template = os.path.abspath(template.loss.__file__)
custom_ext_template = os.path.abspath(template.custom_extension.__file__)
updater_creator_template = os.path.abspath(
template.updater_creator.__file__)

if args.create_subdirs:
if not os.path.exists('model'):
Expand All @@ -23,11 +25,15 @@ def init_basic(args):
if not os.path.exists('extension'):
os.mkdir('extension')
shutil.copy(custom_ext_template, 'extension/')
if not os.path.exists('updater'):
os.mkdir('updater')
shutil.copy(custom_ext_template, 'updater/')
else:
shutil.copy(model_template, './')
shutil.copy(dataset_template, './')
shutil.copy(loss_template, './')
shutil.copy(custom_ext_template, './')
shutil.copy(updater_creator_template, './')
init_config(args)


Expand Down
15 changes: 15 additions & 0 deletions examples/mnist/updater_creator.py
@@ -0,0 +1,15 @@
from chainer.training import updater


def updater_creator(iterator, optimizer, devices, **kwargs):
"""A sample updater creator.
You need to return an Updater object in a updater creator method.
Once a updter creator method is specified in the config YAML, the method
will take iterator object, optimizer object, device dictionary, and "args"
dictionary defined in the config YAML. You can make a custom Updater with
those objects and return it.
"""
return updater.StandardUpdater(
iterator, optimizer, device=devices['main'])
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -11,7 +11,7 @@

setup(
name='chainercmd',
version='1.0.0a6',
version='1.0.0a7',
description='Command Line Tools for Chainer',
author='Shunta Saito',
author_email='shunta.saito@gmail.com',
Expand Down

0 comments on commit 5aa5956

Please sign in to comment.