def register_algorithms_and_preprocessors(self): try: from custom.algorithms import CUSTOM_ALGORITHMS from custom.preprocessors import CUSTOM_PREPROCESSORS from custom.models.impala_cnn_tf import ImpalaCNN except ModuleNotFoundError: from algorithms import CUSTOM_ALGORITHMS from preprocessors import CUSTOM_PREPROCESSORS from models.impala_cnn_tf import ImpalaCNN load_algorithms(CUSTOM_ALGORITHMS) load_preprocessors(CUSTOM_PREPROCESSORS) ModelCatalog.register_custom_model("impala_cnn_tf", ImpalaCNN)
def register_algorithms_and_preprocessors(self): # TODO(annaluo@): register custom model via dynamic sourcing try: from custom.algorithms import CUSTOM_ALGORITHMS from custom.preprocessors import CUSTOM_PREPROCESSORS from custom.models.my_vision_network import MyVisionNetwork except ModuleNotFoundError: from algorithms import CUSTOM_ALGORITHMS from preprocessors import CUSTOM_PREPROCESSORS from models.my_vision_network import MyVisionNetwork load_algorithms(CUSTOM_ALGORITHMS) load_preprocessors(CUSTOM_PREPROCESSORS) ModelCatalog.register_custom_model("my_vision_network", MyVisionNetwork)
Training example: python ./train.py --run DQN --env CartPole-v0 Training with Config: python ./train.py -f experiments/simple-corridor-0.yaml Note that -f overrides all other trial-specific command-line options. """ # Register all necessary assets in tune registries load_envs(os.getcwd()) # Load envs load_models(os.getcwd()) # Load models # Load custom algorithms from algorithms import CUSTOM_ALGORITHMS load_algorithms(CUSTOM_ALGORITHMS) print(ray.rllib.contrib.registry.CONTRIBUTED_ALGORITHMS) ####################################################################################################### ##################################### Helper Funcs ################################################# ####################################################################################################### def create_parser(parser_creator=None): parser = make_parser(parser_creator=parser_creator, formatter_class=argparse.RawDescriptionHelpFormatter, description="Train a reinforcement learning agent.", epilog=EXAMPLE_USAGE) # See also the base parser definition in ray/tune/config_parser.py