returnn.__main__¶
Main entry point¶
This is the main entry point, providing main().
See init_config() for some arguments, or just run ./rnn.py --help.
See Technological Overview for a technical overview.
- returnn.__main__.init_config(config_filename: str | None = None, command_line_options: Sequence[str] = (), default_config: Dict[str, Any] | None = None, extra_updates: Dict[str, Any] | None = None)[source]¶
- Parameters:
config_filename
command_line_options – e.g.
sys.argv[1:]default_config
extra_updates
Initializes the global config. There are multiple sources which are used to init the config:
configFilename, and maybe first item ofcommandLineOptionsinterpret as config filenameother options via
commandLineOptionsextra_updates
Note about the order/priority of these:
extra_updatesoptions from
commandLineOptionsconfigFilenameconfig filename from
commandLineOptions[0]extra_updatesoptions from
commandLineOptions
extra_updatesandcommandLineOptionsare used twice so that they are available when the config is loaded, which thus has access to them, and can e.g. use them via Python code. However, the purpose is that they overwrite any option from the config; that is why we apply them again in the end.commandLineOptionsis applied afterextra_updatesso that the user has still the possibility to overwrite anything set byextra_updates.
- returnn.__main__.get_cache_byte_sizes()[source]¶
- Return type:
(int,int,int)
:returns cache size in bytes for (train,dev,eval)
- returnn.__main__.load_data(config, cache_byte_size, files_config_key, **kwargs)[source]¶
- Parameters:
config (Config)
cache_byte_size (int)
files_config_key (str) – such as “train” or “dev”
kwargs – passed on to init_dataset() or init_dataset_via_str()
- Return type:
(Dataset,int)
:returns the dataset, and the cache byte size left over if we cache the whole dataset.
- returnn.__main__.setup_dummy_datasets()[source]¶
setup config to use
DummyGenericDatasetinstead of the normal datasets
- returnn.__main__.init_engine()[source]¶
Initializes global
engine, for examplereturnn.tf.engine.Engine.
- returnn.__main__.returnn_greeting(config_filename=None, command_line_options=None)[source]¶
Prints some RETURNN greeting to the log.
- Parameters:
config_filename (str|None)
command_line_options (list[str]|None)
- returnn.__main__.init_backend_engine(*, config_opts: Dict[str, Any] | None = None)[source]¶
Selects the backend engine (TensorFlow, PyTorch, Theano, or whatever) and does corresponding initialization and preparation.
This does not initialize the global
engineobject yet. Seeinit_engine()for that.This also initializes a new config, if it was not initialized yet, and allows to update it via
config_opts.- Parameters:
config_opts – to update the global config
- returnn.__main__.init(config_filename=None, command_line_options=(), config_updates=None, extra_greeting=None)[source]¶
- Parameters:
config_filename (str|None)
command_line_options (tuple[str]|list[str]|None) – e.g. sys.argv[1:]
config_updates (dict[str]|None) – see
init_config()extra_greeting (str|None)
- returnn.__main__.finalize(error_occurred=False)[source]¶
Cleanup at the end.
- Parameters:
error_occurred (bool)
- returnn.__main__.need_data() bool[source]¶
- Returns:
whether we need to init the data (call
init_data()) for the current task (execute_main_task())