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 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) # Load custom preprocessors from preprocessors import CUSTOM_PREPROCESSORS load_preprocessors(CUSTOM_PREPROCESSORS) print(ray.rllib.contrib.registry.CONTRIBUTED_ALGORITHMS) 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 parser.add_argument( "--ray-address", default=None, type=str,
EXAMPLE_USAGE = """ 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_preprocessors(os.getcwd()) # Load preprocessors 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 parser.add_argument( "--ray-address", default=None, type=str, help="Connect to an existing Ray cluster at this address instead " "of starting a new one.")