From 992066cb75aa3d456563e4adc8b026f6b0ec79e3 Mon Sep 17 00:00:00 2001 From: tkornut Date: Wed, 29 May 2019 11:48:30 -0700 Subject: [PATCH 1/7] First changes, added loading of default configs to workers, starting to clean up all default variable definitions in worker source files --- configs/default/workers/online_trainer.yml | 19 ++++++++++++++++ configs/default/workers/processor.yml | 8 +++++++ ptp/components/component.py | 25 +++++++--------------- ptp/configuration/config_parsing.py | 4 ++-- ptp/workers/online_trainer.py | 10 +++------ ptp/workers/processor.py | 8 ++----- ptp/workers/trainer.py | 8 ++++--- ptp/workers/worker.py | 24 ++++++++++++--------- 8 files changed, 61 insertions(+), 45 deletions(-) create mode 100644 configs/default/workers/online_trainer.yml create mode 100644 configs/default/workers/processor.yml diff --git a/configs/default/workers/online_trainer.yml b/configs/default/workers/online_trainer.yml new file mode 100644 index 0000000..d4623eb --- /dev/null +++ b/configs/default/workers/online_trainer.yml @@ -0,0 +1,19 @@ +# Default name of section used for training. +# One can change this, but must remember to define all the required parameters in the new section. +training_section_name: training + +# Default name of section used for validation. +# One can change this, but must remember to define all the required parameters in the new section. +validation_section_name: validation + +# Section defining all the default values of parameters used during training. +training: + + # Terminal conditions that will be used during training. + # They can (and ofter should) be overwritten. + terminal_conditions: + + + +# Section defining all the default values of parameters used during training. +validation: diff --git a/configs/default/workers/processor.yml b/configs/default/workers/processor.yml new file mode 100644 index 0000000..862ca8b --- /dev/null +++ b/configs/default/workers/processor.yml @@ -0,0 +1,8 @@ +# Default name of section used - we assume it will be test +# One can change this, but must remember to define all the required parameters in the new section. +# Note: this can also be changed by setting command line argument (--set) +section_name: test + +# Section defining all the default values of parameters used during testing. +test: + diff --git a/ptp/components/component.py b/ptp/components/component.py index e6a882a..f0e0f5c 100644 --- a/ptp/components/component.py +++ b/ptp/components/component.py @@ -30,23 +30,14 @@ class Component(abc.ABC): def __init__(self, name, class_type, config): """ - Initializes the component. - - This constructor: - - - stores a pointer to ``config``: - - >>> self.config = config - - - sets a problem name: - - >>> self.name = name - - - initializes the logger. - - - sets the access to ``AppState``: for dtype, visualization flag etc. - - >>> self.app_state = AppState() + Initializes the component. This constructor: + + - sets the access to ``AppState`` (for dtypes, settings, globals etc.) + - stores the component name and type + - stores reference to the passed configuration registry section + - loads default component parameters + - initializes the logger + - initializes mapping facilities and facades :param name: Name of the component. diff --git a/ptp/configuration/config_parsing.py b/ptp/configuration/config_parsing.py index 7d20f4c..6b4cced 100644 --- a/ptp/configuration/config_parsing.py +++ b/ptp/configuration/config_parsing.py @@ -121,12 +121,12 @@ def load_class_default_config_file(class_type): # Extract path to default config. module = class_type.__module__.replace(".","/") rel_path = module[module.find("ptp")+4:] - # Build the abs path to the default config file of a given component. + # Build the abs path to the default config file of a given component/worker. abs_default_config = os.path.join(AppState().absolute_config_path, "default", rel_path) + ".yml" # Check if file exists. if not os.path.isfile(abs_default_config): - print("ERROR: The default configuration file '{}' for '{}' component does not exist".format(abs_default_config, class_type.__module__)) + print("ERROR: The default configuration file '{}' for '{}' does not exist".format(abs_default_config, class_type.__module__)) exit(-1) try: diff --git a/ptp/workers/online_trainer.py b/ptp/workers/online_trainer.py index 77e42fc..cca4254 100644 --- a/ptp/workers/online_trainer.py +++ b/ptp/workers/online_trainer.py @@ -39,16 +39,12 @@ class OnlineTrainer(Trainer): """ - def __init__(self, name="OnlineTrainer"): + def __init__(self): """ - Only calls the ``Trainer`` constructor as the initialization phase is identical to the ``Trainer``. - - :param name: Name of the worker (DEFAULT: "OnlineTrainer"). - :type name: str - + Constructor. It on calls the ``Trainer`` constructor as the initialization phase is identical to the one from ``Trainer``. """ # Call base constructor to set up app state, registry and add default config. - super(OnlineTrainer, self).__init__(name) + super(OnlineTrainer, self).__init__("OnlineTrainer", OnlineTrainer) def setup_experiment(self): """ diff --git a/ptp/workers/processor.py b/ptp/workers/processor.py index 6974231..ccc3d05 100644 --- a/ptp/workers/processor.py +++ b/ptp/workers/processor.py @@ -42,16 +42,12 @@ class Processor(Worker): """ - def __init__(self, name="Processor"): + def __init__(self): """ Calls the ``Worker`` constructor, adds some additional arguments to parser. - - :param name: Name of the worker (DEFAULT: "Processor"). - :type name: str - """ # Call base constructor to set up app state, registry and add default params. - super(Processor, self).__init__(name) + super(Processor, self).__init__("Processor", Processor) self.parser.add_argument( '--set', diff --git a/ptp/workers/trainer.py b/ptp/workers/trainer.py index 56e72c6..fc10428 100644 --- a/ptp/workers/trainer.py +++ b/ptp/workers/trainer.py @@ -45,18 +45,20 @@ class Trainer(Worker): """ - def __init__(self, name="Trainer"): + def __init__(self, name, class_type): """ Base constructor for all trainers: - Adds default trainer command line arguments - :param name: Name of the worker (DEFAULT: "Trainer"). + :param name: Name of the worker :type name: str + :param class_type: Class type of the component. + """ # Call base constructor to set up app state, registry and add default arguments. - super(Trainer, self).__init__(name) + super(Trainer, self).__init__(name, class_type) # Add arguments to the specific parser. # These arguments will be shared by all basic trainers. diff --git a/ptp/workers/worker.py b/ptp/workers/worker.py index b69c4d4..ccf03f7 100644 --- a/ptp/workers/worker.py +++ b/ptp/workers/worker.py @@ -25,7 +25,9 @@ import ptp.utils.logger as logging from ptp.utils.app_state import AppState + from ptp.configuration.config_interface import ConfigInterface +from ptp.configuration.config_parsing import load_class_default_config_file class Worker(object): @@ -34,23 +36,20 @@ class Worker(object): All base workers should subclass it and override the relevant methods. """ - def __init__(self, name, add_default_parser_args = True): + def __init__(self, name, class_type, add_default_parser_args = True): """ Base constructor for all workers: - - Initializes the AppState singleton: - - >>> self.app_state = AppState() - - - Initializes the Configuration Registry: - - >>> self.config = ConfigInterface() - - - Creates parser and adds default worker command line arguments. + - Initializes the AppState singleton + - Initializes the Configuration Registry + - Loads default parameters + - Creates parser and adds default worker command line arguments :param name: Name of the worker. :type name: str + :param class_type: Class type of the component. + :param add_default_parser_args: If set, adds default parser arguments (DEFAULT: True). :type add_default_parser_args: bool @@ -67,6 +66,11 @@ def __init__(self, name, add_default_parser_args = True): # Initialize parameter interface/registry. self.config = ConfigInterface() + # Load default configuration. + if class_type is not None: + self.config.add_default_params(load_class_default_config_file(class_type)) + + # Create parser with a list of runtime arguments. self.parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter) From d7f0b49e2a1e03c4d0c4d6fb9e3c22b9993608c5 Mon Sep 17 00:00:00 2001 From: tkornut Date: Wed, 29 May 2019 13:47:29 -0700 Subject: [PATCH 2/7] moved all params from online-trainer to default config --- configs/default/workers/online_trainer.yml | 32 +++++++++++++++++++++- ptp/workers/online_trainer.py | 20 ++++++-------- ptp/workers/worker.py | 7 ----- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/configs/default/workers/online_trainer.yml b/configs/default/workers/online_trainer.yml index d4623eb..284f9e0 100644 --- a/configs/default/workers/online_trainer.yml +++ b/configs/default/workers/online_trainer.yml @@ -9,11 +9,41 @@ validation_section_name: validation # Section defining all the default values of parameters used during training. training: + # Set the random seeds: -1 means that they will be picked randomly. + # Note: their final values will be stored in the final training_configuration.yml saved to log dir. + seed_numpy: -1 + seed_torch: -1 + + # Definition of the problem (Mandatory!) + # problem: + # The rest of the content of that section is problem specific. + + # Section describing curriculum learning (Optional) + #curriculum_learning: + # # Flag indicating whether curriculum learning has to finish before (eventual) termination of the training. + # must_finish: True + # The rest of the content of that section is problem specific. + + # Terminal conditions that will be used during training. # They can (and ofter should) be overwritten. terminal_conditions: - + # Terminal condition I: loss threshold, going below will terminate the training. + loss_stop': 0.00001 # 1e-5 + # Terminal condition II: maximal number of epochs (optional, -1 means that this condition is disabled) + epoch_limit: -1 + # Terminal condition III: maximal number of episodes (Mandatory for this trainer! Must be > 0) + episode_limit: 100000 # Section defining all the default values of parameters used during training. validation: + + # Defines how often the partial validation will be performed. + # In this trainer Partial Validation is mandatory, hence interval must be > 0. + partial_validation_interval: 100 + + # Definition of the problem (mandatory!) + # problem: + # The rest of the content of that section is problem specific. + diff --git a/ptp/workers/online_trainer.py b/ptp/workers/online_trainer.py index cca4254..0f45985 100644 --- a/ptp/workers/online_trainer.py +++ b/ptp/workers/online_trainer.py @@ -57,25 +57,22 @@ def setup_experiment(self): # Call base method to parse all command line arguments, load configuration, create problems and model etc. super(OnlineTrainer, self).setup_experiment() - ################# TERMINAL CONDITIONS ################# - log_str = 'Terminal conditions:\n' + '='*80 + "\n" - - # Terminal condition I: loss. - self.config['training']['terminal_conditions'].add_default_params({'loss_stop': 1e-5}) - self.loss_stop = self.config['training']['terminal_conditions']['loss_stop'] - log_str += " Setting Loss Stop threshold to {}\n".format(self.loss_stop) - # In this trainer Partial Validation is mandatory, hence interval must be > 0. - self.config['validation'].add_default_params({'partial_validation_interval': 100}) self.partial_validation_interval = self.config['validation']['partial_validation_interval'] if self.partial_validation_interval <= 0: self.logger.error("Episodic Trainer relies on Partial Validation, thus 'partial_validation_interval' must be a positive number!") exit(-4) else: - log_str += " Partial Validation activated with interval equal to {} episodes\n".format(self.partial_validation_interval) + self.logger.info("Partial Validation activated with interval equal to {} episodes\n".format(self.partial_validation_interval)) + + ################# TERMINAL CONDITIONS ################# + log_str = 'Terminal conditions:\n' + '='*80 + "\n" + + # Terminal condition I: loss. + self.loss_stop = self.config['training']['terminal_conditions']['loss_stop'] + log_str += " Setting Loss Stop threshold to {}\n".format(self.loss_stop) # Terminal condition II: max epochs. Optional. - self.config["training"]["terminal_conditions"].add_default_params({'epoch_limit': -1}) self.epoch_limit = self.config["training"]["terminal_conditions"]["epoch_limit"] if self.epoch_limit <= 0: log_str += " Termination based on Epoch Limit is disabled\n" @@ -89,7 +86,6 @@ def setup_experiment(self): log_str += " Epoch size in terms of training episodes: {}\n".format(self.epoch_size) # Terminal condition III: max episodes. Mandatory. - self.config["training"]["terminal_conditions"].add_default_params({'episode_limit': 100000}) self.episode_limit = self.config['training']['terminal_conditions']['episode_limit'] if self.episode_limit <= 0: self.logger.error("OnLine Trainer relies on episodes, thus 'episode_limit' must be a positive number!") diff --git a/ptp/workers/worker.py b/ptp/workers/worker.py index ccf03f7..3d93393 100644 --- a/ptp/workers/worker.py +++ b/ptp/workers/worker.py @@ -173,11 +173,6 @@ def setup_experiment(self): # For now do not add file handler, as path to logfile is not known yet. self.logger = logging.initialize_logger(self.name, False) - # add empty sections - self.config.add_default_params({"training": {'terminal_conditions': {}}}) - self.config.add_default_params({"validation": {}}) - self.config.add_default_params({"testing": {}}) - def add_statistics(self, stat_col): """ @@ -304,7 +299,6 @@ def set_random_seeds(self, section_name, config): """ # Set the random seeds: either from the loaded configuration or a default randomly selected one. - config.add_default_params({"seed_numpy": -1}) if config["seed_numpy"] == -1: seed = randrange(0, 2 ** 32) # Overwrite the config param! @@ -313,7 +307,6 @@ def set_random_seeds(self, section_name, config): self.logger.info("Setting numpy random seed in {} to: {}".format(section_name, config["seed_numpy"])) np.random.seed(config["seed_numpy"]) - config.add_default_params({"seed_torch": -1}) if config["seed_torch"] == -1: seed = randrange(0, 2 ** 32) # Overwrite the config param! From 3e8c6784d60e52ff99ddc77a23ad0093078ca7a6 Mon Sep 17 00:00:00 2001 From: tkornut Date: Wed, 29 May 2019 16:54:19 -0700 Subject: [PATCH 3/7] OnlineTrainer refactored - using values from the default config, cleanups in configuration files --- configs/default/workers/online_trainer.yml | 84 +++++++++++++++++-- configs/mnist/default_mnist.yml | 6 +- .../mnist_classification_convnet_softmax.yml | 1 - .../mnist_classification_kfold_softmax.yml | 7 +- configs/mnist/mnist_classification_lenet5.yml | 1 - .../mnist/mnist_classification_softmax.yml | 1 - .../mnist/mnist_classification_vf_2lenet5.yml | 2 +- .../mnist/mnist_classification_vf_lenet5.yml | 2 +- ...mnist_classification_vf_lenet5_2losses.yml | 2 +- ...ification_vf_shared_convnet_2softmaxes.yml | 4 +- .../eng_fra_translation_enc_attndec.yml | 3 +- ...c1_classification_all_bow_vgg16_concat.yml | 1 - ...c1_classification_all_rnn_vgg16_concat.yml | 1 - .../c1_classification_image_cnn_softmax.yml | 1 - .../c1_classification_image_size_softmax.yml | 1 - .../c1_classification_question_mimic_rnn.yml | 1 - .../c1_classification_question_onehot_bow.yml | 1 - .../c1_classification_question_rnn.yml | 1 - ...question_rnn_separate_q_categorization.yml | 1 - ...c3_classification_all_bow_vgg16_concat.yml | 1 - .../c3_classification_all_concat.yml | 1 - ...c3_classification_all_rnn_vgg16_concat.yml | 1 - .../c3_classification_image_cnn_softmax.yml | 1 - ..._classification_image_plus_size_concat.yml | 1 - .../c3_classification_image_size_softmax.yml | 1 - .../c3_classification_image_softmax.yml | 1 - .../c3_classification_image_vgg16_softmax.yml | 1 - .../c3_classification_question_onehot_bow.yml | 1 - .../c3_classification_question_rnn.yml | 1 - ..._classification_all_rnn_vgg16_ewm_size.yml | 1 - .../c4_classification/c4_enc_attndec.yml | 1 - .../c4_frozen_if_gru_dec.yml | 2 +- configs/vqa_med_2019/default_vqa_med_2019.yml | 6 +- ...snet50_coattn_mfb_is_cat_ffn_c123_loss.yml | 2 +- ...vgg16_coattn_mfb_is_cat_ffn_c1234_loss.yml | 2 +- ...ic_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml | 2 +- .../evaluation/frozen_if_ffn_c1234_loss.yml | 2 +- .../evaluation/frozen_if_ffn_c123_loss.yml | 2 +- .../frozen_if_vf_5ffn_c1234yn_5losses.yml | 2 +- ...zen_if_vf_5ffn_support_c1234yn_5losses.yml | 2 +- ...stm_resnet152_att_is_cat_ffn_c123_loss.yml | 2 +- ...stm_resnet152_mcb_is_cat_ffn_c123_loss.yml | 2 +- ...ve_lstm_vgg16_att_is_cat_ffn_c123_loss.yml | 2 +- ...ve_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml | 2 +- ...ve_lstm_vgg16_mcb_is_cat_ffn_c123_loss.yml | 2 +- .../input_fusion_processor_io.yml | 1 - .../question_categorization_onehot_bow.yml | 1 - .../question_categorization_onehot_rnn.yml | 1 - .../question_categorization_rnn.yml | 1 - .../question_categorization_rnn_ffn.yml | 1 - ...rd_shared_question_rnn_two_ffns_losses.yml | 5 +- ...nn_shared_all_encoders_two_ffns_losses.yml | 5 +- ...nn_shared_question_rnn_two_ffns_losses.yml | 1 - ...n_shared_all_encoders_four_ffns_losses.yml | 1 - ..._shared_all_encoders_three_ffns_losses.yml | 1 - ..._language_modeling_encoder_attndecoder.yml | 3 +- .../wikitext_language_modeling_rnn.yml | 3 +- .../wikitext_language_modeling_seq2seq.yml | 3 +- ...itext_language_modeling_seq2seq_simple.yml | 3 +- .../dummy_language_identification_bow.yml | 3 +- .../wily/wily_language_identification_bow.yml | 8 +- configs/wily/wily_ngram_language_modeling.yml | 7 +- ptp/application/problem_manager.py | 33 ++------ ptp/application/sampler_factory.py | 6 -- ptp/workers/online_trainer.py | 24 ++++-- ptp/workers/trainer.py | 69 ++++++++++----- 66 files changed, 192 insertions(+), 153 deletions(-) diff --git a/configs/default/workers/online_trainer.yml b/configs/default/workers/online_trainer.yml index 284f9e0..55b0e3c 100644 --- a/configs/default/workers/online_trainer.yml +++ b/configs/default/workers/online_trainer.yml @@ -6,30 +6,67 @@ training_section_name: training # One can change this, but must remember to define all the required parameters in the new section. validation_section_name: validation +# Default name of section containing pipeline definition. +# One can change this, but must remember to define all the required parameters in the new section. +pipeline_section_name: pipeline + + + # Section defining all the default values of parameters used during training. training: - # Set the random seeds: -1 means that they will be picked randomly. # Note: their final values will be stored in the final training_configuration.yml saved to log dir. seed_numpy: -1 seed_torch: -1 + # Default batch size. + batch_size: 64 + # Definition of the problem (Mandatory!) - # problem: - # The rest of the content of that section is problem specific. + #problem: + # One must define its type (Mandatory!) + # type: ? + # The rest of the content of that section is problem-specific... # Section describing curriculum learning (Optional) #curriculum_learning: # # Flag indicating whether curriculum learning has to finish before (eventual) termination of the training. # must_finish: True - # The rest of the content of that section is problem specific. + # The rest of the content of that section is problem-specific... + + # Definition of optimizer (Mandatory!) + #optimizer: + # # Type - generally all optimizers from PyTorch.optim are allowed (Mandatory!) + # type: Adam + # # Options: + # lr: 0.0001 + # The rest of the content of that section is optimizer-specific... + # Set a default configuration section for data loader. + dataloader: + # Shuffle set by default. + shuffle: True + batch_sampler: None + # Do not use multiprocessing by default. + num_workers: 0 + pin_memory: False + # Do not drop last frame by default. + drop_last: False + timeout: 0 + + # Definition of sampler (Optional) + # When this section will not be present, worker will use "standard" sampling (please refer to shuffle in dataloader) + #sampler: + # # Type - generally all samplers from PyTorch (plus some new onses) are allowed (Mandatory!) + # # Options: + # type: RandomSmpler + # The rest of the content of that section is optimizer-specific... # Terminal conditions that will be used during training. # They can (and ofter should) be overwritten. terminal_conditions: # Terminal condition I: loss threshold, going below will terminate the training. - loss_stop': 0.00001 # 1e-5 + loss_stop: 0.00001 # 1e-5 # Terminal condition II: maximal number of epochs (optional, -1 means that this condition is disabled) epoch_limit: -1 # Terminal condition III: maximal number of episodes (Mandatory for this trainer! Must be > 0) @@ -38,12 +75,43 @@ training: # Section defining all the default values of parameters used during training. validation: - # Defines how often the partial validation will be performed. # In this trainer Partial Validation is mandatory, hence interval must be > 0. partial_validation_interval: 100 # Definition of the problem (mandatory!) - # problem: - # The rest of the content of that section is problem specific. + #problem: + # One must define its type (Mandatory!) + # type: ? + # The rest of the content of that section is problem-specific... + + # Set a default configuration section for data loader. + dataloader: + # Shuffle set by default. + shuffle: True + # Do not use multiprocessing by default. + num_workers: 0 + pin_memory: False + # Do not drop last frame by default. + drop_last: False + timeout: 0 + + # Definition of sampler (Optional) + # When this section will not be present, worker will use "standard" sampling (please refer to shuffle in dataloader) + #sampler: + # # Type - generally all samplers from PyTorch (plus some new onses) are allowed (Mandatory!) + # # Options: + # type: RandomSmpler + # The rest of the content of that section is optimizer-specific... + +# Section defining the pipeline. +pipeline: + # Pipeline must contain at least one component. + #name_1: + # Each component must have defined its priority... (Mandatory!) + # priority: 0.1 # Can be float. Smaller means higher priority, up to zero. + # # ... and type (Mandatory!) + # type: ? + # The rest of the content of that section is component-specific... + diff --git a/configs/mnist/default_mnist.yml b/configs/mnist/default_mnist.yml index b3d57a3..b49f033 100644 --- a/configs/mnist/default_mnist.yml +++ b/configs/mnist/default_mnist.yml @@ -7,11 +7,11 @@ training: #resize: [32, 32] # Use sampler that operates on a subset. #sampler: - # name: SubsetRandomSampler + # type: SubsetRandomSampler # indices: [0, 55000] # optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # settings parameters terminal_conditions: @@ -29,7 +29,7 @@ validation: #resize: [32, 32] # Use sampler that operates on a subset. #sampler: - # name: SubsetRandomSampler + # type: SubsetRandomSampler # indices: [55000, 60000] # Testing parameters: diff --git a/configs/mnist/mnist_classification_convnet_softmax.yml b/configs/mnist/mnist_classification_convnet_softmax.yml index 67decc4..8b2580f 100644 --- a/configs/mnist/mnist_classification_convnet_softmax.yml +++ b/configs/mnist/mnist_classification_convnet_softmax.yml @@ -2,7 +2,6 @@ default_configs: mnist/default_mnist.yml pipeline: - name: mnist_convnet_softmax_classifier # Model consisting of two components. image_encoder: diff --git a/configs/mnist/mnist_classification_kfold_softmax.yml b/configs/mnist/mnist_classification_kfold_softmax.yml index 076d757..cfa0402 100644 --- a/configs/mnist/mnist_classification_kfold_softmax.yml +++ b/configs/mnist/mnist_classification_kfold_softmax.yml @@ -10,11 +10,11 @@ training: #resize: [32, 32] # Use k-fold cross-validation random sampler. sampler: - name: kFoldRandomSampler + type: kFoldRandomSampler folds: 7 # Each with size of 6000 # optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # settings parameters terminal_conditions: @@ -32,11 +32,10 @@ validation: #resize: [32, 32] # Use k-fold cross-validation random sampler. sampler: - name: kFoldRandomSampler + type: kFoldRandomSampler folds: 7 # Each with size of 6000 pipeline: - name: mnist_softmax_classifier # Reshapes tensors. reshaper: diff --git a/configs/mnist/mnist_classification_lenet5.yml b/configs/mnist/mnist_classification_lenet5.yml index ddd878b..65deca1 100644 --- a/configs/mnist/mnist_classification_lenet5.yml +++ b/configs/mnist/mnist_classification_lenet5.yml @@ -18,7 +18,6 @@ testing: # Definition of the pipeline. pipeline: - name: mnist_lenet5_classifier # Image classifier. image_classifier: diff --git a/configs/mnist/mnist_classification_softmax.yml b/configs/mnist/mnist_classification_softmax.yml index eaf749a..1875f42 100644 --- a/configs/mnist/mnist_classification_softmax.yml +++ b/configs/mnist/mnist_classification_softmax.yml @@ -2,7 +2,6 @@ default_configs: mnist/default_mnist.yml pipeline: - name: mnist_softmax_classifier # Reshapes tensors. reshaper: diff --git a/configs/mnist/mnist_classification_vf_2lenet5.yml b/configs/mnist/mnist_classification_vf_2lenet5.yml index 47be2dc..83e4970 100644 --- a/configs/mnist/mnist_classification_vf_2lenet5.yml +++ b/configs/mnist/mnist_classification_vf_2lenet5.yml @@ -18,7 +18,7 @@ testing: # Definition of the pipeline. pipeline: - name: mnist_variational_flow_2lenet5 + # Disable components for "default" flow. disable: nllloss, precision_recall diff --git a/configs/mnist/mnist_classification_vf_lenet5.yml b/configs/mnist/mnist_classification_vf_lenet5.yml index 625f73f..707d57a 100644 --- a/configs/mnist/mnist_classification_vf_lenet5.yml +++ b/configs/mnist/mnist_classification_vf_lenet5.yml @@ -18,7 +18,7 @@ testing: # Definition of the pipeline. pipeline: - name: mnist_variational_flow_lenet5 + # Disable components for "default" flow. disable: nllloss, precision_recall diff --git a/configs/mnist/mnist_classification_vf_lenet5_2losses.yml b/configs/mnist/mnist_classification_vf_lenet5_2losses.yml index f92dcae..69d53dc 100644 --- a/configs/mnist/mnist_classification_vf_lenet5_2losses.yml +++ b/configs/mnist/mnist_classification_vf_lenet5_2losses.yml @@ -18,7 +18,7 @@ testing: # Definition of the pipeline. pipeline: - name: mnist_variational_flow_lenet5 + # Disable components for "default" flow. disable: nllloss, precision_recall diff --git a/configs/mnist/mnist_classification_vf_shared_convnet_2softmaxes.yml b/configs/mnist/mnist_classification_vf_shared_convnet_2softmaxes.yml index 25e58cc..3185c52 100644 --- a/configs/mnist/mnist_classification_vf_shared_convnet_2softmaxes.yml +++ b/configs/mnist/mnist_classification_vf_shared_convnet_2softmaxes.yml @@ -7,7 +7,7 @@ training: #resize_image: [32, 32] batch_size: 64 #optimizer: - # #name: Adam + # #type: Adam # lr: 0.001 #terminal_conditions: # loss_stop: 0.08 @@ -25,7 +25,7 @@ training: # Definition of the pipeline. pipeline: - name: mnist_variational_flow_shared_convnet_2softmaxes + # Disable components for "default" flow. disable: nllloss, precision_recall diff --git a/configs/translation/eng_fra_translation_enc_attndec.yml b/configs/translation/eng_fra_translation_enc_attndec.yml index 2127b46..50d37ca 100644 --- a/configs/translation/eng_fra_translation_enc_attndec.yml +++ b/configs/translation/eng_fra_translation_enc_attndec.yml @@ -14,7 +14,7 @@ training: # optimizer parameters: optimizer: - name: Adam + type: Adam lr: 1.0e-3 # settings parameters @@ -45,7 +45,6 @@ testing: batch_size: 64 pipeline: - name: eng_fra_translation_enc_attndec # Source encoding - model 1. source_sentence_embedding: diff --git a/configs/vqa_med_2019/c1_classification/c1_classification_all_bow_vgg16_concat.yml b/configs/vqa_med_2019/c1_classification/c1_classification_all_bow_vgg16_concat.yml index a38067e..17d7b75 100644 --- a/configs/vqa_med_2019/c1_classification/c1_classification_all_bow_vgg16_concat.yml +++ b/configs/vqa_med_2019/c1_classification/c1_classification_all_bow_vgg16_concat.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c1_classification/default_c1_classification.yml pipeline: - name: vqa_med_c1_classification_all_bow_vgg16_concat global_publisher: type: GlobalVariablePublisher diff --git a/configs/vqa_med_2019/c1_classification/c1_classification_all_rnn_vgg16_concat.yml b/configs/vqa_med_2019/c1_classification/c1_classification_all_rnn_vgg16_concat.yml index 1560212..b8d9dfc 100644 --- a/configs/vqa_med_2019/c1_classification/c1_classification_all_rnn_vgg16_concat.yml +++ b/configs/vqa_med_2019/c1_classification/c1_classification_all_rnn_vgg16_concat.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c1_classification/default_c1_classification.yml pipeline: - name: vqa_med_c1_classification_all_rnn_vgg_concat global_publisher: type: GlobalVariablePublisher diff --git a/configs/vqa_med_2019/c1_classification/c1_classification_image_cnn_softmax.yml b/configs/vqa_med_2019/c1_classification/c1_classification_image_cnn_softmax.yml index 63625cd..623a5e4 100644 --- a/configs/vqa_med_2019/c1_classification/c1_classification_image_cnn_softmax.yml +++ b/configs/vqa_med_2019/c1_classification/c1_classification_image_cnn_softmax.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c1_classification/default_c1_classification.yml pipeline: - name: vqa_med_c1_classification_image_cnn_softmax # Image encoder. image_encoder: diff --git a/configs/vqa_med_2019/c1_classification/c1_classification_image_size_softmax.yml b/configs/vqa_med_2019/c1_classification/c1_classification_image_size_softmax.yml index 998d6b2..0201388 100644 --- a/configs/vqa_med_2019/c1_classification/c1_classification_image_size_softmax.yml +++ b/configs/vqa_med_2019/c1_classification/c1_classification_image_size_softmax.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c1_classification/default_c1_classification.yml pipeline: - name: vqa_med_c1_classification_image_size_softmax global_publisher: type: GlobalVariablePublisher diff --git a/configs/vqa_med_2019/c1_classification/c1_classification_question_mimic_rnn.yml b/configs/vqa_med_2019/c1_classification/c1_classification_question_mimic_rnn.yml index aea4592..4f137e1 100644 --- a/configs/vqa_med_2019/c1_classification/c1_classification_question_mimic_rnn.yml +++ b/configs/vqa_med_2019/c1_classification/c1_classification_question_mimic_rnn.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c1_classification/default_c1_classification.yml pipeline: - name: c1_classification_question_mimic_rnn # Questions encoding. question_tokenizer: diff --git a/configs/vqa_med_2019/c1_classification/c1_classification_question_onehot_bow.yml b/configs/vqa_med_2019/c1_classification/c1_classification_question_onehot_bow.yml index a1d9506..d879a86 100644 --- a/configs/vqa_med_2019/c1_classification/c1_classification_question_onehot_bow.yml +++ b/configs/vqa_med_2019/c1_classification/c1_classification_question_onehot_bow.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c1_classification/default_c1_classification.yml pipeline: - name: vqa_med_c1_classification_question_onehot_bow # Questions encoding. question_tokenizer: diff --git a/configs/vqa_med_2019/c1_classification/c1_classification_question_rnn.yml b/configs/vqa_med_2019/c1_classification/c1_classification_question_rnn.yml index 4c1d3a6..0beba15 100644 --- a/configs/vqa_med_2019/c1_classification/c1_classification_question_rnn.yml +++ b/configs/vqa_med_2019/c1_classification/c1_classification_question_rnn.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c1_classification/default_c1_classification.yml pipeline: - name: c1_classification_question_rnn # Questions encoding. question_tokenizer: diff --git a/configs/vqa_med_2019/c1_classification/c1_classification_vf_question_rnn_separate_q_categorization.yml b/configs/vqa_med_2019/c1_classification/c1_classification_vf_question_rnn_separate_q_categorization.yml index 7adf9b7..cce673d 100644 --- a/configs/vqa_med_2019/c1_classification/c1_classification_vf_question_rnn_separate_q_categorization.yml +++ b/configs/vqa_med_2019/c1_classification/c1_classification_vf_question_rnn_separate_q_categorization.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c1_classification/default_c1_classification.yml pipeline: - name: vqa_med_c1_classification_vf_question_rnn_separate_q_categorization ################# SHARED ################# diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_all_bow_vgg16_concat.yml b/configs/vqa_med_2019/c3_classification/c3_classification_all_bow_vgg16_concat.yml index 0a02d41..8d88cd9 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_all_bow_vgg16_concat.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_all_bow_vgg16_concat.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_all_bow_vgg_concat global_publisher: type: GlobalVariablePublisher diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_all_concat.yml b/configs/vqa_med_2019/c3_classification/c3_classification_all_concat.yml index c11c99f..668949c 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_all_concat.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_all_concat.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_all_concat global_publisher: type: GlobalVariablePublisher diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_all_rnn_vgg16_concat.yml b/configs/vqa_med_2019/c3_classification/c3_classification_all_rnn_vgg16_concat.yml index 3aa5410..15a94e9 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_all_rnn_vgg16_concat.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_all_rnn_vgg16_concat.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_all_rnn_vgg_concat global_publisher: type: GlobalVariablePublisher diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_image_cnn_softmax.yml b/configs/vqa_med_2019/c3_classification/c3_classification_image_cnn_softmax.yml index c2aa050..e93a77d 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_image_cnn_softmax.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_image_cnn_softmax.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_image_cnn_softmax # Image encoder. image_encoder: diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_image_plus_size_concat.yml b/configs/vqa_med_2019/c3_classification/c3_classification_image_plus_size_concat.yml index 250de0b..586fbe1 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_image_plus_size_concat.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_image_plus_size_concat.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_image_plus_size global_publisher: type: GlobalVariablePublisher diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_image_size_softmax.yml b/configs/vqa_med_2019/c3_classification/c3_classification_image_size_softmax.yml index 8e055c5..68491a2 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_image_size_softmax.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_image_size_softmax.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_image_size_softmax global_publisher: type: GlobalVariablePublisher diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_image_softmax.yml b/configs/vqa_med_2019/c3_classification/c3_classification_image_softmax.yml index c48a030..0b0405b 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_image_softmax.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_image_softmax.yml @@ -11,7 +11,6 @@ validation: pipeline: - name: vqa_med_c3_classification_image_softmax # Reshape inputs reshaper: diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_image_vgg16_softmax.yml b/configs/vqa_med_2019/c3_classification/c3_classification_image_vgg16_softmax.yml index 1882aca..03ceadd 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_image_vgg16_softmax.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_image_vgg16_softmax.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_image_vgg16_softmax # Image encoder. image_encoder: diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_question_onehot_bow.yml b/configs/vqa_med_2019/c3_classification/c3_classification_question_onehot_bow.yml index 6ef8b55..f6a0e3e 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_question_onehot_bow.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_question_onehot_bow.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_question_onehot_bow # Questions encoding. question_tokenizer: diff --git a/configs/vqa_med_2019/c3_classification/c3_classification_question_rnn.yml b/configs/vqa_med_2019/c3_classification/c3_classification_question_rnn.yml index 065a398..a79da98 100644 --- a/configs/vqa_med_2019/c3_classification/c3_classification_question_rnn.yml +++ b/configs/vqa_med_2019/c3_classification/c3_classification_question_rnn.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c3_classification/default_c3_classification.yml pipeline: - name: vqa_med_c3_classification_question_rnn # Questions encoding. question_tokenizer: diff --git a/configs/vqa_med_2019/c4_classification/c4_classification_all_rnn_vgg16_ewm_size.yml b/configs/vqa_med_2019/c4_classification/c4_classification_all_rnn_vgg16_ewm_size.yml index a68e97e..e6831f9 100644 --- a/configs/vqa_med_2019/c4_classification/c4_classification_all_rnn_vgg16_ewm_size.yml +++ b/configs/vqa_med_2019/c4_classification/c4_classification_all_rnn_vgg16_ewm_size.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/c4_classification/default_c4_classification.yml pipeline: - name: c4_classification_all_rnn_vgg16_ewm_size global_publisher: priority: 0 diff --git a/configs/vqa_med_2019/c4_classification/c4_enc_attndec.yml b/configs/vqa_med_2019/c4_classification/c4_enc_attndec.yml index d9347a0..8f106c0 100644 --- a/configs/vqa_med_2019/c4_classification/c4_enc_attndec.yml +++ b/configs/vqa_med_2019/c4_classification/c4_enc_attndec.yml @@ -30,7 +30,6 @@ validation: num_workers: 2 pipeline: - name: c4_dec_attndecoder # Question embeddings question_embeddings: diff --git a/configs/vqa_med_2019/c4_classification/c4_frozen_if_gru_dec.yml b/configs/vqa_med_2019/c4_classification/c4_frozen_if_gru_dec.yml index ea4425e..1b7dd1a 100644 --- a/configs/vqa_med_2019/c4_classification/c4_frozen_if_gru_dec.yml +++ b/configs/vqa_med_2019/c4_classification/c4_frozen_if_gru_dec.yml @@ -40,7 +40,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/default_vqa_med_2019.yml b/configs/vqa_med_2019/default_vqa_med_2019.yml index bd83a8f..ae570a1 100644 --- a/configs/vqa_med_2019/default_vqa_med_2019.yml +++ b/configs/vqa_med_2019/default_vqa_med_2019.yml @@ -12,7 +12,7 @@ training: # Default sampler during training. sampler: - name: kFoldWeightedRandomSampler + type: kFoldWeightedRandomSampler folds: 20 epochs_per_fold: 1000 # NEVER CHANGE FOLD! # Use four workers for loading images. @@ -21,7 +21,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: @@ -44,7 +44,7 @@ validation: # Default sampler during validation. sampler: - name: kFoldRandomSampler + type: kFoldRandomSampler folds: 20 epochs_per_fold: 1000 # NEVER CHANGE FOLD! # Use four workers for loading images. diff --git a/configs/vqa_med_2019/evaluation/deepta/glove_gru_resnet50_coattn_mfb_is_cat_ffn_c123_loss.yml b/configs/vqa_med_2019/evaluation/deepta/glove_gru_resnet50_coattn_mfb_is_cat_ffn_c123_loss.yml index e7010be..8c7f748 100644 --- a/configs/vqa_med_2019/evaluation/deepta/glove_gru_resnet50_coattn_mfb_is_cat_ffn_c123_loss.yml +++ b/configs/vqa_med_2019/evaluation/deepta/glove_gru_resnet50_coattn_mfb_is_cat_ffn_c123_loss.yml @@ -60,7 +60,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/deepta/glove_gru_vgg16_coattn_mfb_is_cat_ffn_c1234_loss.yml b/configs/vqa_med_2019/evaluation/deepta/glove_gru_vgg16_coattn_mfb_is_cat_ffn_c1234_loss.yml index 5e7a511..551f57c 100644 --- a/configs/vqa_med_2019/evaluation/deepta/glove_gru_vgg16_coattn_mfb_is_cat_ffn_c1234_loss.yml +++ b/configs/vqa_med_2019/evaluation/deepta/glove_gru_vgg16_coattn_mfb_is_cat_ffn_c1234_loss.yml @@ -60,7 +60,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/example_mimic_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml b/configs/vqa_med_2019/evaluation/example_mimic_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml index c65f07e..831e894 100644 --- a/configs/vqa_med_2019/evaluation/example_mimic_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml +++ b/configs/vqa_med_2019/evaluation/example_mimic_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml @@ -65,7 +65,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/frozen_if_ffn_c1234_loss.yml b/configs/vqa_med_2019/evaluation/frozen_if_ffn_c1234_loss.yml index 08a77b1..da7212f 100644 --- a/configs/vqa_med_2019/evaluation/frozen_if_ffn_c1234_loss.yml +++ b/configs/vqa_med_2019/evaluation/frozen_if_ffn_c1234_loss.yml @@ -43,7 +43,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/frozen_if_ffn_c123_loss.yml b/configs/vqa_med_2019/evaluation/frozen_if_ffn_c123_loss.yml index 138111f..e061c56 100644 --- a/configs/vqa_med_2019/evaluation/frozen_if_ffn_c123_loss.yml +++ b/configs/vqa_med_2019/evaluation/frozen_if_ffn_c123_loss.yml @@ -43,7 +43,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/frozen_if_vf_5ffn_c1234yn_5losses.yml b/configs/vqa_med_2019/evaluation/frozen_if_vf_5ffn_c1234yn_5losses.yml index 37366a7..1a072bd 100644 --- a/configs/vqa_med_2019/evaluation/frozen_if_vf_5ffn_c1234yn_5losses.yml +++ b/configs/vqa_med_2019/evaluation/frozen_if_vf_5ffn_c1234yn_5losses.yml @@ -43,7 +43,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/frozen_if_vf_5ffn_support_c1234yn_5losses.yml b/configs/vqa_med_2019/evaluation/frozen_if_vf_5ffn_support_c1234yn_5losses.yml index fc4ae57..62441f5 100644 --- a/configs/vqa_med_2019/evaluation/frozen_if_vf_5ffn_support_c1234yn_5losses.yml +++ b/configs/vqa_med_2019/evaluation/frozen_if_vf_5ffn_support_c1234yn_5losses.yml @@ -58,7 +58,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/tom/glove_lstm_resnet152_att_is_cat_ffn_c123_loss.yml b/configs/vqa_med_2019/evaluation/tom/glove_lstm_resnet152_att_is_cat_ffn_c123_loss.yml index 2eda9e1..038a565 100644 --- a/configs/vqa_med_2019/evaluation/tom/glove_lstm_resnet152_att_is_cat_ffn_c123_loss.yml +++ b/configs/vqa_med_2019/evaluation/tom/glove_lstm_resnet152_att_is_cat_ffn_c123_loss.yml @@ -66,7 +66,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/tom/glove_lstm_resnet152_mcb_is_cat_ffn_c123_loss.yml b/configs/vqa_med_2019/evaluation/tom/glove_lstm_resnet152_mcb_is_cat_ffn_c123_loss.yml index 2168aa4..5f937e7 100644 --- a/configs/vqa_med_2019/evaluation/tom/glove_lstm_resnet152_mcb_is_cat_ffn_c123_loss.yml +++ b/configs/vqa_med_2019/evaluation/tom/glove_lstm_resnet152_mcb_is_cat_ffn_c123_loss.yml @@ -64,7 +64,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_att_is_cat_ffn_c123_loss.yml b/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_att_is_cat_ffn_c123_loss.yml index 56a9544..cd2ec31 100644 --- a/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_att_is_cat_ffn_c123_loss.yml +++ b/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_att_is_cat_ffn_c123_loss.yml @@ -66,7 +66,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml b/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml index cff7147..0014c9e 100644 --- a/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml +++ b/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_ewm_is_cat_ffn_c123_loss.yml @@ -64,7 +64,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_mcb_is_cat_ffn_c123_loss.yml b/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_mcb_is_cat_ffn_c123_loss.yml index eb4fca5..1808c57 100644 --- a/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_mcb_is_cat_ffn_c123_loss.yml +++ b/configs/vqa_med_2019/evaluation/tom/glove_lstm_vgg16_mcb_is_cat_ffn_c123_loss.yml @@ -64,7 +64,7 @@ training: # Optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.0001 # Terminal conditions: diff --git a/configs/vqa_med_2019/frozen_pipelines/input_fusion_processor_io.yml b/configs/vqa_med_2019/frozen_pipelines/input_fusion_processor_io.yml index 0f8754d..542461e 100644 --- a/configs/vqa_med_2019/frozen_pipelines/input_fusion_processor_io.yml +++ b/configs/vqa_med_2019/frozen_pipelines/input_fusion_processor_io.yml @@ -31,7 +31,6 @@ hyperparams: # Add component for exporting answers to files. pipeline: - name: input_fusion_processor_io ################# PIPE 6: C1 + C2 + C3 questions ################# diff --git a/configs/vqa_med_2019/question_categorization/question_categorization_onehot_bow.yml b/configs/vqa_med_2019/question_categorization/question_categorization_onehot_bow.yml index ced3ad0..29baea5 100644 --- a/configs/vqa_med_2019/question_categorization/question_categorization_onehot_bow.yml +++ b/configs/vqa_med_2019/question_categorization/question_categorization_onehot_bow.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/question_categorization/default_question_categorization.yml pipeline: - name: vqa_med_question_categorization_onehot_bow # Questions encoding. question_tokenizer: diff --git a/configs/vqa_med_2019/question_categorization/question_categorization_onehot_rnn.yml b/configs/vqa_med_2019/question_categorization/question_categorization_onehot_rnn.yml index 7453afa..bb7b77d 100644 --- a/configs/vqa_med_2019/question_categorization/question_categorization_onehot_rnn.yml +++ b/configs/vqa_med_2019/question_categorization/question_categorization_onehot_rnn.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/question_categorization/default_question_categorization.yml pipeline: - name: vqa_med_question_categorization_onehot_rnn # Questions encoding. question_tokenizer: diff --git a/configs/vqa_med_2019/question_categorization/question_categorization_rnn.yml b/configs/vqa_med_2019/question_categorization/question_categorization_rnn.yml index 1fae119..8b53f64 100644 --- a/configs/vqa_med_2019/question_categorization/question_categorization_rnn.yml +++ b/configs/vqa_med_2019/question_categorization/question_categorization_rnn.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/question_categorization/default_question_categorization.yml pipeline: - name: vqa_med_question_categorization_rnn # Questions encoding. question_tokenizer: diff --git a/configs/vqa_med_2019/question_categorization/question_categorization_rnn_ffn.yml b/configs/vqa_med_2019/question_categorization/question_categorization_rnn_ffn.yml index d65d9f4..eb770d0 100644 --- a/configs/vqa_med_2019/question_categorization/question_categorization_rnn_ffn.yml +++ b/configs/vqa_med_2019/question_categorization/question_categorization_rnn_ffn.yml @@ -2,7 +2,6 @@ default_configs: vqa_med_2019/question_categorization/default_question_categorization.yml pipeline: - name: vqa_med_question_categorization_rnn_ffn # Add global variables. global_publisher: diff --git a/configs/vqa_med_2019/vf/c1_binary_vf_cat_hard_shared_question_rnn_two_ffns_losses.yml b/configs/vqa_med_2019/vf/c1_binary_vf_cat_hard_shared_question_rnn_two_ffns_losses.yml index 3640e73..adbc985 100644 --- a/configs/vqa_med_2019/vf/c1_binary_vf_cat_hard_shared_question_rnn_two_ffns_losses.yml +++ b/configs/vqa_med_2019/vf/c1_binary_vf_cat_hard_shared_question_rnn_two_ffns_losses.yml @@ -7,7 +7,7 @@ training: categories: C1 export_sample_weights: ~/data/vqa-med/answers.c1.weights.csv sampler: - name: kFoldWeightedRandomSampler + type: kFoldWeightedRandomSampler weights: ~/data/vqa-med/answers.c1.weights.csv folds: 5 dataloader: @@ -18,14 +18,13 @@ validation: problem: categories: C1 sampler: - name: kFoldRandomSampler + type: kFoldRandomSampler folds: 5 dataloader: num_workers: 4 pipeline: - name: c1_binary_vf_cat_hard_shared_question_rnn_two_ffns_losses ################# PIPE 0: SHARED ################# diff --git a/configs/vqa_med_2019/vf/c1_binary_vf_cat_rnn_shared_all_encoders_two_ffns_losses.yml b/configs/vqa_med_2019/vf/c1_binary_vf_cat_rnn_shared_all_encoders_two_ffns_losses.yml index 79d567f..1450d46 100644 --- a/configs/vqa_med_2019/vf/c1_binary_vf_cat_rnn_shared_all_encoders_two_ffns_losses.yml +++ b/configs/vqa_med_2019/vf/c1_binary_vf_cat_rnn_shared_all_encoders_two_ffns_losses.yml @@ -7,7 +7,7 @@ training: categories: C1 export_sample_weights: ~/data/vqa-med/answers.c1.weights.csv sampler: - name: kFoldWeightedRandomSampler + type: kFoldWeightedRandomSampler weights: ~/data/vqa-med/answers.c1.weights.csv folds: 5 dataloader: @@ -18,14 +18,13 @@ validation: problem: categories: C1 sampler: - name: kFoldRandomSampler + type: kFoldRandomSampler folds: 5 dataloader: num_workers: 4 pipeline: - name: c1_binary_vf_cat_rnn_shared_all_encoders_two_ffns_losses ################# PIPE 0: SHARED ################# diff --git a/configs/vqa_med_2019/vf/c1_binary_vf_cat_rnn_shared_question_rnn_two_ffns_losses.yml b/configs/vqa_med_2019/vf/c1_binary_vf_cat_rnn_shared_question_rnn_two_ffns_losses.yml index 36152e9..5b882cc 100644 --- a/configs/vqa_med_2019/vf/c1_binary_vf_cat_rnn_shared_question_rnn_two_ffns_losses.yml +++ b/configs/vqa_med_2019/vf/c1_binary_vf_cat_rnn_shared_question_rnn_two_ffns_losses.yml @@ -16,7 +16,6 @@ validation: pipeline: - name: c1_binary_vf_cat_rnn_shared_question_rnn_two_ffns_losses ################# PIPE 0: SHARED ################# diff --git a/configs/vqa_med_2019/vf/c1_c2_c3_binary_vf_cat_rnn_shared_all_encoders_four_ffns_losses.yml b/configs/vqa_med_2019/vf/c1_c2_c3_binary_vf_cat_rnn_shared_all_encoders_four_ffns_losses.yml index c67e07e..909a872 100644 --- a/configs/vqa_med_2019/vf/c1_c2_c3_binary_vf_cat_rnn_shared_all_encoders_four_ffns_losses.yml +++ b/configs/vqa_med_2019/vf/c1_c2_c3_binary_vf_cat_rnn_shared_all_encoders_four_ffns_losses.yml @@ -16,7 +16,6 @@ validation: pipeline: - name: c1_c2_c3_binary_vf_cat_rnn_shared_all_encoders_four_ffns_losses ################# PIPE 0: SHARED ################# diff --git a/configs/vqa_med_2019/vf/c1_c3_binary_vf_cat_rnn_shared_all_encoders_three_ffns_losses.yml b/configs/vqa_med_2019/vf/c1_c3_binary_vf_cat_rnn_shared_all_encoders_three_ffns_losses.yml index b75083f..46d967a 100644 --- a/configs/vqa_med_2019/vf/c1_c3_binary_vf_cat_rnn_shared_all_encoders_three_ffns_losses.yml +++ b/configs/vqa_med_2019/vf/c1_c3_binary_vf_cat_rnn_shared_all_encoders_three_ffns_losses.yml @@ -16,7 +16,6 @@ validation: pipeline: - name: c1_c3_binary_vf_cat_rnn_shared_all_encoders_three_ffns_losses ################# PIPE 0: SHARED ################# diff --git a/configs/wikitext/wikitext_language_modeling_encoder_attndecoder.yml b/configs/wikitext/wikitext_language_modeling_encoder_attndecoder.yml index 244fc4a..7f469ba 100644 --- a/configs/wikitext/wikitext_language_modeling_encoder_attndecoder.yml +++ b/configs/wikitext/wikitext_language_modeling_encoder_attndecoder.yml @@ -16,7 +16,7 @@ training: # optimizer parameters: optimizer: - name: SGD + type: SGD lr: 1.0e-2 # settings parameters @@ -47,7 +47,6 @@ testing: batch_size: 64 pipeline: - name: wikitext_language_modeling_seq2seq # Source encoding - model 1. source_sentence_embedding: diff --git a/configs/wikitext/wikitext_language_modeling_rnn.yml b/configs/wikitext/wikitext_language_modeling_rnn.yml index 1f8665e..d24ffcf 100644 --- a/configs/wikitext/wikitext_language_modeling_rnn.yml +++ b/configs/wikitext/wikitext_language_modeling_rnn.yml @@ -10,7 +10,7 @@ training: # optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.1 # settings parameters @@ -41,7 +41,6 @@ testing: batch_size: 64 pipeline: - name: wikitext_language_modeling_rnn # Source encoding - model 1. source_sentence_embedding: diff --git a/configs/wikitext/wikitext_language_modeling_seq2seq.yml b/configs/wikitext/wikitext_language_modeling_seq2seq.yml index d23243c..df8be27 100644 --- a/configs/wikitext/wikitext_language_modeling_seq2seq.yml +++ b/configs/wikitext/wikitext_language_modeling_seq2seq.yml @@ -16,7 +16,7 @@ training: # optimizer parameters: optimizer: - name: Adam + type: Adam lr: 1.0e-3 # settings parameters @@ -47,7 +47,6 @@ testing: batch_size: 64 pipeline: - name: wikitext_language_modeling_seq2seq # Source encoding - model 1. source_sentence_embedding: diff --git a/configs/wikitext/wikitext_language_modeling_seq2seq_simple.yml b/configs/wikitext/wikitext_language_modeling_seq2seq_simple.yml index fd489db..22df2a4 100644 --- a/configs/wikitext/wikitext_language_modeling_seq2seq_simple.yml +++ b/configs/wikitext/wikitext_language_modeling_seq2seq_simple.yml @@ -16,7 +16,7 @@ training: # optimizer parameters: optimizer: - name: Adam + type: Adam lr: 1.0e-3 # settings parameters @@ -47,7 +47,6 @@ testing: batch_size: 64 pipeline: - name: wikitext_language_modeling_rnn # Source encoding - model 1. source_sentence_embedding: diff --git a/configs/wily/dummy_language_identification_bow.yml b/configs/wily/dummy_language_identification_bow.yml index 846a290..c4c6985 100644 --- a/configs/wily/dummy_language_identification_bow.yml +++ b/configs/wily/dummy_language_identification_bow.yml @@ -10,7 +10,7 @@ training: # optimizer parameters: optimizer: - name: SGD + type: SGD lr: 0.1 # settings parameters @@ -37,7 +37,6 @@ testing: streams: *p_streams pipeline: - name: language_classifier #load: /users/tomaszkornuta/experiments/dummylanguageidentification/language_classifier/20190301_145416/checkpoints/language_classifier_best.pt #freeze: True #disable: prediction_decoder,accuracy diff --git a/configs/wily/wily_language_identification_bow.yml b/configs/wily/wily_language_identification_bow.yml index cf271e2..5bd8066 100644 --- a/configs/wily/wily_language_identification_bow.yml +++ b/configs/wily/wily_language_identification_bow.yml @@ -10,12 +10,12 @@ training: # Use sampler that operates on a subset. sampler: - name: SubsetRandomSampler + type: SubsetRandomSampler indices: [0, 117000] # optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.1 # settings parameters @@ -35,7 +35,7 @@ validation: # Use sampler that operates on a subset. sampler: - name: SubsetRandomSampler + type: SubsetRandomSampler indices: [117000, 117500] # Testing parameters: @@ -48,7 +48,7 @@ testing: streams: *p_streams pipeline: - name: language_classifier + #load: /users/tomaszkornuta/experiments/dummylanguageidentification/language_classifier/20190301_145416/checkpoints/language_classifier_best.pt #freeze: True #disable: prediction_decoder,accuracy diff --git a/configs/wily/wily_ngram_language_modeling.yml b/configs/wily/wily_ngram_language_modeling.yml index 40209d9..961a515 100644 --- a/configs/wily/wily_ngram_language_modeling.yml +++ b/configs/wily/wily_ngram_language_modeling.yml @@ -12,12 +12,12 @@ training: # Use sampler that operates on a subset. #sampler: - # name: SubsetRandomSampler + # type: SubsetRandomSampler # indices: [0, 117000] # optimizer parameters: optimizer: - name: Adam + type: Adam lr: 0.1 # settings parameters @@ -39,7 +39,7 @@ validation: # Use sampler that operates on a subset. #sampler: - # name: SubsetRandomSampler + # type: SubsetRandomSampler # indices: [117000, 117500] # Testing parameters: @@ -53,7 +53,6 @@ testing: streams: *p_streams pipeline: - name: ngram_language_modeling #load: /users/tomaszkornuta/experiments/dummylanguageidentification/language_classifier/20190301_145416/checkpoints/language_classifier_best.pt #freeze: True #disable: prediction_decoder,accuracy diff --git a/ptp/application/problem_manager.py b/ptp/application/problem_manager.py index 4928a88..bb48460 100644 --- a/ptp/application/problem_manager.py +++ b/ptp/application/problem_manager.py @@ -58,29 +58,11 @@ def __init__(self, name, config): # Single batch that will be used for validation (for validation problem manager). self.batch = None - # Set a default configuration section for data loader. - dataloader_config = { - 'problem' : { - 'batch_size': 64, # Default batch size. - }, - 'dataloader': { - 'shuffle': True, # shuffle set by default. - 'batch_sampler': None, - 'num_workers': 0, # Do not use multiprocessing by default - for now. - 'pin_memory': False, - 'drop_last': False, - 'timeout': 0 - }, - 'sampler': {}, # not using sampler by default - } - - self.config.add_default_params(dataloader_config) - def worker_init_fn(self, worker_id): """ Function to be called by :py:class:`torch.utils.data.DataLoader` on each worker subprocess, \ - after seeding and before data loading. (default: ``None``). + after seeding and before data loading. .. note:: @@ -91,7 +73,6 @@ def worker_init_fn(self, worker_id): :param worker_id: the worker id (in [0, :py:class:`torch.utils.data.DataLoader`.num_workers - 1]) :type worker_id: int - :return: ``None`` by default """ # Set random seed of a worker. np.random.seed(seed=np.random.get_state()[1][0] + worker_id) @@ -121,9 +102,13 @@ def build(self, log=True): self.problem = component # Try to build the sampler. - self.sampler = SamplerFactory.build(self.problem, self.config["sampler"], self.name) - - if self.sampler is not None: + # Check if sampler is required, i.e. 'sampler' section is empty. + if "sampler" not in self.config: + self.logger.info("The sampler configuration section is not present, using default 'random' sampling") + # Set sampler to none. + self.sampler = None + else: + self.sampler = SamplerFactory.build(self.problem, self.config["sampler"], self.name) # Set shuffle to False - REQUIRED as those two are exclusive. self.config['dataloader'].add_config_params({'shuffle': False}) @@ -132,7 +117,7 @@ def build(self, log=True): batch_size=self.config['problem']['batch_size'], shuffle=self.config['dataloader']['shuffle'], sampler=self.sampler, - batch_sampler=self.config['dataloader']['batch_sampler'], + batch_sampler= None, num_workers=self.config['dataloader']['num_workers'], collate_fn=self.problem.collate_fn, pin_memory=self.config['dataloader']['pin_memory'], diff --git a/ptp/application/sampler_factory.py b/ptp/application/sampler_factory.py index 0af1b32..c047065 100644 --- a/ptp/application/sampler_factory.py +++ b/ptp/application/sampler_factory.py @@ -84,12 +84,6 @@ def build(problem, config, problem_subset_name): # Initialize logger. logger = logging.initialize_logger('SamplerFactory') - - # Check if sampler is required, i.e. 'sampler' section is empty. - if not config: - logger.info("The sampler configuration section is not present, using default 'random' sampling") - return None - try: # Check presence of the name attribute. if 'name' not in config: diff --git a/ptp/workers/online_trainer.py b/ptp/workers/online_trainer.py index 0f45985..db9a96f 100644 --- a/ptp/workers/online_trainer.py +++ b/ptp/workers/online_trainer.py @@ -69,11 +69,11 @@ def setup_experiment(self): log_str = 'Terminal conditions:\n' + '='*80 + "\n" # Terminal condition I: loss. - self.loss_stop = self.config['training']['terminal_conditions']['loss_stop'] + self.loss_stop = self.config_training['terminal_conditions']['loss_stop'] log_str += " Setting Loss Stop threshold to {}\n".format(self.loss_stop) # Terminal condition II: max epochs. Optional. - self.epoch_limit = self.config["training"]["terminal_conditions"]["epoch_limit"] + self.epoch_limit = self.config_training["terminal_conditions"]["epoch_limit"] if self.epoch_limit <= 0: log_str += " Termination based on Epoch Limit is disabled\n" # Set to infinity. @@ -86,7 +86,7 @@ def setup_experiment(self): log_str += " Epoch size in terms of training episodes: {}\n".format(self.epoch_size) # Terminal condition III: max episodes. Mandatory. - self.episode_limit = self.config['training']['terminal_conditions']['episode_limit'] + self.episode_limit = self.config_training['terminal_conditions']['episode_limit'] if self.episode_limit <= 0: self.logger.error("OnLine Trainer relies on episodes, thus 'episode_limit' must be a positive number!") exit(-5) @@ -194,7 +194,7 @@ def run_experiment(self): # Check the presence of the 'gradient_clipping' parameter. try: # if present - clip gradients to a range (-gradient_clipping, gradient_clipping) - val = self.config['training']['gradient_clipping'] + val = self.config_training['gradient_clipping'] torch.nn.utils.clip_grad_value_(self.pipeline.parameters(), val) except KeyError: # Else - do nothing. @@ -344,11 +344,17 @@ def main(): """ Entry point function for the ``OnlineTrainer``. """ - trainer = OnlineTrainer() - # parse args, load configuration and create all required objects. - trainer.setup_experiment() - # GO! - trainer.run_experiment() + try: + # Create trainer. + trainer = OnlineTrainer() + # Parse args, load configuration and create all required objects. + trainer.setup_experiment() + # GO! + trainer.run_experiment() + except KeyError as e: + print("Error: {}".format(e)) + exit(-1) + if __name__ == '__main__': main() \ No newline at end of file diff --git a/ptp/workers/trainer.py b/ptp/workers/trainer.py index fc10428..fd6454e 100644 --- a/ptp/workers/trainer.py +++ b/ptp/workers/trainer.py @@ -139,30 +139,57 @@ def setup_experiment(self): conf_str += '='*80 + '\n' print(conf_str) - # Get training problem name. + # Get training section. try: - training_problem_type = self.config['training']['problem']['type'] + tsn = "training" + tsn = self.config["training_section_name"] + self.config_training = self.config[tsn] + except KeyError: + print("Error: Couldn't retrieve the training section '{}' from the loaded configuration".format(tsn)) + exit(-1) + + # Get training problem type. + try: + training_problem_type = self.config_training['problem']['type'] except KeyError: print("Error: Couldn't retrieve the problem 'type' from the 'training' section in the loaded configuration") exit(-1) - # Get validation problem name + # Get validation section. + try: + vsn = "validation" + vsn = self.config["validation_section_name"] + self.config_validation = self.config[vsn] + except KeyError: + print("Error: Couldn't retrieve the validation section '{}' from the loaded configuration".format(vsn)) + exit(-1) + + # Get validation problem type. try: - _ = self.config['validation']['problem']['type'] + _ = self.config_validation['problem']['type'] except KeyError: print("Error: Couldn't retrieve the problem 'type' from the 'validation' section in the loaded configuration") exit(-1) + # Get pipeline section. + try: + psn = "pipeline" + psn = self.config["pipeline_section_name"] + self.config_pipeline = self.config[psn] + except KeyError: + print("Error: Couldn't retrieve the pipeline section '{}' from the loaded configuration".format(psn)) + exit(-1) + # Get pipeline name. try: - pipeline_name = self.config['pipeline']['name'] + pipeline_name = self.config_pipeline['name'] except KeyError: # Using name of the first configuration file from command line. basename = path.basename(root_configs[0]) # Take config filename without extension. pipeline_name = path.splitext(basename)[0] # Set pipeline name, so processor can use it afterwards. - self.config['pipeline'].add_config_params({'name': pipeline_name}) + self.config_pipeline.add_config_params({'name': pipeline_name}) # Prepare the output path for logging while True: # Dirty fix: if log_dir already exists, wait for 1 second and try again @@ -195,7 +222,7 @@ def setup_experiment(self): makedirs(self.checkpoint_dir, exist_ok=False) # Set random seeds in the training section. - self.set_random_seeds('training', self.config['training']) + self.set_random_seeds('training', self.config_training) # Total number of detected errors. errors =0 @@ -203,19 +230,19 @@ def setup_experiment(self): ################# TRAINING PROBLEM ################# # Build training problem manager. - self.training = ProblemManager('training', self.config['training']) + self.training = ProblemManager('training', self.config_training) errors += self.training.build() # parse the curriculum learning section in the loaded configuration. - if 'curriculum_learning' in self.config['training']: + if 'curriculum_learning' in self.config_training: # Initialize curriculum learning - with values from loaded configuration. - self.training.problem.curriculum_learning_initialize(self.config['training']['curriculum_learning']) + self.training.problem.curriculum_learning_initialize(self.config_training['curriculum_learning']) # If the 'must_finish' key is not present in config then then it will be finished by default - self.config['training']['curriculum_learning'].add_default_params({'must_finish': True}) + self.config_training['curriculum_learning'].add_default_params({'must_finish': True}) - self.must_finish_curriculum = self.config['training']['curriculum_learning']['must_finish'] + self.must_finish_curriculum = self.config_training['curriculum_learning']['must_finish'] self.logger.info("Curriculum Learning activated") else: @@ -226,13 +253,13 @@ def setup_experiment(self): ################# VALIDATION PROBLEM ################# # Build validation problem manager. - self.validation = ProblemManager('validation', self.config['validation']) + self.validation = ProblemManager('validation', self.config_validation) errors += self.validation.build() ###################### PIPELINE ###################### # Build the pipeline using the loaded configuration. - self.pipeline = PipelineManager(pipeline_name, self.config['pipeline']) + self.pipeline = PipelineManager(pipeline_name, self.config_pipeline) errors += self.pipeline.build() # Check errors. @@ -269,8 +296,8 @@ def setup_experiment(self): if self.app_state.args.load_checkpoint != "": pipeline_name = self.app_state.args.load_checkpoint msg = "command line (--load)" - elif "load" in self.config['pipeline']: - pipeline_name = self.config['pipeline']['load'] + elif "load" in self.config_pipeline: + pipeline_name = self.config_pipeline['load'] msg = "'pipeline' section of the configuration file" else: pipeline_name = "" @@ -309,9 +336,9 @@ def setup_experiment(self): ################# OPTIMIZER ################# # Set the optimizer. - optimizer_conf = dict(self.config['training']['optimizer']) - optimizer_name = optimizer_conf['name'] - del optimizer_conf['name'] + optimizer_conf = dict(self.config_training['optimizer']) + optimizer_type = optimizer_conf['type'] + del optimizer_conf['type'] # Check if there are any models in the pipeline. if len(list(filter(lambda p: p.requires_grad, self.pipeline.parameters()))) == 0: @@ -319,11 +346,11 @@ def setup_experiment(self): exit(-7) # Instantiate the optimizer and filter the model parameters based on if they require gradients. - self.optimizer = getattr(torch.optim, optimizer_name)( + self.optimizer = getattr(torch.optim, optimizer_type)( filter(lambda p: p.requires_grad, self.pipeline.parameters()), **optimizer_conf) log_str = 'Optimizer:\n' + '='*80 + "\n" - log_str += " Name: " + optimizer_name + "\n" + log_str += " Type: " + optimizer_type + "\n" log_str += " Params: {}".format(optimizer_conf) self.logger.info(log_str) From 592903a8d493dc89b5f5b94f81f3faefe5adafb3 Mon Sep 17 00:00:00 2001 From: tkornut Date: Wed, 29 May 2019 18:05:34 -0700 Subject: [PATCH 4/7] testing->test, processor operational relying on default config, standardized passing section names as command line arguments --- configs/default/workers/online_trainer.yml | 29 ++++---- configs/default/workers/processor.yml | 53 ++++++++++++-- configs/mnist/default_mnist.yml | 2 +- configs/mnist/mnist_classification_lenet5.yml | 2 +- .../mnist/mnist_classification_vf_2lenet5.yml | 2 +- .../mnist/mnist_classification_vf_lenet5.yml | 2 +- ...mnist_classification_vf_lenet5_2losses.yml | 2 +- ...ification_vf_shared_convnet_2softmaxes.yml | 2 +- .../eng_fra_translation_enc_attndec.yml | 2 +- ..._language_modeling_encoder_attndecoder.yml | 2 +- .../wikitext_language_modeling_rnn.yml | 2 +- .../wikitext_language_modeling_seq2seq.yml | 2 +- ...itext_language_modeling_seq2seq_simple.yml | 2 +- .../dummy_language_identification_bow.yml | 2 +- .../wily/wily_language_identification_bow.yml | 2 +- configs/wily/wily_ngram_language_modeling.yml | 2 +- ptp/workers/processor.py | 73 ++++++++++++------- ptp/workers/trainer.py | 40 +++++++--- ptp/workers/worker.py | 14 +++- 19 files changed, 161 insertions(+), 76 deletions(-) diff --git a/configs/default/workers/online_trainer.yml b/configs/default/workers/online_trainer.yml index 55b0e3c..96fe8ed 100644 --- a/configs/default/workers/online_trainer.yml +++ b/configs/default/workers/online_trainer.yml @@ -1,18 +1,7 @@ -# Default name of section used for training. -# One can change this, but must remember to define all the required parameters in the new section. -training_section_name: training - -# Default name of section used for validation. -# One can change this, but must remember to define all the required parameters in the new section. -validation_section_name: validation - -# Default name of section containing pipeline definition. -# One can change this, but must remember to define all the required parameters in the new section. -pipeline_section_name: pipeline - - - +#################################################################### # Section defining all the default values of parameters used during training. +# If you want to use different section for training pass its name as command line argument '--training_section_name' to trainer (DEFAULT: training) +# Note: in such a case remember to define all the required parameters in the new section. training: # Set the random seeds: -1 means that they will be picked randomly. # Note: their final values will be stored in the final training_configuration.yml saved to log dir. @@ -73,7 +62,11 @@ training: episode_limit: 100000 -# Section defining all the default values of parameters used during training. + +#################################################################### +# Section defining all the default values of parameters used during validation. +# If you want to use different section for validation pass its name as command line argument '--validation_section_name' to trainer (DEFAULT: validation) +# Note: in such a case remember to define all the required parameters in the new section. validation: # Defines how often the partial validation will be performed. # In this trainer Partial Validation is mandatory, hence interval must be > 0. @@ -104,7 +97,11 @@ validation: # type: RandomSmpler # The rest of the content of that section is optimizer-specific... -# Section defining the pipeline. + + +#################################################################### +# Section defining all the default values of parameters used during training. +# If you want to use different section for validation pass its name as command line argument '--pipeline_section_name' to trainer (DEFAULT: pipeline) pipeline: # Pipeline must contain at least one component. #name_1: diff --git a/configs/default/workers/processor.yml b/configs/default/workers/processor.yml index 862ca8b..e04a388 100644 --- a/configs/default/workers/processor.yml +++ b/configs/default/workers/processor.yml @@ -1,8 +1,51 @@ -# Default name of section used - we assume it will be test -# One can change this, but must remember to define all the required parameters in the new section. -# Note: this can also be changed by setting command line argument (--set) -section_name: test - +#################################################################### # Section defining all the default values of parameters used during testing. +# If you want to use different section for training pass its name as command line argument '--section_name' to trainer (DEFAULT: test) +# Note: in such a case remember to define all the required parameters in the new section. test: + # Set the random seeds: -1 means that they will be picked randomly. + # Note: their final values will be stored in the final training_configuration.yml saved to log dir. + seed_numpy: -1 + seed_torch: -1 + + # Default batch size. + batch_size: 64 + + # Definition of the problem (Mandatory!) + #problem: + # One must define its type (Mandatory!) + # type: ? + # The rest of the content of that section is problem-specific... + + # Set a default configuration section for data loader. + dataloader: + # Shuffle set by default. + shuffle: True + batch_sampler: None + # Do not use multiprocessing by default. + num_workers: 0 + pin_memory: False + # Do not drop last frame by default. + drop_last: False + timeout: 0 + + # Definition of sampler (Optional) + # When this section will not be present, worker will use "standard" sampling (please refer to shuffle in dataloader) + #sampler: + # # Type - generally all samplers from PyTorch (plus some new onses) are allowed (Mandatory!) + # # Options: + # type: RandomSmpler + # The rest of the content of that section is optimizer-specific... + +#################################################################### +# Section defining all the default values of parameters used during training. +# If you want to use different section for validation pass its name as command line argument '--pipeline_section_name' to trainer (DEFAULT: pipeline) +pipeline: + # Pipeline must contain at least one component. + #name_1: + # Each component must have defined its priority... (Mandatory!) + # priority: 0.1 # Can be float. Smaller means higher priority, up to zero. + # # ... and type (Mandatory!) + # type: ? + # The rest of the content of that section is component-specific... diff --git a/configs/mnist/default_mnist.yml b/configs/mnist/default_mnist.yml index b49f033..5565041 100644 --- a/configs/mnist/default_mnist.yml +++ b/configs/mnist/default_mnist.yml @@ -33,7 +33,7 @@ validation: # indices: [55000, 60000] # Testing parameters: -testing: +test: problem: type: MNIST batch_size: *b diff --git a/configs/mnist/mnist_classification_lenet5.yml b/configs/mnist/mnist_classification_lenet5.yml index 65deca1..1dded53 100644 --- a/configs/mnist/mnist_classification_lenet5.yml +++ b/configs/mnist/mnist_classification_lenet5.yml @@ -12,7 +12,7 @@ validation: resize_image: [32, 32] # Testing parameters - overwrite defaults: -testing: +test: problem: resize_image: [32, 32] diff --git a/configs/mnist/mnist_classification_vf_2lenet5.yml b/configs/mnist/mnist_classification_vf_2lenet5.yml index 83e4970..6737421 100644 --- a/configs/mnist/mnist_classification_vf_2lenet5.yml +++ b/configs/mnist/mnist_classification_vf_2lenet5.yml @@ -12,7 +12,7 @@ validation: resize_image: [32, 32] # Testing parameters - overwrite defaults: -testing: +test: problem: resize_image: [32, 32] diff --git a/configs/mnist/mnist_classification_vf_lenet5.yml b/configs/mnist/mnist_classification_vf_lenet5.yml index 707d57a..731f180 100644 --- a/configs/mnist/mnist_classification_vf_lenet5.yml +++ b/configs/mnist/mnist_classification_vf_lenet5.yml @@ -12,7 +12,7 @@ validation: resize_image: [32, 32] # Testing parameters - overwrite defaults: -testing: +test: problem: resize_image: [32, 32] diff --git a/configs/mnist/mnist_classification_vf_lenet5_2losses.yml b/configs/mnist/mnist_classification_vf_lenet5_2losses.yml index 69d53dc..a685120 100644 --- a/configs/mnist/mnist_classification_vf_lenet5_2losses.yml +++ b/configs/mnist/mnist_classification_vf_lenet5_2losses.yml @@ -12,7 +12,7 @@ validation: resize_image: [32, 32] # Testing parameters - overwrite defaults: -testing: +test: problem: resize_image: [32, 32] diff --git a/configs/mnist/mnist_classification_vf_shared_convnet_2softmaxes.yml b/configs/mnist/mnist_classification_vf_shared_convnet_2softmaxes.yml index 3185c52..c782099 100644 --- a/configs/mnist/mnist_classification_vf_shared_convnet_2softmaxes.yml +++ b/configs/mnist/mnist_classification_vf_shared_convnet_2softmaxes.yml @@ -19,7 +19,7 @@ training: # resize_image: [32, 32] # Testing parameters - overwrite defaults: -#testing: +#test: # problem: # resize_image: [32, 32] diff --git a/configs/translation/eng_fra_translation_enc_attndec.yml b/configs/translation/eng_fra_translation_enc_attndec.yml index 50d37ca..bba5363 100644 --- a/configs/translation/eng_fra_translation_enc_attndec.yml +++ b/configs/translation/eng_fra_translation_enc_attndec.yml @@ -35,7 +35,7 @@ validation: batch_size: 64 # Testing parameters: -testing: +test: problem: type: *p_type data_folder: *data_folder diff --git a/configs/wikitext/wikitext_language_modeling_encoder_attndecoder.yml b/configs/wikitext/wikitext_language_modeling_encoder_attndecoder.yml index 7f469ba..55a1261 100644 --- a/configs/wikitext/wikitext_language_modeling_encoder_attndecoder.yml +++ b/configs/wikitext/wikitext_language_modeling_encoder_attndecoder.yml @@ -37,7 +37,7 @@ validation: batch_size: 64 # Testing parameters: -testing: +test: problem: type: *p_type data_folder: *data_folder diff --git a/configs/wikitext/wikitext_language_modeling_rnn.yml b/configs/wikitext/wikitext_language_modeling_rnn.yml index d24ffcf..3bd504a 100644 --- a/configs/wikitext/wikitext_language_modeling_rnn.yml +++ b/configs/wikitext/wikitext_language_modeling_rnn.yml @@ -31,7 +31,7 @@ validation: batch_size: 64 # Testing parameters: -testing: +test: problem: type: *p_type data_folder: *data_folder diff --git a/configs/wikitext/wikitext_language_modeling_seq2seq.yml b/configs/wikitext/wikitext_language_modeling_seq2seq.yml index df8be27..49f611b 100644 --- a/configs/wikitext/wikitext_language_modeling_seq2seq.yml +++ b/configs/wikitext/wikitext_language_modeling_seq2seq.yml @@ -37,7 +37,7 @@ validation: batch_size: 64 # Testing parameters: -testing: +test: problem: type: *p_type data_folder: *data_folder diff --git a/configs/wikitext/wikitext_language_modeling_seq2seq_simple.yml b/configs/wikitext/wikitext_language_modeling_seq2seq_simple.yml index 22df2a4..4e9d0d6 100644 --- a/configs/wikitext/wikitext_language_modeling_seq2seq_simple.yml +++ b/configs/wikitext/wikitext_language_modeling_seq2seq_simple.yml @@ -37,7 +37,7 @@ validation: batch_size: 64 # Testing parameters: -testing: +test: problem: type: *p_type data_folder: *data_folder diff --git a/configs/wily/dummy_language_identification_bow.yml b/configs/wily/dummy_language_identification_bow.yml index c4c6985..2ff27a0 100644 --- a/configs/wily/dummy_language_identification_bow.yml +++ b/configs/wily/dummy_language_identification_bow.yml @@ -29,7 +29,7 @@ validation: streams: *p_streams # Testing parameters: -testing: +test: problem: type: *p_type batch_size: 2 diff --git a/configs/wily/wily_language_identification_bow.yml b/configs/wily/wily_language_identification_bow.yml index 5bd8066..aa84c8c 100644 --- a/configs/wily/wily_language_identification_bow.yml +++ b/configs/wily/wily_language_identification_bow.yml @@ -39,7 +39,7 @@ validation: indices: [117000, 117500] # Testing parameters: -testing: +test: problem: type: *p_type data_folder: *data_folder diff --git a/configs/wily/wily_ngram_language_modeling.yml b/configs/wily/wily_ngram_language_modeling.yml index 961a515..316a95a 100644 --- a/configs/wily/wily_ngram_language_modeling.yml +++ b/configs/wily/wily_ngram_language_modeling.yml @@ -43,7 +43,7 @@ validation: # indices: [117000, 117500] # Testing parameters: -testing: +test: problem: type: *p_type data_folder: *data_folder diff --git a/ptp/workers/processor.py b/ptp/workers/processor.py index ccc3d05..22e10b5 100644 --- a/ptp/workers/processor.py +++ b/ptp/workers/processor.py @@ -50,11 +50,11 @@ def __init__(self): super(Processor, self).__init__("Processor", Processor) self.parser.add_argument( - '--set', - dest='set', + '--section', + dest='section_name', type=str, - default="testing", - help='Name of the specific set (section containing problem) to be processed (DEFAULT: testing)') + default="test", + help='Name of the section defining the specific set to be processed (DEFAULT: test)') def setup_global_experiment(self): """ @@ -73,9 +73,8 @@ def setup_global_experiment(self): # Call base method to parse all command line arguments and add default sections. super(Processor, self).setup_experiment() - # Retrieve checkpoint file and section + # Retrieve checkpoint file. chkpt_file = self.app_state.args.load_checkpoint - self.set = self.app_state.args.set # Check the presence of the CUDA-compatible devices. if self.app_state.args.use_gpu and (torch.cuda.device_count() == 0): @@ -147,16 +146,36 @@ def setup_individual_experiment(self): """ + # Get test section. + try: + self.tsn = self.app_state.args.section_name + self.config_test = self.config[self.tsn] + if self.config_test is None: + raise KeyError() + except KeyError: + print("Error: Couldn't retrieve the section '{}' from the loaded configuration".format(self.tsn)) + exit(-1) + # Get testing problem type. try: - _ = self.config[self.set]['problem']['type'] + _ = self.config_test['problem']['type'] except KeyError: - print("Error: Couldn't retrieve the problem 'type' from the '{}' section in the loaded configuration".format(self.set)) + print("Error: Couldn't retrieve the problem 'type' from the '{}' section in the loaded configuration".format(self.tsn)) exit(-5) + # Get pipeline section. + try: + psn = self.app_state.args.pipeline_section_name + self.config_pipeline = self.config[psn] + if self.config_pipeline is None: + raise KeyError() + except KeyError: + print("Error: Couldn't retrieve the pipeline section '{}' from the loaded configuration".format(psn)) + exit(-1) + # Get pipeline name. try: - pipeline_name = self.config['pipeline']['name'] + pipeline_name = self.config_pipeline['name'] except KeyError: print("Error: Couldn't retrieve the pipeline 'name' from the loaded configuration") exit(-6) @@ -165,9 +184,9 @@ def setup_individual_experiment(self): while True: # Dirty fix: if log_dir already exists, wait for 1 second and try again try: - time_str = self.set+'_{0:%Y%m%d_%H%M%S}'.format(datetime.now()) - if self.app_state.args.savetag != '': - time_str = time_str + "_" + self.app_state.args.savetag + time_str = self.tsn+'_{0:%Y%m%d_%H%M%S}'.format(datetime.now()) + if self.app_state.args.exptag != '': + time_str = time_str + "_" + self.app_state.args.exptag self.app_state.log_dir = self.abs_path + '/' + time_str + '/' # Lowercase dir. self.app_state.log_dir = self.app_state.log_dir.lower() @@ -189,7 +208,7 @@ def setup_individual_experiment(self): self.app_state.set_types() # Set random seeds in the testing section. - self.set_random_seeds(self.set, self.config[self.set]) + self.set_random_seeds(self.tsn, self.config_test) # Total number of detected errors. errors =0 @@ -197,7 +216,7 @@ def setup_individual_experiment(self): ################# TESTING PROBLEM ################# # Build the used problem manager. - self.pm = ProblemManager(self.set, self.config[self.set]) + self.pm = ProblemManager(self.tsn, self.config_test) errors += self.pm.build() @@ -206,28 +225,28 @@ def setup_individual_experiment(self): # So that by default, we loop over the test set once. max_test_episodes = len(self.pm) - self.config[self.set]['problem'].add_default_params({'max_test_episodes': max_test_episodes}) - if self.config[self.set]["problem"]["max_test_episodes"] == -1: + self.config_test['problem'].add_default_params({'max_test_episodes': max_test_episodes}) + if self.config_test["problem"]["max_test_episodes"] == -1: # Overwrite the config value! - self.config[self.set]['problem'].add_config_params({'max_test_episodes': max_test_episodes}) + self.config_test['problem'].add_config_params({'max_test_episodes': max_test_episodes}) # Warn if indicated number of episodes is larger than an epoch size: - if self.config[self.set]["problem"]["max_test_episodes"] > max_test_episodes: + if self.config_test["problem"]["max_test_episodes"] > max_test_episodes: self.logger.warning('Indicated maximum number of episodes is larger than one epoch, reducing it.') - self.config[self.set]['problem'].add_config_params({'max_test_episodes': max_test_episodes}) + self.config_test['problem'].add_config_params({'max_test_episodes': max_test_episodes}) self.logger.info("Setting the max number of episodes to: {}".format( - self.config[self.set]["problem"]["max_test_episodes"])) + self.config_test["problem"]["max_test_episodes"])) ###################### PIPELINE ###################### # Build the pipeline using the loaded configuration and global variables. - self.pipeline = PipelineManager(pipeline_name, self.config['pipeline']) + self.pipeline = PipelineManager(pipeline_name, self.config_pipeline) errors += self.pipeline.build() # Show pipeline. summary_str = self.pipeline.summarize_all_components_header() - summary_str += self.pm.problem.summarize_io(self.set) + summary_str += self.pm.problem.summarize_io(self.tsn) summary_str += self.pipeline.summarize_all_components() self.logger.info(summary_str) @@ -258,8 +277,8 @@ def setup_individual_experiment(self): if self.app_state.args.load_checkpoint != "": pipeline_name = self.app_state.args.load_checkpoint msg = "command line (--load)" - elif "load" in self.config['pipeline']: - pipeline_name = self.config['pipeline']['load'] + elif "load" in self.config_pipeline: + pipeline_name = self.config_pipeline['load'] msg = "'pipeline' section of the configuration file" else: pipeline_name = "" @@ -312,7 +331,7 @@ def initialize_statistics_collection(self): self.pm.problem.add_statistics(self.stat_col) self.pipeline.add_statistics(self.stat_col) # Create the csv file to store the statistics. - self.pm_batch_stats_file = self.stat_col.initialize_csv_file(self.app_state.log_dir, self.set+'_statistics.csv') + self.pm_batch_stats_file = self.stat_col.initialize_csv_file(self.app_state.log_dir, self.tsn+'_statistics.csv') # Create statistics aggregator. self.stat_agg = StatisticsAggregator() @@ -321,7 +340,7 @@ def initialize_statistics_collection(self): self.pipeline.add_aggregators(self.stat_agg) # Create the csv file to store the statistic aggregations. # Will contain a single row with aggregated statistics. - self.pm_set_stats_file = self.stat_agg.initialize_csv_file(self.app_state.log_dir, self.set+'_set_agg_statistics.csv') + self.pm_set_stats_file = self.stat_agg.initialize_csv_file(self.app_state.log_dir, self.tsn+'_set_agg_statistics.csv') def finalize_statistics_collection(self): """ @@ -366,7 +385,7 @@ def run_experiment(self): # Increment counter. self.app_state.episode += 1 # Terminal condition 0: max test episodes reached. - if self.app_state.episode == self.config[self.set]["problem"]["max_test_episodes"]: + if self.app_state.episode == self.config_test["problem"]["max_test_episodes"]: break # Forward pass. diff --git a/ptp/workers/trainer.py b/ptp/workers/trainer.py index fd6454e..af8456d 100644 --- a/ptp/workers/trainer.py +++ b/ptp/workers/trainer.py @@ -74,11 +74,25 @@ def __init__(self, name, class_type): "(Warning: Even slower).") self.parser.add_argument( - '--save', + '--saveall', dest='save_intermediate', action='store_true', help='Setting to true results in saving intermediate models during training (DEFAULT: False)') + self.parser.add_argument( + '--training', + dest='training_section_name', + type=str, + default="training", + help='Name of the section defining the training procedure (DEFAULT: training)') + + self.parser.add_argument( + '--validation', + dest='validation_section_name', + type=str, + default="validation", + help='Name of the section defining the validation procedure (DEFAULT: validation)') + def setup_experiment(self): """ @@ -141,9 +155,11 @@ def setup_experiment(self): # Get training section. try: - tsn = "training" - tsn = self.config["training_section_name"] + tsn = self.app_state.args.training_section_name self.config_training = self.config[tsn] + # We must additionally check if it is None - weird behvaiour when using default value. + if self.config_training is None: + raise KeyError() except KeyError: print("Error: Couldn't retrieve the training section '{}' from the loaded configuration".format(tsn)) exit(-1) @@ -152,14 +168,15 @@ def setup_experiment(self): try: training_problem_type = self.config_training['problem']['type'] except KeyError: - print("Error: Couldn't retrieve the problem 'type' from the 'training' section in the loaded configuration") + print("Error: Couldn't retrieve the problem 'type' from the training section '{}' in the loaded configuration".format(tsn)) exit(-1) # Get validation section. try: - vsn = "validation" - vsn = self.config["validation_section_name"] + vsn = self.app_state.args.validation_section_name self.config_validation = self.config[vsn] + if self.config_validation is None: + raise KeyError() except KeyError: print("Error: Couldn't retrieve the validation section '{}' from the loaded configuration".format(vsn)) exit(-1) @@ -168,14 +185,15 @@ def setup_experiment(self): try: _ = self.config_validation['problem']['type'] except KeyError: - print("Error: Couldn't retrieve the problem 'type' from the 'validation' section in the loaded configuration") + print("Error: Couldn't retrieve the problem 'type' from the validation section '{}' in the loaded configuration".format(vsn)) exit(-1) # Get pipeline section. try: - psn = "pipeline" - psn = self.config["pipeline_section_name"] + psn = self.app_state.args.pipeline_section_name self.config_pipeline = self.config[psn] + if self.config_pipeline is None: + raise KeyError() except KeyError: print("Error: Couldn't retrieve the pipeline section '{}' from the loaded configuration".format(psn)) exit(-1) @@ -195,8 +213,8 @@ def setup_experiment(self): while True: # Dirty fix: if log_dir already exists, wait for 1 second and try again try: time_str = '{0:%Y%m%d_%H%M%S}'.format(datetime.now()) - if self.app_state.args.savetag != '': - time_str = time_str + "_" + self.app_state.args.savetag + if self.app_state.args.exptag != '': + time_str = time_str + "_" + self.app_state.args.exptag self.app_state.log_dir = path.expanduser(self.app_state.args.expdir) + '/' + training_problem_type + '/' + pipeline_name + '/' + time_str + '/' # Lowercase dir. self.app_state.log_dir = self.app_state.log_dir.lower() diff --git a/ptp/workers/worker.py b/ptp/workers/worker.py index 3d93393..958c5d7 100644 --- a/ptp/workers/worker.py +++ b/ptp/workers/worker.py @@ -116,11 +116,11 @@ def __init__(self, name, class_type, add_default_parser_args = True): ' (DEFAULT: ~/experiments)') self.parser.add_argument( - '--savetag', - dest='savetag', + '--exptag', + dest='exptag', type=str, default='', - help='Tag for the save directory.') + help="Additional tag that will be added to the output folder name (DEFAULT: '').") self.parser.add_argument( '--logger', @@ -147,6 +147,14 @@ def __init__(self, name, class_type, add_default_parser_args = True): help='Request user confirmation just after loading the settings, ' 'before starting the experiment. (DEFAULT: False)') + self.parser.add_argument( + '--pipeline', + dest='pipeline_section_name', + type=str, + default="pipeline", + help='Name of the section defining the pipeline (DEFAULT: pipeline)') + + def setup_experiment(self): """ Setups a specific experiment. From f1d2c2cdc36e2b33d3a93c265a5d6cab45a23686 Mon Sep 17 00:00:00 2001 From: tkornut Date: Wed, 29 May 2019 18:13:00 -0700 Subject: [PATCH 5/7] added KeyErro handling to main entry points of both workers --- ptp/workers/online_trainer.py | 1 + ptp/workers/processor.py | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ptp/workers/online_trainer.py b/ptp/workers/online_trainer.py index db9a96f..1361c9e 100644 --- a/ptp/workers/online_trainer.py +++ b/ptp/workers/online_trainer.py @@ -351,6 +351,7 @@ def main(): trainer.setup_experiment() # GO! trainer.run_experiment() + except KeyError as e: print("Error: {}".format(e)) exit(-1) diff --git a/ptp/workers/processor.py b/ptp/workers/processor.py index 22e10b5..3770310 100644 --- a/ptp/workers/processor.py +++ b/ptp/workers/processor.py @@ -434,15 +434,18 @@ def main(): Entry point function for the ``Processor``. """ - processor = Processor() - # parse args, load configuration and create all required objects. - processor.setup_global_experiment() - - # finalize the experiment setup - processor.setup_individual_experiment() - - # run the experiment - processor.run_experiment() + try: + processor = Processor() + # parse args, load configuration and create all required objects. + processor.setup_global_experiment() + # finalize the experiment setup + processor.setup_individual_experiment() + # run the experiment + processor.run_experiment() + + except KeyError as e: + print("Error: {}".format(e)) + exit(-1) if __name__ == '__main__': From 61724418f99548ee0f0129b3a19b9bc951367753 Mon Sep 17 00:00:00 2001 From: tkornut Date: Wed, 29 May 2019 18:33:54 -0700 Subject: [PATCH 6/7] update of readme --- README.md | 17 ++++++++++------- ptp/workers/processor.py | 3 +-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 74c545e..e748bc4 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ PyTorchPipe (PTP) is a component-oriented framework that facilitates development PTP frames training and testing procedures as _pipelines_ consisting of many components communicating through data streams. Each such a stream can consist of several components, including one problem instance (providing batches of data), any number of trainable components (models) and additional components providing required transformations and computations. -As a result, the training & testing procedures are no longer pinned to a specific problem or model, and built-in mechanisms for compatibility checking (handshaking), configuration management & statistics collection facilitate running diverse experiments. +As a result, the training & testing procedures are no longer pinned to a specific problem or model, and built-in mechanisms for compatibility checking (handshaking), configuration and global variables management & statistics collection facilitate rapid development of complex pipelines and running diverse experiments. In its core, to _accelerate the computations_ on their own, PTP relies on PyTorch and extensively uses its mechanisms for distribution of computations on CPUs/GPUs, including multi-threaded data loaders and multi-GPU data parallelism. The models are _agnostic_ to those operations and one indicates whether to use them in configuration files (data loaders) or by passing adequate run-time arguments (--gpu). @@ -31,13 +31,16 @@ PTP focuses on multi-modal reasoning combining vision and language. Currently it * ANKI (Machine Translation) Aside of providing batches of samples, the Problem class will automatically download the files associated with a given dataset (as long as the dataset is publicly available). -The diversity of those problems proves the flexibility of the framework, we are working on incorporation of new ones into PTP. +The diversity of those problems (and associated models) proves the flexibility of the framework, we are working on incorporation of new ones into PTP. -**Model Zoo:** -What people typically define as _model_ in PTP is decomposed into components, with _Model_ being a defived class that contains trainable elements. -Those components are loosely coupled and care only about the inputs they retrieve and outputs they produce. -The framework offers full flexibility and it is up to the programer to choose the _granularity_ of his/her components/models. -However, PTP provides several ready to use, out of the box components, from ones of general usage to very specialized ones: +**Pipelines** +What people typically define as a _model_ in PTP is framed as a _pipeline_, consisting of many inter-connected components, with one or more _Models_ containing trainable elements. +Those components are loosely coupled and care only about the _input streams_ they retrieve and _output streams_ they produce. +The framework offers full flexibility and it is up to the programmer to choose the _granularity_ of his/her components/models/pipelines. +Such a decomposition enables one to easily combine many components and models into pipelines, whereas the framework supports loading of pretrained models, freezing during training, saving them to checkpoints etc. + +**Model/Component Zoo:** +PTP provides several ready to use, out of the box components, from ones of general usage to very specialized ones: * Feed Forward Network (Fully Connected layers with activation functions and dropout, variable number of hidden layers, general usage) * Torch Vision Wrapper (wrapping several models from Torch Vision, e.g. VGG-16, ResNet-50, ResNet-152, DenseNet-121, general usage) diff --git a/ptp/workers/processor.py b/ptp/workers/processor.py index 3770310..f8c189b 100644 --- a/ptp/workers/processor.py +++ b/ptp/workers/processor.py @@ -362,7 +362,6 @@ def run_experiment(self): - Logs statistics & accumulates loss, - Activate visualization if set. - """ # Initialize tensorboard and statistics collection. self.initialize_statistics_collection() @@ -442,7 +441,7 @@ def main(): processor.setup_individual_experiment() # run the experiment processor.run_experiment() - + except KeyError as e: print("Error: {}".format(e)) exit(-1) From 227e353a7158d3e41d55c71676a1a7954b422f3b Mon Sep 17 00:00:00 2001 From: tkornut Date: Wed, 29 May 2019 18:38:18 -0700 Subject: [PATCH 7/7] update of readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e748bc4..7151986 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Each such a stream can consist of several components, including one problem inst As a result, the training & testing procedures are no longer pinned to a specific problem or model, and built-in mechanisms for compatibility checking (handshaking), configuration and global variables management & statistics collection facilitate rapid development of complex pipelines and running diverse experiments. -In its core, to _accelerate the computations_ on their own, PTP relies on PyTorch and extensively uses its mechanisms for distribution of computations on CPUs/GPUs, including multi-threaded data loaders and multi-GPU data parallelism. +In its core, to _accelerate the computations_ on their own, PTP relies on PyTorch and extensively uses its mechanisms for distribution of computations on CPUs/GPUs, including multi-process data loaders and multi-GPU data parallelism. The models are _agnostic_ to those operations and one indicates whether to use them in configuration files (data loaders) or by passing adequate run-time arguments (--gpu). **Datasets:** @@ -33,7 +33,7 @@ PTP focuses on multi-modal reasoning combining vision and language. Currently it Aside of providing batches of samples, the Problem class will automatically download the files associated with a given dataset (as long as the dataset is publicly available). The diversity of those problems (and associated models) proves the flexibility of the framework, we are working on incorporation of new ones into PTP. -**Pipelines** +**Pipelines:** What people typically define as a _model_ in PTP is framed as a _pipeline_, consisting of many inter-connected components, with one or more _Models_ containing trainable elements. Those components are loosely coupled and care only about the _input streams_ they retrieve and _output streams_ they produce. The framework offers full flexibility and it is up to the programmer to choose the _granularity_ of his/her components/models/pipelines.