Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
129 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from chainercmd.config.model import get_model_from_config # NOQA | ||
from chainercmd.config.dataset import get_dataset_from_config # NOQA | ||
from chainercmd.config.optimizer import get_optimizer_from_config # NOQA | ||
from chainercmd.config.updater_creator import get_updater_creator_from_config # NOQA |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from functools import partial | ||
from importlib.machinery import SourceFileLoader | ||
|
||
from chainercmd.config.base import ConfigBase | ||
|
||
|
||
class UpdaterCreator(ConfigBase): | ||
|
||
def __init__(self, **kwargs): | ||
required_keys = [ | ||
'file', | ||
'name', | ||
] | ||
optional_keys = [ | ||
'args', | ||
] | ||
super().__init__( | ||
required_keys, optional_keys, kwargs, self.__class__.__name__) | ||
|
||
|
||
def get_updater_creator(file, name, args): | ||
loader = SourceFileLoader(name, file) | ||
mod = loader.load_module() | ||
updater_creator = getattr(mod, name) | ||
if args is not None: | ||
return partial(updater_creator, **args) | ||
else: | ||
return updater_creator | ||
|
||
|
||
def get_updater_creator_from_config(config): | ||
updater_creator_config = UpdaterCreator(**config['updater_creator']) | ||
updater_creator = get_updater_creator( | ||
updater_creator_config.file, updater_creator_config.name, | ||
updater_creator_config.args) | ||
return updater_creator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from chainer.training import updater | ||
|
||
|
||
def updater_creator(iterator, optimizer, devices, *args, **kwargs): | ||
print(args) | ||
print(kwargs) | ||
return updater.StandardUpdater(iterator, optimizer, device=devices['main']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.