hydra_train
allennlp_hydra.commands.hydra_train
The hydra-train creates an AllenNLP config by composing a set of yaml files
with Hydra's Compose API then
passing it to AllenNLP's train method.
Overriding using Hydra's Override Grammar
is also supported.
The hydra-train command uses the underlying functionality of the
compose command. So the
use that documentation for understanding the composition of .yaml files.
Parameters¶
-
config_path :
Union[str, PathLike]
Path to the root config directory. -
config_name :
str
The name of the root config file. Do NOT include the.yaml. -
job_name :
str
The job name. This is passed to Hydra and is not used here. -
-s/--serialization-dir :
Union[str, PathLike]
The directory where everything is saved. -
-r/--recover :
bool, optional (default =False)
Flag. Recover training from the state inserialization_dir -
-f/--force :
bool, optional (default =False)
Flag. Overwrite the output directory if it exists. -
--node-rank :
int, optional (default =0)
The rank of this node in the distributed setup -
--dry-run :
bool, optional (default =False)
Flag. Do not train the model, but create a vocabulary, show dataset statistics and other training information -
--file-friendly-logging :
bool, optional (default =False)
Flag. Outputs tqdm status on separate lines and slows tqdm refresh rate -
-o/--overrides :
List[str], optional (default =[])
Keyword arguments passed will be used as a list of overrides using Hydra's override grammar for the config.Example usage:
Will be interpreted as overrides--overrides A=B C="D"['A=B', 'C="D"']
HydraTrain#
@Subcommand.register("hydra-train")
class HydraTrain(Subcommand)
add_subparser#
class HydraTrain(Subcommand):
| ...
| @overrides
| def add_subparser(
| self,
| parser: argparse._SubParsersAction
| ) -> argparse.ArgumentParser
hydra_train_model_from_args#
def hydra_train_model_from_args(args: argparse.Namespace)
Just converts from an argparse.Namespace object to string paths.