pydgn.experiment

experiment.experiment

class pydgn.experiment.experiment.Experiment(model_configuration: dict, exp_path: str, exp_seed: int)

Bases: object

Class that handles a single experiment.

Parameters
  • model_configuration (dict) – the dictionary holding the experiment-specific configuration

  • exp_path (str) – path to the experiment folder

  • exp_seed (int) – the experiment’s seed to use

create_incremental_engine(model: pydgn.model.interface.ModelInterface) pydgn.training.engine.TrainingEngine

Instantiates the training engine by using the layer_config key in the config file

Parameters

model – the model that needs be trained

Returns

a TrainingEngine object

create_incremental_model(dim_node_features: int, dim_edge_features: int, dim_target: int, depth: int, prev_outputs_to_consider: List[int]) pydgn.model.interface.ModelInterface

Instantiates a layer of an incremental architecture. It assumes the config file has a field layer_config and another layer_config.arbitrary_function_config that holds any kind of information for the arbitrary function of an incremental architecture

Parameters
  • dim_node_features – input node features

  • dim_edge_features – input edge features

  • dim_target – target size

  • depth – current depth of the architecture

  • prev_outputs_to_consider – A list of previous layers to consider, e.g. [1,2] means the last two previous layers.

Returns

a layer of a model that implements the ModelInterface interface

create_supervised_engine(model: pydgn.model.interface.ModelInterface) pydgn.training.engine.TrainingEngine

Instantiates the training engine by using the supervised_config key in the config file

Parameters

model – the model that needs be trained

Returns

a TrainingEngine object

create_supervised_model(dim_node_features: int, dim_edge_features: int, dim_target: int) pydgn.model.interface.ModelInterface

Instantiates a supervised model that implements the ModelInterface interface, using the supervised_config field in the configuration file.

Parameters
  • dim_node_features (int) – number of node features

  • dim_edge_features (int) – number of edge features

  • dim_target (int) – target dimension

Returns

a model that implements the ModelInterface interface

create_supervised_readout(dim_node_features: int, dim_edge_features: int, dim_target: int) pydgn.model.interface.ReadoutInterface

Instantiates an supervised readout that implements the ReadoutInterface interface, using the supervised_config field in the configuration file.

Parameters
  • dim_node_features (int) – number of node features

  • dim_edge_features (int) – number of edge features

  • dim_target (int) – target dimension

Returns

a model that implements the ReadoutInterface interface

create_unsupervised_engine(model: pydgn.model.interface.ModelInterface) pydgn.training.engine.TrainingEngine

Instantiates the training engine by using the unsupervised_config key in the config file

Parameters

model – the model that needs be trained

Returns

a TrainingEngine object

create_unsupervised_model(dim_node_features: int, dim_edge_features: int, dim_target: int) pydgn.model.interface.ModelInterface

Instantiates an unsupervised model that implements the ModelInterface interface, using the unsupervised_config field in the configuration file.

Parameters
  • dim_node_features (int) – number of node features

  • dim_edge_features (int) – number of edge features

  • dim_target (int) – target dimension

Returns

a model that implements the ModelInterface interface

run_test(dataset_getter: pydgn.data.provider.DataProvider, logger: pydgn.log.logger.Logger) Tuple[dict, dict, dict]

This function returns the training, validation and test results for a final run. Do not use the test to train the model nor for early stopping reasons! If possible, rely on already available subclasses of this class.

Parameters
Returns

  • LOSS (as defined in pydgn.static)

  • SCORE (as defined in pydgn.static)

For instance, training_results[SCORE] is a dictionary itself with other fields to be used by the evaluator.

Return type

a tuple of training,validation,test dictionaries. Each dictionary has two keys

run_valid(dataset_getter, logger) Tuple[dict, dict]

This function returns the training and validation results for a model selection run. Do not attempt to load the set inside this method! If possible, rely on already available subclasses of this class.

Parameters
Returns

  • LOSS (as defined in pydgn.static)

  • SCORE (as defined in pydgn.static)

For instance, training_results[SCORE] is a dictionary itself with other fields to be used by the evaluator.

Return type

a tuple of training and test dictionaries. Each dictionary has two keys

experiment.semi_supervised_task

class pydgn.experiment.semi_supervised_task.SemiSupervisedTask(model_configuration, exp_path, exp_seed)

Bases: pydgn.experiment.experiment.Experiment

Class that implements a semi-supervised experiment. There is an unsupervised_config field in the configuration file that is used, together with the field model, to produce unsupervised embeddings. These are later used by a readout extracted from a supervised_config field in the configuration file to perform the supervised task.

run_test(dataset_getter, logger)

This function returns the training, validation and test results for a final run. Do not use the test to train the model nor for early stopping reasons! If possible, rely on already available subclasses of this class.

Parameters
Returns

  • LOSS (as defined in pydgn.static)

  • SCORE (as defined in pydgn.static)

For instance, training_results[SCORE] is a dictionary itself with other fields to be used by the evaluator.

Return type

a tuple of training,validation,test dictionaries. Each dictionary has two keys

run_valid(dataset_getter, logger)

This function returns the training and validation results for a model selection run. Do not attempt to load the set inside this method! If possible, rely on already available subclasses of this class.

Parameters
Returns

  • LOSS (as defined in pydgn.static)

  • SCORE (as defined in pydgn.static)

For instance, training_results[SCORE] is a dictionary itself with other fields to be used by the evaluator.

Return type

a tuple of training and test dictionaries. Each dictionary has two keys

experiment.supervised_task

class pydgn.experiment.supervised_task.SupervisedTask(model_configuration: dict, exp_path: str, exp_seed: int)

Bases: pydgn.experiment.experiment.Experiment

Class that implements a standard supervised experiment.

run_test(dataset_getter, logger)

This function returns the training, validation and test results for a final run. Do not use the test to train the model nor for early stopping reasons! If possible, rely on already available subclasses of this class.

Parameters
Returns

  • LOSS (as defined in pydgn.static)

  • SCORE (as defined in pydgn.static)

For instance, training_results[SCORE] is a dictionary itself with other fields to be used by the evaluator.

Return type

a tuple of training,validation,test dictionaries. Each dictionary has two keys

run_valid(dataset_getter, logger)

This function returns the training and validation results for a model selection run. Do not attempt to load the set inside this method! If possible, rely on already available subclasses of this class.

Parameters
Returns

  • LOSS (as defined in pydgn.static)

  • SCORE (as defined in pydgn.static)

For instance, training_results[SCORE] is a dictionary itself with other fields to be used by the evaluator.

Return type

a tuple of training and test dictionaries. Each dictionary has two keys

experiment.util

pydgn.experiment.util.s2c(class_name: str) Callable[[...], object]

Converts a dotted path to the corresponding class

Parameters

class_name (str) – dotted path to class name

Returns

the class to be used