osl_dynamics.config_api.wrappers.train_hive#
- osl_dynamics.config_api.wrappers.train_hive(data, output_dir, config_kwargs, init_kwargs=None, fit_kwargs=None, save_inf_params=True)#
Train a
HIVE Model.This function will:
Build an
hive.Modelobject.Initialize the parameters of the HIVE model using the method set by
init_methodin the config (Model.initialization).Perform full training.
Save the inferred parameters (state probabilities, means, covariances and embeddings) if
save_inf_params=True.
This function will create two directories:
<output_dir>/model, which contains the trained model.<output_dir>/inf_params, which contains the inferred parameters. This directory is only created ifsave_inf_params=True.
- Parameters:
- dataosl_dynamics.data.Data
Data object for training the model.
- output_dirstr
Path to output directory.
- config_kwargsdict
Keyword arguments to pass to
osl_dynamics.models.hive.Config. Defaults to:{ 'sequence_length': 200, 'spatial_embeddings_dim': 2, 'dev_n_layers': 5, 'dev_n_units': 32, 'dev_activation': 'tanh', 'dev_normalization': 'layer', 'dev_regularizer': 'l1', 'dev_regularizer_factor': 10, 'batch_size': 128, 'learning_rate': 0.005, 'lr_decay': 0.1, 'n_epochs': 30, 'do_kl_annealing': True, 'kl_annealing_curve': 'tanh', 'kl_annealing_sharpness': 10, 'n_kl_annealing_epochs': 15, }.
- init_kwargsdict, optional
Keyword arguments to pass to the initialization method (
Model.initialization). Defaults to:{'n_init': 10, 'n_epochs': 2}.
- fit_kwargsdict, optional
Keyword arguments to pass to the
Model.fit. No defaults.- save_inf_paramsbool, optional
Should we save the inferred parameters?