From 65a871d65d35b768ad7ab3479d064ca204300dd5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 5 Sep 2023 13:48:43 +0200 Subject: [PATCH 001/762] . --- domainlab/algos/trainers/fbopt.py | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 domainlab/algos/trainers/fbopt.py diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py new file mode 100644 index 000000000..989c538b3 --- /dev/null +++ b/domainlab/algos/trainers/fbopt.py @@ -0,0 +1,83 @@ +""" +update hyper-parameters during training +""" + + +class HyperSchedulerFeedback(): + """ + design $\\mu$$ sequence based on state of penalized loss + """ + def __init__(self, **kwargs): + """ + kwargs is a dictionary with key the hyper-parameter name and its value + """ + self.dict_par_init = kwargs + self.ploss_old_theta_old_mu = None + self.ploss_old_theta_new_mu = None + self.ploss_new_theta_old_mu = None + self.ploss_new_theta_new_mu = None + self.delta_mu = 0.01 # FIXME + self.theta = None + self.mmu = None + self.opt_theta = None # theta operator + self.budget_mu_per_step = 5 # FIXME + self.budget_theta_per_step = 5 + + def search_mu(self): + """ + enlarge mmu to see if the criteria is met + """ + flag_success = False + for miter in range(self.budget_mu_per_step): + mmu = self.mmu + miter * self.delta_mu + if self.search_theta(mmu): + flag_success = True + if not flag_success: + raise RuntimeError("failed to find mu within budget") + + def search_theta(self, mmu_new): + """ + conditioned on fixed $$\\mu$$, the operator should search theta based on + the current value of $theta$ + """ + flag_success = False + self.ploss_old_theta_new_mu = self.eval_loss(mmu_new, self.theta) + self.ploss_old_theta_old_mu = self.eval_loss(self.mmu, self.theta) + for _ in range(self.budget_theta_per_step): + theta4mu_new = self.opt_theta(mmu_new) + self.ploss_new_theta_new_mu = self.eval_loss(mmu_new, theta4mu_new) + self.ploss_new_theta_old_mu = self.eval_loss(self.mmu, theta4mu_new) + if self.is_criteria_met(): + self.mmu = mmu_new + self.theta = theta4mu_new + flag_success = True + return flag_success + + def eval_loss(self, mmu, theta): + """ + evaluate the penalty function value + """ + v_reg_loss = self.trainer.model.cal_reg_loss(theta) + loss_reg = self.inner_product(v_reg_loss, mmu) + ploss = loss_reg + self.trainer.model.cal_task_loss(theta) + return ploss + + def inner_product(self, mmu, v_reg_loss): + """ + - the first dimension of the tensor v_reg_loss is mini-batch + the second dimension is the number of regularizers + - the vector mmu has dimension the number of regularizers + """ + return mmu * v_reg_loss # + + def is_criteria_met(self): + """ + if the reg-descent criteria is met + """ + flag_improve = self.ploss_new_theta_new_mu < self.ploss_old_theta_new_mu + flag_deteriorate = self.ploss_new_theta_old_mu > self.ploss_old_theta_old_mu + return flag_improve & flag_deteriorate + + def __call__(self, epoch): + """ + """ From bd9353625cb4ac174a738cdb40d9ef2c594547d1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 5 Sep 2023 14:46:46 +0200 Subject: [PATCH 002/762] . --- domainlab/algos/trainers/fbopt.py | 6 +- domainlab/algos/trainers/train_fbopt.py | 56 +++++++++++++++++++ .../algos/trainers/train_hyper_scheduler.py | 1 + 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 domainlab/algos/trainers/train_fbopt.py diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 989c538b3..af3630f27 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -7,10 +7,11 @@ class HyperSchedulerFeedback(): """ design $\\mu$$ sequence based on state of penalized loss """ - def __init__(self, **kwargs): + def __init__(self, trainer, **kwargs): """ kwargs is a dictionary with key the hyper-parameter name and its value """ + self.trainer = trainer self.dict_par_init = kwargs self.ploss_old_theta_old_mu = None self.ploss_old_theta_new_mu = None @@ -19,7 +20,6 @@ def __init__(self, **kwargs): self.delta_mu = 0.01 # FIXME self.theta = None self.mmu = None - self.opt_theta = None # theta operator self.budget_mu_per_step = 5 # FIXME self.budget_theta_per_step = 5 @@ -44,7 +44,7 @@ def search_theta(self, mmu_new): self.ploss_old_theta_new_mu = self.eval_loss(mmu_new, self.theta) self.ploss_old_theta_old_mu = self.eval_loss(self.mmu, self.theta) for _ in range(self.budget_theta_per_step): - theta4mu_new = self.opt_theta(mmu_new) + theta4mu_new = self.trainer.opt_theta(mmu_new) self.ploss_new_theta_new_mu = self.eval_loss(mmu_new, theta4mu_new) self.ploss_new_theta_old_mu = self.eval_loss(self.mmu, theta4mu_new) if self.is_criteria_met(): diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py new file mode 100644 index 000000000..baf9f783e --- /dev/null +++ b/domainlab/algos/trainers/train_fbopt.py @@ -0,0 +1,56 @@ +""" +feedback optimization +""" +import copy + +from domainlab.algos.trainers.a_trainer import AbstractTrainer +from domainlab.algos.trainers.train_basic import TrainerBasic +from domainlab.algos.trainers.fbopt import HyperSchedulerFeedback + + +class TrainerFbOpt(AbstractTrainer): + """ + feedback optimization + """ + def set_scheduler(self, scheduler=HyperSchedulerFeedback): + """ + Args: + scheduler: The class name of the scheduler, the object corresponding to + this class name will be created inside model + """ + self.hyper_scheduler = self.model.hyper_init(scheduler) + + def before_tr(self): + """ + check the performance of randomly initialized weight + """ + self.set_scheduler() + self.model.evaluate(self.loader_te, self.device) + self.inner_trainer = TrainerBasic() + self.inner_trainer.init_business( + self.model, self.task, self.observer, self.device, self.aconf, + flag_accept=False) + + def opt_theta(self, mmu): + """ + operator for theta, move gradient for a few steps, then check if criteria is met + """ + + def tr_epoch(self, epoch): + self.model.train() + self.hyper_scheduler.search_mu() + + for ind_batch, (tensor_x, vec_y, vec_d, *others) in enumerate(self.loader_tr): + inner_net = copy.deepcopy(self.model) + self.inner_trainer.model = inner_net # FORCE replace model + self.inner_trainer.train_batch( + tensor_x, vec_y, vec_d, others) # update inner_net + + loss_look_forward = inner_net.cal_task_loss(tensor_x, vec_y) + loss_source = self.model.cal_loss(tensor_x, vec_y, vec_d, others) + loss = loss_source.sum() + self.aconf.gamma_reg * loss_look_forward.sum() + loss.backward() + self.optimizer.step() + self.after_batch(epoch, ind_batch) + flag_stop = self.observer.update(epoch) # notify observer + return flag_stop diff --git a/domainlab/algos/trainers/train_hyper_scheduler.py b/domainlab/algos/trainers/train_hyper_scheduler.py index d52fe658d..0a12e0c04 100644 --- a/domainlab/algos/trainers/train_hyper_scheduler.py +++ b/domainlab/algos/trainers/train_hyper_scheduler.py @@ -26,6 +26,7 @@ def set_scheduler(self, scheduler, total_steps, flag_update_batch: if hyper-parameters should be changed per batch """ self.hyper_scheduler = self.model.hyper_init(scheduler) + # let model register its hyper-parameters to the scheduler self.flag_update_hyper_per_epoch = flag_update_epoch self.flag_update_hyper_per_batch = flag_update_batch self.hyper_scheduler.set_steps(total_steps=total_steps) From 62b9e0825c64b948d4d22fb6ffee07b8ce06b3fb Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 5 Sep 2023 15:31:50 +0200 Subject: [PATCH 003/762] global picture finished --- domainlab/algos/trainers/fbopt.py | 19 ++------ domainlab/algos/trainers/train_fbopt.py | 61 ++++++++++++++++++------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index af3630f27..b9d16cc73 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -41,27 +41,18 @@ def search_theta(self, mmu_new): the current value of $theta$ """ flag_success = False - self.ploss_old_theta_new_mu = self.eval_loss(mmu_new, self.theta) - self.ploss_old_theta_old_mu = self.eval_loss(self.mmu, self.theta) + self.ploss_old_theta_new_mu = self.trainer.eval_loss(mmu_new, self.theta) + self.ploss_old_theta_old_mu = self.trainer.eval_loss(self.mmu, self.theta) for _ in range(self.budget_theta_per_step): - theta4mu_new = self.trainer.opt_theta(mmu_new) - self.ploss_new_theta_new_mu = self.eval_loss(mmu_new, theta4mu_new) - self.ploss_new_theta_old_mu = self.eval_loss(self.mmu, theta4mu_new) + theta4mu_new = self.trainer.opt_theta(mmu_new, self.trainer.model.named_parameters()) # FIXME: get theta from model + self.ploss_new_theta_new_mu = self.trainer.eval_loss(mmu_new, theta4mu_new) + self.ploss_new_theta_old_mu = self.trainer.eval_loss(self.mmu, theta4mu_new) if self.is_criteria_met(): self.mmu = mmu_new self.theta = theta4mu_new flag_success = True return flag_success - def eval_loss(self, mmu, theta): - """ - evaluate the penalty function value - """ - v_reg_loss = self.trainer.model.cal_reg_loss(theta) - loss_reg = self.inner_product(v_reg_loss, mmu) - ploss = loss_reg + self.trainer.model.cal_task_loss(theta) - return ploss - def inner_product(self, mmu, v_reg_loss): """ - the first dimension of the tensor v_reg_loss is mini-batch diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index baf9f783e..e0bdb2731 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -8,6 +8,14 @@ from domainlab.algos.trainers.fbopt import HyperSchedulerFeedback +class HyperSetter(): + def __init__(self, dict_hyper): + self.dict_hyper = dict_hyper + + def __call__(self, epoch=None): + return self.dict_hyper + + class TrainerFbOpt(AbstractTrainer): """ feedback optimization @@ -18,7 +26,6 @@ def set_scheduler(self, scheduler=HyperSchedulerFeedback): scheduler: The class name of the scheduler, the object corresponding to this class name will be created inside model """ - self.hyper_scheduler = self.model.hyper_init(scheduler) def before_tr(self): """ @@ -31,26 +38,46 @@ def before_tr(self): self.model, self.task, self.observer, self.device, self.aconf, flag_accept=False) - def opt_theta(self, mmu): + def opt_theta(self, dict4mu, theta0): + """ + operator for theta, move gradient for one epoch, then check if criteria is met + """ + self.inner_trainer.model.set_params(theta0) # FIXME: implement for each model + self.inner_trainer.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) + for _, (tensor_x, vec_y, vec_d, *others) in enumerate(self.inner_trainer.loader_tr): + self.inner_trainer.train_batch(tensor_x, vec_y, vec_d, others) # update inner_net + # the following is not needed anymore + # loss_look_forward = inner_net.cal_task_loss(tensor_x, vec_y) + # loss_source = self.model.cal_loss(tensor_x, vec_y, vec_d, others) + # loss = loss_source.sum() + self.aconf.gamma_reg * loss_look_forward.sum() + # loss.backward() + # self.optimizer.step() + dict_par = self.inner_trainer.model.name_parameters() + return dict_par + + def eval_loss(self, dict4mu, theta): """ - operator for theta, move gradient for a few steps, then check if criteria is met + evaluate the penalty function value """ + temp_model = copy.deepcopy(self.model) + temp_model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) + temp_model.set_params(theta) # FIXME: for each model, implement net1.load_state_dict(net2.state_dict()) + epo_reg_loss = 0 + epo_task_loss = 0 + epo_p_loss = 0 # penalized loss + # FIXME: will loader be corupted? if called at different places? + for ind_batch, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): + b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y).sum() + b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() # sum will kill the dimension of the mini batch + b_p_loss = temp_model.cal_p_loss(tensor_x, vec_y).sum() + epo_reg_loss += b_reg_loss + epo_task_loss += b_task_loss + epo_p_loss += b_p_loss + return epo_p_loss def tr_epoch(self, epoch): self.model.train() - self.hyper_scheduler.search_mu() - - for ind_batch, (tensor_x, vec_y, vec_d, *others) in enumerate(self.loader_tr): - inner_net = copy.deepcopy(self.model) - self.inner_trainer.model = inner_net # FORCE replace model - self.inner_trainer.train_batch( - tensor_x, vec_y, vec_d, others) # update inner_net - - loss_look_forward = inner_net.cal_task_loss(tensor_x, vec_y) - loss_source = self.model.cal_loss(tensor_x, vec_y, vec_d, others) - loss = loss_source.sum() + self.aconf.gamma_reg * loss_look_forward.sum() - loss.backward() - self.optimizer.step() - self.after_batch(epoch, ind_batch) + self.hyper_scheduler.search_mu() # if mu not found, will raise error + self.model.set_params(self.hyper_scheduler.theta) flag_stop = self.observer.update(epoch) # notify observer return flag_stop From 0a6087e51eed741181d378af7200a74f05793ce4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 11:09:11 +0200 Subject: [PATCH 004/762] . --- domainlab/algos/trainers/train_fbopt.py | 26 ++++++++++++------------- domainlab/models/a_model.py | 6 ++++++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index e0bdb2731..887220e05 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -26,32 +26,32 @@ def set_scheduler(self, scheduler=HyperSchedulerFeedback): scheduler: The class name of the scheduler, the object corresponding to this class name will be created inside model """ + # model.hyper_init will register the hyper-parameters of the model to scheduler + self.hyper_scheduler = self.model.hyper_init(scheduler) def before_tr(self): """ - check the performance of randomly initialized weight + before training begins, construct helper objects """ - self.set_scheduler() + self.set_scheduler(scheduler=HyperSchedulerFeedback) self.model.evaluate(self.loader_te, self.device) - self.inner_trainer = TrainerBasic() + self.inner_trainer = TrainerBasic() # look ahead + # here we need a mechanism to generate deep copy of the model self.inner_trainer.init_business( - self.model, self.task, self.observer, self.device, self.aconf, + copy.deepcopy(self.model), self.task, self.observer, self.device, self.aconf, flag_accept=False) - def opt_theta(self, dict4mu, theta0): + def opt_theta(self, dict4mu, dict_theta0): """ operator for theta, move gradient for one epoch, then check if criteria is met + this method will be invoked by the hyper-parameter scheduling object """ - self.inner_trainer.model.set_params(theta0) # FIXME: implement for each model + self.inner_trainer.model.set_params(dict_theta0) + # mock the model hyper-parameter to be from dict4mu self.inner_trainer.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) + # hide implementation details of inner_trainer for _, (tensor_x, vec_y, vec_d, *others) in enumerate(self.inner_trainer.loader_tr): self.inner_trainer.train_batch(tensor_x, vec_y, vec_d, others) # update inner_net - # the following is not needed anymore - # loss_look_forward = inner_net.cal_task_loss(tensor_x, vec_y) - # loss_source = self.model.cal_loss(tensor_x, vec_y, vec_d, others) - # loss = loss_source.sum() + self.aconf.gamma_reg * loss_look_forward.sum() - # loss.backward() - # self.optimizer.step() dict_par = self.inner_trainer.model.name_parameters() return dict_par @@ -77,7 +77,7 @@ def eval_loss(self, dict4mu, theta): def tr_epoch(self, epoch): self.model.train() - self.hyper_scheduler.search_mu() # if mu not found, will raise error + self.hyper_scheduler.search_mu() # if mu not found, will terminate self.model.set_params(self.hyper_scheduler.theta) flag_stop = self.observer.update(epoch) # notify observer return flag_stop diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index 544563533..7f011200e 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -11,6 +11,12 @@ class AModel(nn.Module, metaclass=abc.ABCMeta): """ operations that all models (classification, segmentation, seq2seq) """ + def set_params(self, dict_params): + """ + set + """ + self.load_state_dict(dict_params, strict=False) + def cal_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): """ calculate the loss From 10fb1fe990c069e71b4fdb4ba180f03daf149c35 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 11:16:35 +0200 Subject: [PATCH 005/762] . --- domainlab/algos/trainers/train_fbopt.py | 10 ++++++---- domainlab/models/a_model.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 887220e05..0522b57e3 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -55,20 +55,21 @@ def opt_theta(self, dict4mu, dict_theta0): dict_par = self.inner_trainer.model.name_parameters() return dict_par - def eval_loss(self, dict4mu, theta): + def eval_loss(self, dict4mu, dict_theta): """ evaluate the penalty function value """ temp_model = copy.deepcopy(self.model) + # mock the model hyper-parameter to be from dict4mu temp_model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) - temp_model.set_params(theta) # FIXME: for each model, implement net1.load_state_dict(net2.state_dict()) + temp_model.set_params(dict_theta) epo_reg_loss = 0 epo_task_loss = 0 epo_p_loss = 0 # penalized loss # FIXME: will loader be corupted? if called at different places? for ind_batch, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): - b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y).sum() - b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() # sum will kill the dimension of the mini batch + b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d).sum() + b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y, vec_d).sum() # sum will kill the dimension of the mini batch b_p_loss = temp_model.cal_p_loss(tensor_x, vec_y).sum() epo_reg_loss += b_reg_loss epo_task_loss += b_task_loss @@ -77,6 +78,7 @@ def eval_loss(self, dict4mu, theta): def tr_epoch(self, epoch): self.model.train() + # FIXME: hyper_scheduler should use the last theta self.hyper_scheduler.search_mu() # if mu not found, will terminate self.model.set_params(self.hyper_scheduler.theta) flag_stop = self.observer.update(epoch) # notify observer diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index 7f011200e..e8db936fa 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -15,6 +15,7 @@ def set_params(self, dict_params): """ set """ + # FIXME: net1.load_state_dict(net2.state_dict()) contains more information than model.named_parameters() like optimizer status self.load_state_dict(dict_params, strict=False) def cal_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): From 61582d82805b4aeeba0bb5f6c232c72e9e6a899c Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 11:31:28 +0200 Subject: [PATCH 006/762] . --- domainlab/algos/trainers/fbopt.py | 14 ++++++++------ domainlab/algos/trainers/train_fbopt.py | 16 ++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index b9d16cc73..7b63e42ac 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -18,15 +18,17 @@ def __init__(self, trainer, **kwargs): self.ploss_new_theta_old_mu = None self.ploss_new_theta_new_mu = None self.delta_mu = 0.01 # FIXME - self.theta = None + self.dict_theta = None self.mmu = None self.budget_mu_per_step = 5 # FIXME self.budget_theta_per_step = 5 - def search_mu(self): + def search_mu(self, dict_theta): """ + start from parameter dict_theta, enlarge mmu to see if the criteria is met """ + self.dict_theta = dict_theta flag_success = False for miter in range(self.budget_mu_per_step): mmu = self.mmu + miter * self.delta_mu @@ -41,15 +43,15 @@ def search_theta(self, mmu_new): the current value of $theta$ """ flag_success = False - self.ploss_old_theta_new_mu = self.trainer.eval_loss(mmu_new, self.theta) - self.ploss_old_theta_old_mu = self.trainer.eval_loss(self.mmu, self.theta) + self.ploss_old_theta_new_mu = self.trainer.eval_loss(mmu_new, self.dict_theta) + self.ploss_old_theta_old_mu = self.trainer.eval_loss(self.mmu, self.dict_theta) for _ in range(self.budget_theta_per_step): - theta4mu_new = self.trainer.opt_theta(mmu_new, self.trainer.model.named_parameters()) # FIXME: get theta from model + theta4mu_new = self.trainer.opt_theta(mmu_new, self.dict_theta) self.ploss_new_theta_new_mu = self.trainer.eval_loss(mmu_new, theta4mu_new) self.ploss_new_theta_old_mu = self.trainer.eval_loss(self.mmu, theta4mu_new) if self.is_criteria_met(): self.mmu = mmu_new - self.theta = theta4mu_new + self.dict_theta = theta4mu_new flag_success = True return flag_success diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 0522b57e3..30454d4c4 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -9,6 +9,9 @@ class HyperSetter(): + """ + mock object to force hyper-parameter in the model + """ def __init__(self, dict_hyper): self.dict_hyper = dict_hyper @@ -66,10 +69,11 @@ def eval_loss(self, dict4mu, dict_theta): epo_reg_loss = 0 epo_task_loss = 0 epo_p_loss = 0 # penalized loss - # FIXME: will loader be corupted? if called at different places? - for ind_batch, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): + # FIXME: will loader be corupted? if called at different places? if we do not make deep copy + for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d).sum() - b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y, vec_d).sum() # sum will kill the dimension of the mini batch + b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y, vec_d).sum() + # sum will kill the dimension of the mini batch b_p_loss = temp_model.cal_p_loss(tensor_x, vec_y).sum() epo_reg_loss += b_reg_loss epo_task_loss += b_task_loss @@ -78,8 +82,8 @@ def eval_loss(self, dict4mu, dict_theta): def tr_epoch(self, epoch): self.model.train() - # FIXME: hyper_scheduler should use the last theta - self.hyper_scheduler.search_mu() # if mu not found, will terminate - self.model.set_params(self.hyper_scheduler.theta) + self.hyper_scheduler.search_mu( + self.model.named_parameters()) # if mu not found, will terminate + self.model.set_params(self.hyper_scheduler.dict_theta) flag_stop = self.observer.update(epoch) # notify observer return flag_stop From fb573220ae93a7140c73b95c64cc64f2f9831641 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 11:53:47 +0200 Subject: [PATCH 007/762] . --- domainlab/algos/trainers/fbopt.py | 11 ++++++++--- domainlab/algos/trainers/train_fbopt.py | 2 +- domainlab/algos/trainers/zoo_trainer.py | 4 +++- domainlab/models/model_dann.py | 6 +++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 7b63e42ac..27fe2010c 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -12,14 +12,13 @@ def __init__(self, trainer, **kwargs): kwargs is a dictionary with key the hyper-parameter name and its value """ self.trainer = trainer - self.dict_par_init = kwargs + self.mmu = kwargs self.ploss_old_theta_old_mu = None self.ploss_old_theta_new_mu = None self.ploss_new_theta_old_mu = None self.ploss_new_theta_new_mu = None self.delta_mu = 0.01 # FIXME self.dict_theta = None - self.mmu = None self.budget_mu_per_step = 5 # FIXME self.budget_theta_per_step = 5 @@ -31,12 +30,18 @@ def search_mu(self, dict_theta): self.dict_theta = dict_theta flag_success = False for miter in range(self.budget_mu_per_step): - mmu = self.mmu + miter * self.delta_mu + mmu = self.dict_addition(self.mmu, miter * self.delta_mu) if self.search_theta(mmu): flag_success = True if not flag_success: raise RuntimeError("failed to find mu within budget") + def dict_addition(self, dict_base, delta): + """ + increase the value of a dictionary by delta + """ + return {key: val + delta for key, val in dict_base.items()} + def search_theta(self, mmu_new): """ conditioned on fixed $$\\mu$$, the operator should search theta based on diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 30454d4c4..f5fe9f97d 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -30,7 +30,7 @@ def set_scheduler(self, scheduler=HyperSchedulerFeedback): this class name will be created inside model """ # model.hyper_init will register the hyper-parameters of the model to scheduler - self.hyper_scheduler = self.model.hyper_init(scheduler) + self.hyper_scheduler = self.model.hyper_init(scheduler, trainer=self) def before_tr(self): """ diff --git a/domainlab/algos/trainers/zoo_trainer.py b/domainlab/algos/trainers/zoo_trainer.py index 069e1d3d4..e825ad75b 100644 --- a/domainlab/algos/trainers/zoo_trainer.py +++ b/domainlab/algos/trainers/zoo_trainer.py @@ -6,6 +6,7 @@ from domainlab.algos.trainers.train_matchdg import TrainerMatchDG from domainlab.algos.trainers.train_mldg import TrainerMLDG from domainlab.algos.trainers.train_hyper_scheduler import TrainerHyperScheduler +from domainlab.algos.trainers.train_fbopt import TrainerFbOpt class TrainerChainNodeGetter(object): @@ -38,6 +39,7 @@ def __call__(self, lst_candidates=None, default=None, lst_excludes=None): chain = TrainerDIAL(chain) chain = TrainerMatchDG(chain) chain = TrainerMLDG(chain) - chain = TrainerHyperScheduler(chain) # FIXME: change to warmup + chain = TrainerHyperScheduler(chain) + chain = TrainerFbOpt(chain) node = chain.handle(self.request) return node diff --git a/domainlab/models/model_dann.py b/domainlab/models/model_dann.py index 2be72828f..e48a6b5f4 100644 --- a/domainlab/models/model_dann.py +++ b/domainlab/models/model_dann.py @@ -16,7 +16,7 @@ def mk_dann(parent_class=AModelClassif): The model is trained to solve two tasks: 1. Standard image classification. 2. Domain classification. - Here for, a feature extractor is adversarially trained to minimize the loss of the image + Here for, a feature extractor is adversarially trained to minimize the loss of the image classifier and maximize the loss of the domain classifier. For more details, see: Ganin, Yaroslav, et al. "Domain-adversarial training of neural networks." @@ -66,11 +66,11 @@ def hyper_update(self, epoch, fun_scheduler): dict_rst = fun_scheduler(epoch) # the __call__ method of hyperparameter scheduler self.alpha = dict_rst["alpha"] - def hyper_init(self, functor_scheduler): + def hyper_init(self, functor_scheduler, trainer=None): """hyper_init. :param functor_scheduler: """ - return functor_scheduler(alpha=self.alpha) + return functor_scheduler(trainer=trainer, alpha=self.alpha) def cal_logit_y(self, tensor_x): # FIXME: this is only for classification """ From 72f7b7d6a5b3975b233c44335da05d27e34a779a Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 11:57:30 +0200 Subject: [PATCH 008/762] . --- tests/test_fbopt.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/test_fbopt.py diff --git a/tests/test_fbopt.py b/tests/test_fbopt.py new file mode 100644 index 000000000..f741f9cb1 --- /dev/null +++ b/tests/test_fbopt.py @@ -0,0 +1,12 @@ +""" +unit and end-end test for deep all, mldg +""" +from tests.utils_test import utils_test_algo + + +def test_deepall_fbopt(): + """ + train DeepAll with MLDG + """ + args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=dann --trainer=fbopt --nname=alexnet" + utils_test_algo(args) From 69d8858a613139f27068ba852722434df49801a5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 11:59:04 +0200 Subject: [PATCH 009/762] . --- domainlab/algos/trainers/train_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index f5fe9f97d..1059ffe30 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -83,7 +83,7 @@ def eval_loss(self, dict4mu, dict_theta): def tr_epoch(self, epoch): self.model.train() self.hyper_scheduler.search_mu( - self.model.named_parameters()) # if mu not found, will terminate + dict(self.model.named_parameters())) # if mu not found, will terminate self.model.set_params(self.hyper_scheduler.dict_theta) flag_stop = self.observer.update(epoch) # notify observer return flag_stop From 6164bd84c41a1cd13e16beeff8e517855c6ed36f Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 13:07:25 +0200 Subject: [PATCH 010/762] cuda out of memory --- domainlab/algos/trainers/train_fbopt.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 1059ffe30..586a33b9d 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -55,7 +55,7 @@ def opt_theta(self, dict4mu, dict_theta0): # hide implementation details of inner_trainer for _, (tensor_x, vec_y, vec_d, *others) in enumerate(self.inner_trainer.loader_tr): self.inner_trainer.train_batch(tensor_x, vec_y, vec_d, others) # update inner_net - dict_par = self.inner_trainer.model.name_parameters() + dict_par = dict(self.inner_trainer.model.named_parameters()) return dict_par def eval_loss(self, dict4mu, dict_theta): @@ -71,10 +71,12 @@ def eval_loss(self, dict4mu, dict_theta): epo_p_loss = 0 # penalized loss # FIXME: will loader be corupted? if called at different places? if we do not make deep copy for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): + tensor_x, vec_y, vec_d = \ + tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d).sum() - b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y, vec_d).sum() + b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() # sum will kill the dimension of the mini batch - b_p_loss = temp_model.cal_p_loss(tensor_x, vec_y).sum() + b_p_loss = temp_model.cal_loss(tensor_x, vec_y, vec_d).sum() epo_reg_loss += b_reg_loss epo_task_loss += b_task_loss epo_p_loss += b_p_loss From e8c60d5e85553a3e8f34a2196cc96495b3d9f81e Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 13:35:54 +0200 Subject: [PATCH 011/762] . --- domainlab/algos/trainers/fbopt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 27fe2010c..283115ac2 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -29,12 +29,14 @@ def search_mu(self, dict_theta): """ self.dict_theta = dict_theta flag_success = False + mmu = None for miter in range(self.budget_mu_per_step): mmu = self.dict_addition(self.mmu, miter * self.delta_mu) if self.search_theta(mmu): + print(f"found reg-pareto operator with mu={mmu}") flag_success = True if not flag_success: - raise RuntimeError("failed to find mu within budget") + raise RuntimeError("failed to find mu within budget, mu={mmu}") def dict_addition(self, dict_base, delta): """ @@ -46,6 +48,8 @@ def search_theta(self, mmu_new): """ conditioned on fixed $$\\mu$$, the operator should search theta based on the current value of $theta$ + + the execution will set the value for mu and theta as well """ flag_success = False self.ploss_old_theta_new_mu = self.trainer.eval_loss(mmu_new, self.dict_theta) From eee027b30d01d6e5fc52881d8bb891277d226f34 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 13:39:44 +0200 Subject: [PATCH 012/762] . --- domainlab/algos/trainers/fbopt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 283115ac2..58b7438da 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -20,7 +20,7 @@ def __init__(self, trainer, **kwargs): self.delta_mu = 0.01 # FIXME self.dict_theta = None self.budget_mu_per_step = 5 # FIXME - self.budget_theta_per_step = 5 + self.budget_theta_update_per_mu = 5 def search_mu(self, dict_theta): """ @@ -54,7 +54,7 @@ def search_theta(self, mmu_new): flag_success = False self.ploss_old_theta_new_mu = self.trainer.eval_loss(mmu_new, self.dict_theta) self.ploss_old_theta_old_mu = self.trainer.eval_loss(self.mmu, self.dict_theta) - for _ in range(self.budget_theta_per_step): + for _ in range(self.budget_theta_update_per_mu): theta4mu_new = self.trainer.opt_theta(mmu_new, self.dict_theta) self.ploss_new_theta_new_mu = self.trainer.eval_loss(mmu_new, theta4mu_new) self.ploss_new_theta_old_mu = self.trainer.eval_loss(self.mmu, theta4mu_new) From 273e24f747aba05c3fb648b1fde25e317ae70751 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 13:41:36 +0200 Subject: [PATCH 013/762] . --- run_fbopt.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 run_fbopt.sh diff --git a/run_fbopt.sh b/run_fbopt.sh new file mode 100644 index 000000000..5ac75d948 --- /dev/null +++ b/run_fbopt.sh @@ -0,0 +1,5 @@ +#!/bin/bash +export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +pytest -s tests/test_fbopt.py From d4a80c6b432253ed8f1ea3c488acc36d63ffc89b Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 13:45:06 +0200 Subject: [PATCH 014/762] . --- domainlab/algos/trainers/fbopt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 58b7438da..d6eeeeb6b 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -20,7 +20,7 @@ def __init__(self, trainer, **kwargs): self.delta_mu = 0.01 # FIXME self.dict_theta = None self.budget_mu_per_step = 5 # FIXME - self.budget_theta_update_per_mu = 5 + self.budget_theta_update_per_mu = 5 # np.infty def search_mu(self, dict_theta): """ @@ -58,9 +58,9 @@ def search_theta(self, mmu_new): theta4mu_new = self.trainer.opt_theta(mmu_new, self.dict_theta) self.ploss_new_theta_new_mu = self.trainer.eval_loss(mmu_new, theta4mu_new) self.ploss_new_theta_old_mu = self.trainer.eval_loss(self.mmu, theta4mu_new) + self.dict_theta = theta4mu_new if self.is_criteria_met(): self.mmu = mmu_new - self.dict_theta = theta4mu_new flag_success = True return flag_success From 3509017f9176f6e0c7f4ff0207427aeba5db84ea Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 13:54:30 +0200 Subject: [PATCH 015/762] . --- domainlab/algos/trainers/fbopt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index d6eeeeb6b..611c1939c 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -32,6 +32,7 @@ def search_mu(self, dict_theta): mmu = None for miter in range(self.budget_mu_per_step): mmu = self.dict_addition(self.mmu, miter * self.delta_mu) + print(f"trying mu={mmu} at mu iteration {miter}") if self.search_theta(mmu): print(f"found reg-pareto operator with mu={mmu}") flag_success = True @@ -54,7 +55,8 @@ def search_theta(self, mmu_new): flag_success = False self.ploss_old_theta_new_mu = self.trainer.eval_loss(mmu_new, self.dict_theta) self.ploss_old_theta_old_mu = self.trainer.eval_loss(self.mmu, self.dict_theta) - for _ in range(self.budget_theta_update_per_mu): + for i in range(self.budget_theta_update_per_mu): + print(f"update theta at iteration {i} with mu={mmu_new}") theta4mu_new = self.trainer.opt_theta(mmu_new, self.dict_theta) self.ploss_new_theta_new_mu = self.trainer.eval_loss(mmu_new, theta4mu_new) self.ploss_new_theta_old_mu = self.trainer.eval_loss(self.mmu, theta4mu_new) From 086348125cf0d396cda329e8accfec38dd640f6d Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 14:07:37 +0200 Subject: [PATCH 016/762] . --- domainlab/algos/trainers/fbopt.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 611c1939c..765bc189a 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -1,6 +1,7 @@ """ update hyper-parameters during training """ +import copy class HyperSchedulerFeedback(): @@ -55,15 +56,18 @@ def search_theta(self, mmu_new): flag_success = False self.ploss_old_theta_new_mu = self.trainer.eval_loss(mmu_new, self.dict_theta) self.ploss_old_theta_old_mu = self.trainer.eval_loss(self.mmu, self.dict_theta) + theta4mu_new = copy.deepcopy(self.dict_theta) for i in range(self.budget_theta_update_per_mu): print(f"update theta at iteration {i} with mu={mmu_new}") - theta4mu_new = self.trainer.opt_theta(mmu_new, self.dict_theta) + theta4mu_new = self.trainer.opt_theta(mmu_new, theta4mu_new) self.ploss_new_theta_new_mu = self.trainer.eval_loss(mmu_new, theta4mu_new) self.ploss_new_theta_old_mu = self.trainer.eval_loss(self.mmu, theta4mu_new) - self.dict_theta = theta4mu_new if self.is_criteria_met(): self.mmu = mmu_new flag_success = True + # FIXME: update theta only if current mu is good enough? + self.dict_theta = theta4mu_new + return flag_success return flag_success def inner_product(self, mmu, v_reg_loss): From 6c43cf36af70a1cd8ae64099518c3b764593f79d Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 14:30:37 +0200 Subject: [PATCH 017/762] . --- domainlab/algos/trainers/fbopt.py | 4 +++- domainlab/algos/trainers/train_fbopt.py | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 765bc189a..4a5fb9b53 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -2,6 +2,7 @@ update hyper-parameters during training """ import copy +import warnings class HyperSchedulerFeedback(): @@ -38,7 +39,8 @@ def search_mu(self, dict_theta): print(f"found reg-pareto operator with mu={mmu}") flag_success = True if not flag_success: - raise RuntimeError("failed to find mu within budget, mu={mmu}") + warnings.warn("!!!!!!failed to find mu within budget, mu={mmu}") + return flag_success def dict_addition(self, dict_base, delta): """ diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 586a33b9d..458683947 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -84,8 +84,12 @@ def eval_loss(self, dict4mu, dict_theta): def tr_epoch(self, epoch): self.model.train() - self.hyper_scheduler.search_mu( + flag_success = self.hyper_scheduler.search_mu( dict(self.model.named_parameters())) # if mu not found, will terminate - self.model.set_params(self.hyper_scheduler.dict_theta) - flag_stop = self.observer.update(epoch) # notify observer + if flag_success: + self.model.set_params(self.hyper_scheduler.dict_theta) + else: + # if failed to find reg-pareto descent operator, continue training + self.inner_trainer.tr_epoch(epoch) + flag_stop = self.observer.update(epoch) # FIXME: should count how many epochs were used return flag_stop From 97eb62a50c0e2949e8a037a50091571f503097ae Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 14:46:22 +0200 Subject: [PATCH 018/762] . --- domainlab/algos/trainers/fbopt.py | 1 + domainlab/algos/trainers/train_fbopt.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 4a5fb9b53..216e83c90 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -38,6 +38,7 @@ def search_mu(self, dict_theta): if self.search_theta(mmu): print(f"found reg-pareto operator with mu={mmu}") flag_success = True + self.mmu = mmu if not flag_success: warnings.warn("!!!!!!failed to find mu within budget, mu={mmu}") return flag_success diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 458683947..a5ba23797 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -67,6 +67,7 @@ def eval_loss(self, dict4mu, dict_theta): temp_model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) temp_model.set_params(dict_theta) epo_reg_loss = 0 + # FIXME: check if reg is decreasing epo_task_loss = 0 epo_p_loss = 0 # penalized loss # FIXME: will loader be corupted? if called at different places? if we do not make deep copy @@ -87,6 +88,7 @@ def tr_epoch(self, epoch): flag_success = self.hyper_scheduler.search_mu( dict(self.model.named_parameters())) # if mu not found, will terminate if flag_success: + # only in success case, mu will be updated self.model.set_params(self.hyper_scheduler.dict_theta) else: # if failed to find reg-pareto descent operator, continue training From 901bc819d02288ed20b9cb366f88c3b931b25f6e Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 14:50:20 +0200 Subject: [PATCH 019/762] . --- domainlab/algos/trainers/fbopt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 216e83c90..d1f849455 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -33,6 +33,7 @@ def search_mu(self, dict_theta): flag_success = False mmu = None for miter in range(self.budget_mu_per_step): + # FIXME: the same mu is tried two times since miter=0 mmu = self.dict_addition(self.mmu, miter * self.delta_mu) print(f"trying mu={mmu} at mu iteration {miter}") if self.search_theta(mmu): From ed5945c30a1bf913213eb5372fcd5a3bca94db68 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 14:55:55 +0200 Subject: [PATCH 020/762] . --- domainlab/algos/trainers/fbopt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index d1f849455..4a055cadb 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -2,7 +2,7 @@ update hyper-parameters during training """ import copy -import warnings +from domainlab.utils.logger import Logger class HyperSchedulerFeedback(): @@ -41,7 +41,8 @@ def search_mu(self, dict_theta): flag_success = True self.mmu = mmu if not flag_success: - warnings.warn("!!!!!!failed to find mu within budget, mu={mmu}") + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.warn("!!!!!!failed to find mu within budget, mu={mmu}") return flag_success def dict_addition(self, dict_base, delta): From f950ed5d8d39196d4fd6843f70f6262c6367794d Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 14:57:44 +0200 Subject: [PATCH 021/762] . --- domainlab/algos/trainers/fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 4a055cadb..1dcbd98e0 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -37,7 +37,7 @@ def search_mu(self, dict_theta): mmu = self.dict_addition(self.mmu, miter * self.delta_mu) print(f"trying mu={mmu} at mu iteration {miter}") if self.search_theta(mmu): - print(f"found reg-pareto operator with mu={mmu}") + print(f"!!!found reg-pareto operator with mu={mmu}") flag_success = True self.mmu = mmu if not flag_success: From 954b97a5a35fc796bba4ec3f0e75565e88ad0e43 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 15:16:07 +0200 Subject: [PATCH 022/762] . --- domainlab/algos/trainers/train_fbopt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index a5ba23797..d82db3d39 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -92,6 +92,8 @@ def tr_epoch(self, epoch): self.model.set_params(self.hyper_scheduler.dict_theta) else: # if failed to find reg-pareto descent operator, continue training - self.inner_trainer.tr_epoch(epoch) + theta = dict(self.model.named_parameters()) + dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) + self.model.set_params(dict_par) flag_stop = self.observer.update(epoch) # FIXME: should count how many epochs were used return flag_stop From 62cafe9a48485c11665b5acd31fa696304136dc8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 15:20:11 +0200 Subject: [PATCH 023/762] . --- domainlab/algos/trainers/fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 1dcbd98e0..bf4784310 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -42,7 +42,7 @@ def search_mu(self, dict_theta): self.mmu = mmu if not flag_success: logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.warn("!!!!!!failed to find mu within budget, mu={mmu}") + logger.warn(f"!!!!!!failed to find mu within budget, mu={mmu}") return flag_success def dict_addition(self, dict_base, delta): From f8f7a654bdd3c86228fe30910580559b578555c8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 15:26:18 +0200 Subject: [PATCH 024/762] . --- domainlab/algos/trainers/fbopt.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index bf4784310..07cab827f 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -30,7 +30,6 @@ def search_mu(self, dict_theta): enlarge mmu to see if the criteria is met """ self.dict_theta = dict_theta - flag_success = False mmu = None for miter in range(self.budget_mu_per_step): # FIXME: the same mu is tried two times since miter=0 @@ -38,12 +37,11 @@ def search_mu(self, dict_theta): print(f"trying mu={mmu} at mu iteration {miter}") if self.search_theta(mmu): print(f"!!!found reg-pareto operator with mu={mmu}") - flag_success = True self.mmu = mmu - if not flag_success: - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.warn(f"!!!!!!failed to find mu within budget, mu={mmu}") - return flag_success + return True + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.warn(f"!!!!!!failed to find mu within budget, mu={mmu}") + return False def dict_addition(self, dict_base, delta): """ From aaf3aeb5741a3b5521f61965a080929235fc7f0b Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 15:34:03 +0200 Subject: [PATCH 025/762] . --- domainlab/algos/trainers/fbopt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 07cab827f..d87a94872 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -15,6 +15,7 @@ def __init__(self, trainer, **kwargs): """ self.trainer = trainer self.mmu = kwargs + self.mmu = {key: 0.0 for key, val in self.mmu.items()} self.ploss_old_theta_old_mu = None self.ploss_old_theta_new_mu = None self.ploss_new_theta_old_mu = None From d8db3fd1d9a8d0d4f0e246bbd03610bc23f8543a Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 15:35:49 +0200 Subject: [PATCH 026/762] . --- run_fbopt.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index 5ac75d948..efa857f9f 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -1,5 +1,6 @@ #!/bin/bash -export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring -pytest -s tests/test_fbopt.py +# pytest -s tests/test_fbopt.py +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet From 25675c90ffdea2d26dd47cb665440363cc378a05 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 15:36:11 +0200 Subject: [PATCH 027/762] . --- run_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index efa857f9f..ef7417d0b 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 From 07f24dee15e11075b8fdd88293aed9d0288b1fe9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 16:26:07 +0200 Subject: [PATCH 028/762] . --- run_fbopt_pacs.sh | 6 ++++++ tests/test_fbopt.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 run_fbopt_pacs.sh diff --git a/run_fbopt_pacs.sh b/run_fbopt_pacs.sh new file mode 100644 index 000000000..b571cb830 --- /dev/null +++ b/run_fbopt_pacs.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py +python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=4 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 diff --git a/tests/test_fbopt.py b/tests/test_fbopt.py index f741f9cb1..be4ec6815 100644 --- a/tests/test_fbopt.py +++ b/tests/test_fbopt.py @@ -8,5 +8,5 @@ def test_deepall_fbopt(): """ train DeepAll with MLDG """ - args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=dann --trainer=fbopt --nname=alexnet" + args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=dann --trainer=fbopt --nname=alexnet --epos=20" utils_test_algo(args) From 0ce810b335596022f25dfea99ad379dde0c884e0 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 11 Sep 2023 16:40:35 +0200 Subject: [PATCH 029/762] Update test_fbopt.py --- tests/test_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fbopt.py b/tests/test_fbopt.py index be4ec6815..bfe9ef3c6 100644 --- a/tests/test_fbopt.py +++ b/tests/test_fbopt.py @@ -8,5 +8,5 @@ def test_deepall_fbopt(): """ train DeepAll with MLDG """ - args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=dann --trainer=fbopt --nname=alexnet --epos=20" + args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=dann --trainer=fbopt --nname=alexnet --epos=3" utils_test_algo(args) From 867b00668d4be0c900f13c8946d2099b0f8bb8ed Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 11 Sep 2023 16:56:18 +0200 Subject: [PATCH 030/762] . --- run_fbopt_pacs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_fbopt_pacs.sh b/run_fbopt_pacs.sh index b571cb830..0c80816fd 100644 --- a/run_fbopt_pacs.sh +++ b/run_fbopt_pacs.sh @@ -3,4 +3,5 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=4 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 +# python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=2 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 +python main_out.py --te_d=sketch --tpath=examples/tasks/demo_task_path_list_small.py --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 From 7cd92d2fdae72ebba04f5c7f34d1883c4e8c46d2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 09:50:36 +0200 Subject: [PATCH 031/762] add optimizer reset --- domainlab/algos/trainers/a_trainer.py | 6 ++++++ domainlab/algos/trainers/train_fbopt.py | 1 + 2 files changed, 7 insertions(+) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 4dbe745cc..efd5ce179 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -80,6 +80,12 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True): self.optimizer = mk_opt(self.model, self.aconf) self.flag_initialized = True + def reset(self): + """ + make a new optimizer to clear internal state + """ + self.optimizer = mk_opt(self.model, self.aconf) + @abc.abstractmethod def tr_epoch(self, epoch): """ diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index d82db3d39..da78b3038 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -49,6 +49,7 @@ def opt_theta(self, dict4mu, dict_theta0): operator for theta, move gradient for one epoch, then check if criteria is met this method will be invoked by the hyper-parameter scheduling object """ + self.inner_trainer.reset() self.inner_trainer.model.set_params(dict_theta0) # mock the model hyper-parameter to be from dict4mu self.inner_trainer.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) From e431e3c25aedbea182795a3e7821b08b01cd471b Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 10:59:30 +0200 Subject: [PATCH 032/762] mu iter start --- domainlab/algos/trainers/a_trainer.py | 2 ++ domainlab/algos/trainers/fbopt.py | 5 ++--- domainlab/algos/trainers/train_fbopt.py | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index efd5ce179..c83c54afe 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -51,6 +51,8 @@ def __init__(self, successor_node=None): self.inner_trainer = None self.loader_tr_source_target = None self.flag_initialized = False + # fbopt + self.mu_iter_start = 0 def init_business(self, model, task, observer, device, aconf, flag_accept=True): diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index d87a94872..6bdbf00e4 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -25,15 +25,14 @@ def __init__(self, trainer, **kwargs): self.budget_mu_per_step = 5 # FIXME self.budget_theta_update_per_mu = 5 # np.infty - def search_mu(self, dict_theta): + def search_mu(self, dict_theta, iter_start=0): """ start from parameter dict_theta, enlarge mmu to see if the criteria is met """ self.dict_theta = dict_theta mmu = None - for miter in range(self.budget_mu_per_step): - # FIXME: the same mu is tried two times since miter=0 + for miter in range(iter_start, self.budget_mu_per_step): mmu = self.dict_addition(self.mmu, miter * self.delta_mu) print(f"trying mu={mmu} at mu iteration {miter}") if self.search_theta(mmu): diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index da78b3038..7394bb61a 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -87,7 +87,8 @@ def eval_loss(self, dict4mu, dict_theta): def tr_epoch(self, epoch): self.model.train() flag_success = self.hyper_scheduler.search_mu( - dict(self.model.named_parameters())) # if mu not found, will terminate + dict(self.model.named_parameters()), + iter_start=self.mu_iter_start) if flag_success: # only in success case, mu will be updated self.model.set_params(self.hyper_scheduler.dict_theta) @@ -97,4 +98,5 @@ def tr_epoch(self, epoch): dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) self.model.set_params(dict_par) flag_stop = self.observer.update(epoch) # FIXME: should count how many epochs were used + self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return flag_stop From d7d8214441ea23e1021124be858e3ffedbe9c3ac Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 11:18:57 +0200 Subject: [PATCH 033/762] no early stop --- domainlab/algos/trainers/train_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 7394bb61a..3529ca912 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -99,4 +99,4 @@ def tr_epoch(self, epoch): self.model.set_params(dict_par) flag_stop = self.observer.update(epoch) # FIXME: should count how many epochs were used self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) - return flag_stop + return True # total number of epochs controled in args From 3461fa9849f509756f40a683109e85cfa57bb9c6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 11:19:22 +0200 Subject: [PATCH 034/762] return false in flag_stop --- domainlab/algos/trainers/train_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 3529ca912..03f0e669a 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -99,4 +99,4 @@ def tr_epoch(self, epoch): self.model.set_params(dict_par) flag_stop = self.observer.update(epoch) # FIXME: should count how many epochs were used self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) - return True # total number of epochs controled in args + return False # total number of epochs controled in args From f1d6fcfbd67b77823e29823146215f5ffe55ae77 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 11:49:42 +0200 Subject: [PATCH 035/762] . --- run_fbopt.sh | 2 +- run_fbopt_pacs.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index ef7417d0b..f48c9f368 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --loglevel=DEBUG diff --git a/run_fbopt_pacs.sh b/run_fbopt_pacs.sh index 0c80816fd..1c950d1f3 100644 --- a/run_fbopt_pacs.sh +++ b/run_fbopt_pacs.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py # python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=2 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 -python main_out.py --te_d=sketch --tpath=examples/tasks/demo_task_path_list_small.py --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 +python main_out.py --te_d=sketch --tpath=examples/tasks/demo_task_path_list_small.py --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --loglevel=DEBUG From bca6f3f1a9d5e9bb81e8a2ed0dff5f0d2220950d Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 12:38:52 +0200 Subject: [PATCH 036/762] hyperparameters for fbopt --- domainlab/algos/trainers/args_fbopt.py | 18 +++++++++++++++++ domainlab/algos/trainers/fbopt.py | 28 ++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 domainlab/algos/trainers/args_fbopt.py diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py new file mode 100644 index 000000000..0e33d2f94 --- /dev/null +++ b/domainlab/algos/trainers/args_fbopt.py @@ -0,0 +1,18 @@ +""" +feedback opt +""" + + +def add_args2parser_fbopt(parser): + """ + append hyper-parameters to the main argparser + """ + parser.add_argument('--beta_mu', type=float, default=1.4, + help='how much to multiply mu each time') + parser.add_argument('--delta_mu', type=float, default=None, + help='how much to increment mu each time') + parser.add_argument('--budget_mu_per_step', type=int, default=5, + help='number of mu iterations to try') + parser.add_argument('--budget_theta_update_per_mu', type=int, default=5, + help='number of theta update for each fixed mu') + return parser diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 6bdbf00e4..ac00ce316 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -20,10 +20,11 @@ def __init__(self, trainer, **kwargs): self.ploss_old_theta_new_mu = None self.ploss_new_theta_old_mu = None self.ploss_new_theta_new_mu = None - self.delta_mu = 0.01 # FIXME + self.delta_mu = trainer.aconf.delta_mu + self.beta_mu = trainer.aconf.beta_mu self.dict_theta = None - self.budget_mu_per_step = 5 # FIXME - self.budget_theta_update_per_mu = 5 # np.infty + self.budget_mu_per_step = trainer.aconf.budget_mu_per_step + self.budget_theta_update_per_mu = trainer.aconf.budget_theta_update_per_mu def search_mu(self, dict_theta, iter_start=0): """ @@ -33,7 +34,7 @@ def search_mu(self, dict_theta, iter_start=0): self.dict_theta = dict_theta mmu = None for miter in range(iter_start, self.budget_mu_per_step): - mmu = self.dict_addition(self.mmu, miter * self.delta_mu) + mmu = self.dict_iter(miter) print(f"trying mu={mmu} at mu iteration {miter}") if self.search_theta(mmu): print(f"!!!found reg-pareto operator with mu={mmu}") @@ -43,6 +44,25 @@ def search_mu(self, dict_theta, iter_start=0): logger.warn(f"!!!!!!failed to find mu within budget, mu={mmu}") return False + def dict_iter(self, miter): + """ + update a dictionary according to iteration + """ + if self.delta_mu is not None: + mmu = self.dict_addition(self.mmu, miter * self.delta_mu) + elif self.beta_mu is not None: + mmu = self.dict_multiply(self.mmu, self.beta_mu) + else: + raise RuntimeError("delta_mu and beta_mu can not be simultaneously None!") + return mmu + + def dict_multiply(self, dict_base, multiplier): + """ + multiply a float to each element of a dictionary + """ + assert multiplier > 1 + return {key: val*multiplier for key, val in dict_base.items()} + def dict_addition(self, dict_base, delta): """ increase the value of a dictionary by delta From 959b9a24de53d0d5522103a85574c0a02d0e2b39 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 12:43:31 +0200 Subject: [PATCH 037/762] forgot to add args to main --- domainlab/arg_parser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/arg_parser.py b/domainlab/arg_parser.py index 53deb148a..1403243df 100644 --- a/domainlab/arg_parser.py +++ b/domainlab/arg_parser.py @@ -8,6 +8,7 @@ from domainlab.algos.compos.matchdg_args import add_args2parser_matchdg from domainlab.algos.trainers.args_dial import add_args2parser_dial +from domainlab.algos.trainers.args_fbopt import add_args2parser_fbopt from domainlab.models.args_jigen import add_args2parser_jigen from domainlab.models.args_vae import add_args2parser_vae from domainlab.utils.logger import Logger @@ -190,6 +191,8 @@ def mk_parser_main(): arg_group_jigen = add_args2parser_jigen(arg_group_jigen) args_group_dial = parser.add_argument_group('dial') args_group_dial = add_args2parser_dial(args_group_dial) + args_group_fbopt = parser.add_argument_group('fbopt') + args_group_fbopt = add_args2parser_fbopt(args_group_fbopt) return parser From 8343b1f4f5f6dc87febbb5ec40406f3748cfc362 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 12:52:27 +0200 Subject: [PATCH 038/762] multipler with np.power --- domainlab/algos/trainers/args_fbopt.py | 4 +++- domainlab/algos/trainers/fbopt.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 0e33d2f94..4a7e9266f 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -7,7 +7,9 @@ def add_args2parser_fbopt(parser): """ append hyper-parameters to the main argparser """ - parser.add_argument('--beta_mu', type=float, default=1.4, + parser.add_argument('--init_mu4beta', type=float, default=0.01, + help='initial beta for multiplication') + parser.add_argument('--beta_mu', type=float, default=1.2, help='how much to multiply mu each time') parser.add_argument('--delta_mu', type=float, default=None, help='how much to increment mu each time') diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index ac00ce316..501d0c025 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -2,6 +2,7 @@ update hyper-parameters during training """ import copy +import numpy as np from domainlab.utils.logger import Logger @@ -21,6 +22,7 @@ def __init__(self, trainer, **kwargs): self.ploss_new_theta_old_mu = None self.ploss_new_theta_new_mu = None self.delta_mu = trainer.aconf.delta_mu + self.init_mu = trainer.aconf.init_mu4beta self.beta_mu = trainer.aconf.beta_mu self.dict_theta = None self.budget_mu_per_step = trainer.aconf.budget_mu_per_step @@ -48,10 +50,14 @@ def dict_iter(self, miter): """ update a dictionary according to iteration """ + if miter == 0: + return self.mmu if self.delta_mu is not None: mmu = self.dict_addition(self.mmu, miter * self.delta_mu) elif self.beta_mu is not None: - mmu = self.dict_multiply(self.mmu, self.beta_mu) + multiplier = np.power(self.beta_mu, miter) + base = self.dict_addition(self.mmu, self.init_mu) + mmu = self.dict_multiply(base, multiplier) else: raise RuntimeError("delta_mu and beta_mu can not be simultaneously None!") return mmu From 36d2e36017d2639e09880463010dc5e8bdceff55 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 15:51:46 +0200 Subject: [PATCH 039/762] . --- domainlab/algos/trainers/args_fbopt.py | 4 ++-- run_fbopt.sh | 2 +- run_fbopt_pacs.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 4a7e9266f..fa731032b 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -7,9 +7,9 @@ def add_args2parser_fbopt(parser): """ append hyper-parameters to the main argparser """ - parser.add_argument('--init_mu4beta', type=float, default=0.01, + parser.add_argument('--init_mu4beta', type=float, default=0.001, help='initial beta for multiplication') - parser.add_argument('--beta_mu', type=float, default=1.2, + parser.add_argument('--beta_mu', type=float, default=1.1, help='how much to multiply mu each time') parser.add_argument('--delta_mu', type=float, default=None, help='how much to increment mu each time') diff --git a/run_fbopt.sh b/run_fbopt.sh index f48c9f368..ebbe0dd19 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --loglevel=DEBUG +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=20 --loglevel=DEBUG diff --git a/run_fbopt_pacs.sh b/run_fbopt_pacs.sh index 1c950d1f3..6e4707337 100644 --- a/run_fbopt_pacs.sh +++ b/run_fbopt_pacs.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py # python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=2 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 -python main_out.py --te_d=sketch --tpath=examples/tasks/demo_task_path_list_small.py --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --loglevel=DEBUG +python main_out.py --te_d=sketch --tpath=examples/tasks/demo_task_path_list_small.py --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --loglevel=DEBUG From 17bc89e09adb2cac93dc0aff2760ecc1b9755bf1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 15:55:38 +0200 Subject: [PATCH 040/762] run schell --- run_fbopt_pacs.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/run_fbopt_pacs.sh b/run_fbopt_pacs.sh index 6e4707337..188d475fa 100644 --- a/run_fbopt_pacs.sh +++ b/run_fbopt_pacs.sh @@ -3,5 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -# python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=2 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 -python main_out.py --te_d=sketch --tpath=examples/tasks/demo_task_path_list_small.py --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --loglevel=DEBUG +python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 From 5a85025c870193183ab8238596ec52cf6dc5b84b Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 12 Sep 2023 16:20:04 +0200 Subject: [PATCH 041/762] eval loss with torch_no grad --- domainlab/algos/trainers/train_fbopt.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 03f0e669a..96126770e 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -2,6 +2,7 @@ feedback optimization """ import copy +import torch from domainlab.algos.trainers.a_trainer import AbstractTrainer from domainlab.algos.trainers.train_basic import TrainerBasic @@ -72,16 +73,17 @@ def eval_loss(self, dict4mu, dict_theta): epo_task_loss = 0 epo_p_loss = 0 # penalized loss # FIXME: will loader be corupted? if called at different places? if we do not make deep copy - for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): - tensor_x, vec_y, vec_d = \ - tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) - b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d).sum() - b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() - # sum will kill the dimension of the mini batch - b_p_loss = temp_model.cal_loss(tensor_x, vec_y, vec_d).sum() - epo_reg_loss += b_reg_loss - epo_task_loss += b_task_loss - epo_p_loss += b_p_loss + with torch.no_grad(): + for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): + tensor_x, vec_y, vec_d = \ + tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) + b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d).sum() + b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() + # sum will kill the dimension of the mini batch + b_p_loss = temp_model.cal_loss(tensor_x, vec_y, vec_d).sum() + epo_reg_loss += b_reg_loss + epo_task_loss += b_task_loss + epo_p_loss += b_p_loss return epo_p_loss def tr_epoch(self, epoch): From a716e71e68e713c1c778e98c1b4b6a1a70fc23ae Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 13 Sep 2023 12:15:27 +0200 Subject: [PATCH 042/762] detailed log --- domainlab/algos/trainers/fbopt.py | 17 ++++---- domainlab/algos/trainers/train_fbopt.py | 55 +++++++++++++++++++++---- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 501d0c025..02bcd5f8e 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -82,22 +82,19 @@ def search_theta(self, mmu_new): the execution will set the value for mu and theta as well """ - flag_success = False - self.ploss_old_theta_new_mu = self.trainer.eval_loss(mmu_new, self.dict_theta) - self.ploss_old_theta_old_mu = self.trainer.eval_loss(self.mmu, self.dict_theta) + self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta) + self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta) theta4mu_new = copy.deepcopy(self.dict_theta) for i in range(self.budget_theta_update_per_mu): - print(f"update theta at iteration {i} with mu={mmu_new}") + print(f"search theta at iteration {i} with mu={mmu_new}") theta4mu_new = self.trainer.opt_theta(mmu_new, theta4mu_new) - self.ploss_new_theta_new_mu = self.trainer.eval_loss(mmu_new, theta4mu_new) - self.ploss_new_theta_old_mu = self.trainer.eval_loss(self.mmu, theta4mu_new) + self.ploss_new_theta_new_mu = self.trainer.eval_p_loss(mmu_new, theta4mu_new) + self.ploss_new_theta_old_mu = self.trainer.eval_p_loss(self.mmu, theta4mu_new) if self.is_criteria_met(): self.mmu = mmu_new - flag_success = True - # FIXME: update theta only if current mu is good enough? self.dict_theta = theta4mu_new - return flag_success - return flag_success + return True + return False def inner_product(self, mmu, v_reg_loss): """ diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 96126770e..ff060d8c3 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -7,6 +7,7 @@ from domainlab.algos.trainers.a_trainer import AbstractTrainer from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.fbopt import HyperSchedulerFeedback +from domainlab.utils.logger import Logger class HyperSetter(): @@ -60,42 +61,80 @@ def opt_theta(self, dict4mu, dict_theta0): dict_par = dict(self.inner_trainer.model.named_parameters()) return dict_par - def eval_loss(self, dict4mu, dict_theta): + def eval_p_loss(self, dict4mu, dict_theta): """ - evaluate the penalty function value + evaluate the penalty function value on all available training data + # TODO: normalize loss via batchsize """ temp_model = copy.deepcopy(self.model) # mock the model hyper-parameter to be from dict4mu temp_model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) temp_model.set_params(dict_theta) + epo_p_loss = 0 # penalized loss + # FIXME: will loader be corupted? if called at different places? if we do not make deep copy + with torch.no_grad(): + for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): + tensor_x, vec_y, vec_d = \ + tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) + # sum will kill the dimension of the mini batch + b_p_loss = temp_model.cal_loss(tensor_x, vec_y, vec_d).sum() + epo_p_loss += b_p_loss + return epo_p_loss + + def eval_r_loss(self): + """ + evaluate the regularization loss and ERM loss with respect ot parameter dict_theta + ERM loss on all available training data + # TODO: normalize loss via batchsize + """ + # FIXME: move this to model instead of having it in trainer here + temp_model = copy.deepcopy(self.model) + # mock the model hyper-parameter to be from dict4mu epo_reg_loss = 0 - # FIXME: check if reg is decreasing epo_task_loss = 0 - epo_p_loss = 0 # penalized loss # FIXME: will loader be corupted? if called at different places? if we do not make deep copy - with torch.no_grad(): + with torch.no_grad(): for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d).sum() b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() # sum will kill the dimension of the mini batch - b_p_loss = temp_model.cal_loss(tensor_x, vec_y, vec_d).sum() epo_reg_loss += b_reg_loss epo_task_loss += b_task_loss - epo_p_loss += b_p_loss - return epo_p_loss + return epo_reg_loss, epo_task_loss def tr_epoch(self, epoch): + """ + the algorithm will try to search for the reg-descent operator, only when found, + the model will tunnel/jump/shoot into the found pivot parameter $\\theta^{(k+1)}$, + otherwise, + """ + # FIXME: check if reg is decreasing by logging + epo_reg_loss, epo_task_loss = self.eval_r_loss() + + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"at epoch {epoch}, epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + self.model.train() flag_success = self.hyper_scheduler.search_mu( dict(self.model.named_parameters()), iter_start=self.mu_iter_start) if flag_success: # only in success case, mu will be updated + logger.info("pivot parameter found, jumping/shooting there now!") + epo_reg_loss, epo_task_loss = self.eval_r_loss() + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info( + f"at epoch {epoch}, before shooting: epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") self.model.set_params(self.hyper_scheduler.dict_theta) + epo_reg_loss, epo_task_loss = self.eval_r_loss() + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info( + f"at epoch {epoch}, after shooting: epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") else: # if failed to find reg-pareto descent operator, continue training + logger.info("failed to find pivot, move forward \\bar{\\theta}, this will deteriorate reg loss!") theta = dict(self.model.named_parameters()) dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) self.model.set_params(dict_par) From ad0be7cef3193c4155954a3eb8f220d8eb14ce3f Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 13 Sep 2023 12:35:37 +0200 Subject: [PATCH 043/762] no drop for loader --- domainlab/algos/trainers/a_trainer.py | 2 ++ domainlab/algos/trainers/train_fbopt.py | 7 ++----- domainlab/tasks/a_task.py | 1 + domainlab/tasks/b_task.py | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index c83c54afe..ad6050d5e 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -36,6 +36,7 @@ def __init__(self, successor_node=None): self.aconf = None # self.loader_tr = None + self.loader_tr_no_drop = None self.loader_te = None self.num_batches = None self.flag_update_hyper_per_epoch = None @@ -67,6 +68,7 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True): self.aconf = aconf # self.loader_tr = task.loader_tr + self.loader_tr_no_drop = task._loader_tr_no_drop self.loader_te = task.loader_te if flag_accept: diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index ff060d8c3..c22a13a16 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -71,9 +71,8 @@ def eval_p_loss(self, dict4mu, dict_theta): temp_model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) temp_model.set_params(dict_theta) epo_p_loss = 0 # penalized loss - # FIXME: will loader be corupted? if called at different places? if we do not make deep copy with torch.no_grad(): - for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): + for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) # sum will kill the dimension of the mini batch @@ -87,14 +86,12 @@ def eval_r_loss(self): ERM loss on all available training data # TODO: normalize loss via batchsize """ - # FIXME: move this to model instead of having it in trainer here temp_model = copy.deepcopy(self.model) # mock the model hyper-parameter to be from dict4mu epo_reg_loss = 0 epo_task_loss = 0 - # FIXME: will loader be corupted? if called at different places? if we do not make deep copy with torch.no_grad(): - for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): + for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d).sum() diff --git a/domainlab/tasks/a_task.py b/domainlab/tasks/a_task.py index 583a2c28a..489345957 100644 --- a/domainlab/tasks/a_task.py +++ b/domainlab/tasks/a_task.py @@ -16,6 +16,7 @@ class NodeTaskDG(AbstractChainNodeHandler): def __init__(self, succ=None): super().__init__(succ) self._loader_tr = None + self._loader_tr_no_drop = None self._loader_te = None self._loader_val = None self._list_domains = None diff --git a/domainlab/tasks/b_task.py b/domainlab/tasks/b_task.py index 160f09ed7..ec0a92b6c 100644 --- a/domainlab/tasks/b_task.py +++ b/domainlab/tasks/b_task.py @@ -43,6 +43,7 @@ def init_business(self, args, node_algo_builder=None): self.dict_dset_val.update({na_domain: ddset_val}) ddset_mix = ConcatDataset(tuple(self.dict_dset_tr.values())) self._loader_tr = mk_loader(ddset_mix, args.bs) + self._loader_tr_no_drop = mk_loader(ddset_mix, args.bs, drop_last=False, shuffle=False) ddset_mix_val = ConcatDataset(tuple(self.dict_dset_val.values())) self._loader_val = mk_loader(ddset_mix_val, args.bs, From 9b921fd5a3559876e905856fa171419748b515b6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 13 Sep 2023 12:54:02 +0200 Subject: [PATCH 044/762] same loss function has big variation --- domainlab/algos/trainers/train_fbopt.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index c22a13a16..baa96385d 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -113,6 +113,13 @@ def tr_epoch(self, epoch): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"at epoch {epoch}, epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + epo_reg_loss, epo_task_loss = self.eval_r_loss() + + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"at epoch {epoch}, epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + + + self.model.train() flag_success = self.hyper_scheduler.search_mu( dict(self.model.named_parameters()), @@ -132,9 +139,18 @@ def tr_epoch(self, epoch): else: # if failed to find reg-pareto descent operator, continue training logger.info("failed to find pivot, move forward \\bar{\\theta}, this will deteriorate reg loss!") + epo_reg_loss, epo_task_loss = self.eval_r_loss() + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info( + f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") theta = dict(self.model.named_parameters()) dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) self.model.set_params(dict_par) + epo_reg_loss, epo_task_loss = self.eval_r_loss() + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info( + f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + flag_stop = self.observer.update(epoch) # FIXME: should count how many epochs were used self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return False # total number of epochs controled in args From a35c50d633c87e41ba1d36da0fbd264244ce5c8d Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 13 Sep 2023 14:25:38 +0200 Subject: [PATCH 045/762] print success rate --- domainlab/algos/trainers/fbopt.py | 10 ++++++++-- domainlab/algos/trainers/train_fbopt.py | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 02bcd5f8e..3581d4e2d 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -27,23 +27,29 @@ def __init__(self, trainer, **kwargs): self.dict_theta = None self.budget_mu_per_step = trainer.aconf.budget_mu_per_step self.budget_theta_update_per_mu = trainer.aconf.budget_theta_update_per_mu + self.count_found_operator = 0 + self.count_search_mu = 0 def search_mu(self, dict_theta, iter_start=0): """ start from parameter dict_theta, enlarge mmu to see if the criteria is met """ + self.count_search_mu += 1 self.dict_theta = dict_theta + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") mmu = None for miter in range(iter_start, self.budget_mu_per_step): mmu = self.dict_iter(miter) print(f"trying mu={mmu} at mu iteration {miter}") if self.search_theta(mmu): - print(f"!!!found reg-pareto operator with mu={mmu}") + self.count_found_operator += 1 + logger.info(f"!!!found reg-pareto operator with mu={mmu}") + logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") self.mmu = mmu return True - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.warn(f"!!!!!!failed to find mu within budget, mu={mmu}") + logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") return False def dict_iter(self, miter): diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index baa96385d..423df700d 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -87,6 +87,7 @@ def eval_r_loss(self): # TODO: normalize loss via batchsize """ temp_model = copy.deepcopy(self.model) + temp_model.eval() # mock the model hyper-parameter to be from dict4mu epo_reg_loss = 0 epo_task_loss = 0 From c91e919f534c8fd46b015f1616338e2548e97927 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 13 Sep 2023 14:29:39 +0200 Subject: [PATCH 046/762] reduce repetitive computation --- domainlab/algos/trainers/fbopt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 3581d4e2d..effadba6e 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -39,6 +39,8 @@ def search_mu(self, dict_theta, iter_start=0): self.dict_theta = dict_theta logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") mmu = None + # self.mmu is not updated until a reg-descent operator is found + self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta) for miter in range(iter_start, self.budget_mu_per_step): mmu = self.dict_iter(miter) print(f"trying mu={mmu} at mu iteration {miter}") @@ -89,7 +91,6 @@ def search_theta(self, mmu_new): the execution will set the value for mu and theta as well """ self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta) - self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta) theta4mu_new = copy.deepcopy(self.dict_theta) for i in range(self.budget_theta_update_per_mu): print(f"search theta at iteration {i} with mu={mmu_new}") From 8b9b6258f1bbc0e4dc0f0bf253c4f36dcaf766b6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 13 Sep 2023 14:40:58 +0200 Subject: [PATCH 047/762] . --- domainlab/models/a_model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index e8db936fa..558b68d69 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -16,6 +16,7 @@ def set_params(self, dict_params): set """ # FIXME: net1.load_state_dict(net2.state_dict()) contains more information than model.named_parameters() like optimizer status + # but I dont know another method to set neural network weights without using load_state_dict self.load_state_dict(dict_params, strict=False) def cal_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): From cfaeef62e88e80945d1201a251af39821c278ba1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 13 Sep 2023 14:43:58 +0200 Subject: [PATCH 048/762] . --- domainlab/models/a_model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index 558b68d69..151809d10 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -17,6 +17,7 @@ def set_params(self, dict_params): """ # FIXME: net1.load_state_dict(net2.state_dict()) contains more information than model.named_parameters() like optimizer status # but I dont know another method to set neural network weights without using load_state_dict + # FIXME: dict_params lack some keys compared to self.state_dict(), why? self.load_state_dict(dict_params, strict=False) def cal_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): From e76bb5a411633a1092dce1815b34594b518fd7ea Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 13 Sep 2023 14:46:31 +0200 Subject: [PATCH 049/762] demo file to debug why loss changes --- demo_draw_loss.py | 97 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 demo_draw_loss.py diff --git a/demo_draw_loss.py b/demo_draw_loss.py new file mode 100644 index 000000000..3c8b6f3df --- /dev/null +++ b/demo_draw_loss.py @@ -0,0 +1,97 @@ +""" +test if it is possible to have stable evaluation of a deepcopied model's loss +i.e. +1. if we evaluate it twice, will it get the same loss? +2. +""" +import torch +import torch.nn.functional as F +import torchvision +import torchvision.transforms as transforms +from torch import nn +import torch.optim as optim +import copy + +class Net(nn.Module): + def __init__(self): + super().__init__() + self.conv1 = nn.Conv2d(3, 6, 5) + self.pool = nn.MaxPool2d(2, 2) + self.conv2 = nn.Conv2d(6, 16, 5) + self.fc1 = nn.Linear(16 * 5 * 5, 120) + self.fc2 = nn.Linear(120, 84) + self.fc3 = nn.Linear(84, 10) + + def forward(self, x): + x = self.pool(F.relu(self.conv1(x))) + x = self.pool(F.relu(self.conv2(x))) + x = torch.flatten(x, 1) # flatten all dimensions except batch + x = F.relu(self.fc1(x)) + x = F.relu(self.fc2(x)) + x = self.fc3(x) + return x + + +net = Net() +criterion = nn.CrossEntropyLoss() +optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9) + + +transform = transforms.Compose( + [transforms.ToTensor(), + transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))]) + +batch_size = 4 + +trainset = torchvision.datasets.CIFAR10(root='./data', train=True, + download=True, transform=transform) +trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size, + shuffle=True, num_workers=2) + +testset = torchvision.datasets.CIFAR10(root='./data', train=False, + download=True, transform=transform) +testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size, + shuffle=False, num_workers=2) + +classes = ('plane', 'car', 'bird', 'cat', + 'deer', 'dog', 'frog', 'horse', 'ship', 'truck') + + + +def train_model(net): + running_loss = 0 + for i, data in enumerate(trainloader, 0): + # get the inputs; data is a list of [inputs, labels] + inputs, labels = data + # zero the parameter gradients + optimizer.zero_grad() + # forward + backward + optimize + outputs = net(inputs) + loss = criterion(outputs, labels) + loss.backward() + optimizer.step() + # print statistics + running_loss += loss.item() + print(f'train loss={running_loss}') + return running_loss + + +def eval_model(net): + net = copy.deepcopy(net) + running_loss = 0 + net.eval() + for i, data in enumerate(trainloader, 0): + # get the inputs; data is a list of [inputs, labels] + inputs, labels = data + # zero the parameter gradients + # forward + backward + optimize + outputs = net(inputs) + loss = criterion(outputs, labels) + # print statistics + running_loss += loss.item() + print(f'eval loss={running_loss}') + return running_loss + +eval_model(net) +train_model(net) +eval_model(net) From daac36d097d7e980e5fafb88d44c1dc8467378fd Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 09:58:36 +0200 Subject: [PATCH 050/762] code refinement, mu iteration start at 1 --- domainlab/algos/trainers/fbopt.py | 24 +++++++++---------- domainlab/algos/trainers/train_fbopt.py | 32 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index effadba6e..f3afb629e 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -23,6 +23,7 @@ def __init__(self, trainer, **kwargs): self.ploss_new_theta_new_mu = None self.delta_mu = trainer.aconf.delta_mu self.init_mu = trainer.aconf.init_mu4beta + # for exponential increase of mu, mu can not be starting from zero self.beta_mu = trainer.aconf.beta_mu self.dict_theta = None self.budget_mu_per_step = trainer.aconf.budget_mu_per_step @@ -30,33 +31,34 @@ def __init__(self, trainer, **kwargs): self.count_found_operator = 0 self.count_search_mu = 0 - def search_mu(self, dict_theta, iter_start=0): + def search_mu(self, dict_theta, iter_start): """ - start from parameter dict_theta, - enlarge mmu to see if the criteria is met + start from parameter dictionary dict_theta: {"layer":tensor}, + enlarge mu w.r.t. its current value + to see if the criteria is met """ self.count_search_mu += 1 - self.dict_theta = dict_theta + self.dict_theta = copy.deepcopy(dict_theta) + # I am not sure if necessary here to deepcopy, but safer logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") mmu = None # self.mmu is not updated until a reg-descent operator is found self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta) for miter in range(iter_start, self.budget_mu_per_step): - mmu = self.dict_iter(miter) - print(f"trying mu={mmu} at mu iteration {miter}") + mmu = self.dict_mu_iter(miter) + print(f"trying mu={mmu} at mu iteration {miter} of {self.budget_mu_per_step}") if self.search_theta(mmu): self.count_found_operator += 1 logger.info(f"!!!found reg-pareto operator with mu={mmu}") logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") - self.mmu = mmu return True logger.warn(f"!!!!!!failed to find mu within budget, mu={mmu}") logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") return False - def dict_iter(self, miter): + def dict_mu_iter(self, miter): """ - update a dictionary according to iteration + update the dictionary of mu w.r.t. its current value, and its iteration, and its iteration """ if miter == 0: return self.mmu @@ -118,7 +120,3 @@ def is_criteria_met(self): flag_improve = self.ploss_new_theta_new_mu < self.ploss_old_theta_new_mu flag_deteriorate = self.ploss_new_theta_old_mu > self.ploss_old_theta_old_mu return flag_improve & flag_deteriorate - - def __call__(self, epoch): - """ - """ diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 423df700d..d4ea27af6 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -56,6 +56,7 @@ def opt_theta(self, dict4mu, dict_theta0): # mock the model hyper-parameter to be from dict4mu self.inner_trainer.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) # hide implementation details of inner_trainer + self.inner_trainer.model.train() for _, (tensor_x, vec_y, vec_d, *others) in enumerate(self.inner_trainer.loader_tr): self.inner_trainer.train_batch(tensor_x, vec_y, vec_d, others) # update inner_net dict_par = dict(self.inner_trainer.model.named_parameters()) @@ -108,50 +109,59 @@ def tr_epoch(self, epoch): the model will tunnel/jump/shoot into the found pivot parameter $\\theta^{(k+1)}$, otherwise, """ - # FIXME: check if reg is decreasing by logging + # FIXME: check if reg is decreasing by logging and plot epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"at epoch {epoch}, epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + # double check if loss evaluation is the same when executed two times epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"at epoch {epoch}, epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + # self.model.train() # FIXME: i guess no need to put into train mode? - - self.model.train() flag_success = self.hyper_scheduler.search_mu( dict(self.model.named_parameters()), - iter_start=self.mu_iter_start) + iter_start=1) # FIXME: iter_start=0 or 1? + if flag_success: # only in success case, mu will be updated logger.info("pivot parameter found, jumping/shooting there now!") epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info( - f"at epoch {epoch}, before shooting: epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + f"at epoch {epoch}, before shooting: epo_reg_loss={epo_reg_loss}, \ + epo_task_loss={epo_task_loss}") + self.model.set_params(self.hyper_scheduler.dict_theta) + epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info( - f"at epoch {epoch}, after shooting: epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + f"at epoch {epoch}, after shooting: epo_reg_loss={epo_reg_loss}, \ + epo_task_loss={epo_task_loss}") else: # if failed to find reg-pareto descent operator, continue training - logger.info("failed to find pivot, move forward \\bar{\\theta}, this will deteriorate reg loss!") + logger.info("failed to find pivot, move forward \\bar{\\theta}, \ + this will deteriorate reg loss!") epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info( - f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") + f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ + epo_task_loss={epo_task_loss}") + theta = dict(self.model.named_parameters()) dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) self.model.set_params(dict_par) + epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info( - f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") - - flag_stop = self.observer.update(epoch) # FIXME: should count how many epochs were used + f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ + epo_task_loss={epo_task_loss}") + self.observer.update(epoch) self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return False # total number of epochs controled in args From c03e639edaf22dd275da5603941192b92b75cb2f Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 10:14:47 +0200 Subject: [PATCH 051/762] correct reg loss --- domainlab/algos/trainers/train_fbopt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index d4ea27af6..8bd2c987b 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -96,7 +96,9 @@ def eval_r_loss(self): for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) - b_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d).sum() + tuple_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d) + b_reg_loss = tuple_reg_loss[0][0] # FIXME: this only works when scalar multiplier + b_reg_loss = b_reg_loss.sum().item() b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() # sum will kill the dimension of the mini batch epo_reg_loss += b_reg_loss From 0dcb3ccb5b884fbb8d61a41624202863c1d5ff60 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 11:53:41 +0200 Subject: [PATCH 052/762] fixed randomness --- run_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index ebbe0dd19..f48c9f368 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=20 --loglevel=DEBUG +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --loglevel=DEBUG From 3a1a40328bdab4ee6c7abe20b5fb0c8f91eacbbe Mon Sep 17 00:00:00 2001 From: lisab00 Date: Thu, 14 Sep 2023 13:50:10 +0200 Subject: [PATCH 053/762] add yaml for fbopt --- examples/benchmark/test_benchmark_fbopt.yaml | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 examples/benchmark/test_benchmark_fbopt.yaml diff --git a/examples/benchmark/test_benchmark_fbopt.yaml b/examples/benchmark/test_benchmark_fbopt.yaml new file mode 100644 index 000000000..2c9254049 --- /dev/null +++ b/examples/benchmark/test_benchmark_fbopt.yaml @@ -0,0 +1,67 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt + +num_param_samples: 8 +sampling_seed: 0 +startseed: 0 +endseed: 2 + +test_domains: + - 3 + - 0 + + +domainlab_args: + task: mnistcolor10 + tr_d: [1, 2] + dmem: False + lr: 0.001 + epos: 50 + es: 5 + bs: 64 + nname: conv_bn_pool_2 + san_check: True + + +# Test fbopt with different hyperparameter configurations + +Test1: + aname: dann + trainer: fbopt + + hyperparameters: + init_mu4beta: + min: 0.0001 + max: 0.01 + num: 2 + step: 0.0001 + distribution: uniform + + beta_mu: + min: 1 + max: 2 + num: 3 + step: 0.1 + distribution: uniform + + delta_mu: + min: 0.001 + max: 0.1 + num: 5 + step: 0.001 + distribution: loguniform + + budget_mu_per_step: + min: 4 + max: 10 + num: 7 + step: 1 + distribution: uniform + + budget_theta_update_per_mu: + min: 4 + max: 10 + num: 7 + step: 1 + distribution: uniform From e87df4f6d3e2149e6d33e3c2d438975c5da404db Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 14:29:17 +0200 Subject: [PATCH 054/762] fix mu iteration --- domainlab/algos/trainers/fbopt.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index f3afb629e..603b926e4 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -25,6 +25,7 @@ def __init__(self, trainer, **kwargs): self.init_mu = trainer.aconf.init_mu4beta # for exponential increase of mu, mu can not be starting from zero self.beta_mu = trainer.aconf.beta_mu + self.dict_bar_theta = None self.dict_theta = None self.budget_mu_per_step = trainer.aconf.budget_mu_per_step self.budget_theta_update_per_mu = trainer.aconf.budget_theta_update_per_mu @@ -65,13 +66,25 @@ def dict_mu_iter(self, miter): if self.delta_mu is not None: mmu = self.dict_addition(self.mmu, miter * self.delta_mu) elif self.beta_mu is not None: + if self.dict_is_zero(self.mmu): + base = self.dict_addition(self.mmu, self.init_mu) + else: + base = self.mmu multiplier = np.power(self.beta_mu, miter) - base = self.dict_addition(self.mmu, self.init_mu) mmu = self.dict_multiply(base, multiplier) else: raise RuntimeError("delta_mu and beta_mu can not be simultaneously None!") return mmu + def dict_is_zero(self, dict_mu): + """ + check if hyper-parameter start from zero + """ + for key in dict_mu.keys(): + if dict_mu[key] == 0.0: + return True + + def dict_multiply(self, dict_base, multiplier): """ multiply a float to each element of a dictionary From a428d79a0c9d8d4e450a608b815000f1064a6ed3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 14:51:08 +0200 Subject: [PATCH 055/762] big mu seems to lead to finding of reg-descent operator --- run_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index f48c9f368..6ea5b174c 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --loglevel=DEBUG +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=30 From b59629af4b06030572718d248b99464b74104075 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 15:16:52 +0200 Subject: [PATCH 056/762] . --- domainlab/algos/trainers/fbopt.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 603b926e4..afdbd4422 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -27,6 +27,7 @@ def __init__(self, trainer, **kwargs): self.beta_mu = trainer.aconf.beta_mu self.dict_bar_theta = None self.dict_theta = None + self.dict_theta_ref = None self.budget_mu_per_step = trainer.aconf.budget_mu_per_step self.budget_theta_update_per_mu = trainer.aconf.budget_theta_update_per_mu self.count_found_operator = 0 @@ -83,6 +84,7 @@ def dict_is_zero(self, dict_mu): for key in dict_mu.keys(): if dict_mu[key] == 0.0: return True + return False def dict_multiply(self, dict_base, multiplier): From e742e32669649cd69e1052748220967be98a68ed Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 15:29:03 +0200 Subject: [PATCH 057/762] reorganize code --- domainlab/algos/trainers/fbopt.py | 72 ++++++++++++++----------------- domainlab/models/a_model.py | 4 +- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index afdbd4422..51a04271b 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -25,8 +25,10 @@ def __init__(self, trainer, **kwargs): self.init_mu = trainer.aconf.init_mu4beta # for exponential increase of mu, mu can not be starting from zero self.beta_mu = trainer.aconf.beta_mu - self.dict_bar_theta = None + self.dict_theta_bar = None self.dict_theta = None + # theta_ref should be equal to either theta or theta bar as reference + # since theta_ref will be used to judge if criteria is met self.dict_theta_ref = None self.budget_mu_per_step = trainer.aconf.budget_mu_per_step self.budget_theta_update_per_mu = trainer.aconf.budget_theta_update_per_mu @@ -41,11 +43,12 @@ def search_mu(self, dict_theta, iter_start): """ self.count_search_mu += 1 self.dict_theta = copy.deepcopy(dict_theta) + self.dict_theta_ref = self.dict_theta # I am not sure if necessary here to deepcopy, but safer logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") mmu = None # self.mmu is not updated until a reg-descent operator is found - self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta) + self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta_ref) for miter in range(iter_start, self.budget_mu_per_step): mmu = self.dict_mu_iter(miter) print(f"trying mu={mmu} at mu iteration {miter} of {self.budget_mu_per_step}") @@ -58,6 +61,34 @@ def search_mu(self, dict_theta, iter_start): logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") return False + def search_theta(self, mmu_new): + """ + conditioned on fixed $$\\mu$$, the operator should search theta based on + the current value of $theta$ + + the execution will set the value for mu and theta as well + """ + self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta_ref) + theta4mu_new = copy.deepcopy(self.dict_theta) + for i in range(self.budget_theta_update_per_mu): + print(f"search theta at iteration {i} with mu={mmu_new}") + theta4mu_new = self.trainer.opt_theta(mmu_new, theta4mu_new) + self.ploss_new_theta_new_mu = self.trainer.eval_p_loss(mmu_new, theta4mu_new) + self.ploss_new_theta_old_mu = self.trainer.eval_p_loss(self.mmu, theta4mu_new) + if self.is_criteria_met(): + self.mmu = mmu_new + self.dict_theta = theta4mu_new + return True + return False + + def is_criteria_met(self): + """ + if the reg-descent criteria is met + """ + flag_improve = self.ploss_new_theta_new_mu < self.ploss_old_theta_new_mu + flag_deteriorate = self.ploss_new_theta_old_mu > self.ploss_old_theta_old_mu + return flag_improve & flag_deteriorate + def dict_mu_iter(self, miter): """ update the dictionary of mu w.r.t. its current value, and its iteration, and its iteration @@ -86,7 +117,6 @@ def dict_is_zero(self, dict_mu): return True return False - def dict_multiply(self, dict_base, multiplier): """ multiply a float to each element of a dictionary @@ -99,39 +129,3 @@ def dict_addition(self, dict_base, delta): increase the value of a dictionary by delta """ return {key: val + delta for key, val in dict_base.items()} - - def search_theta(self, mmu_new): - """ - conditioned on fixed $$\\mu$$, the operator should search theta based on - the current value of $theta$ - - the execution will set the value for mu and theta as well - """ - self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta) - theta4mu_new = copy.deepcopy(self.dict_theta) - for i in range(self.budget_theta_update_per_mu): - print(f"search theta at iteration {i} with mu={mmu_new}") - theta4mu_new = self.trainer.opt_theta(mmu_new, theta4mu_new) - self.ploss_new_theta_new_mu = self.trainer.eval_p_loss(mmu_new, theta4mu_new) - self.ploss_new_theta_old_mu = self.trainer.eval_p_loss(self.mmu, theta4mu_new) - if self.is_criteria_met(): - self.mmu = mmu_new - self.dict_theta = theta4mu_new - return True - return False - - def inner_product(self, mmu, v_reg_loss): - """ - - the first dimension of the tensor v_reg_loss is mini-batch - the second dimension is the number of regularizers - - the vector mmu has dimension the number of regularizers - """ - return mmu * v_reg_loss # - - def is_criteria_met(self): - """ - if the reg-descent criteria is met - """ - flag_improve = self.ploss_new_theta_new_mu < self.ploss_old_theta_new_mu - flag_deteriorate = self.ploss_new_theta_old_mu > self.ploss_old_theta_old_mu - return flag_improve & flag_deteriorate diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index c1a52d4d3..ccd4e6556 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -28,10 +28,12 @@ def cal_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): loss_reg = self.inner_product(list_loss, list_multiplier) return self.cal_task_loss(tensor_x, tensor_y) + loss_reg - def inner_product(self, list_loss_scalar, list_multiplier): """ compute inner product between list of scalar loss and multiplier + - the first dimension of the tensor v_reg_loss is mini-batch + the second dimension is the number of regularizers + - the vector mmu has dimension the number of regularizers """ list_tuple = zip(list_loss_scalar, list_multiplier) rst = [mtuple[0]*mtuple[1] for mtuple in list_tuple] From 2a0c8fb55ec9a71d0a6511c3549a9a507201a162 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 15:36:53 +0200 Subject: [PATCH 058/762] separate theta and theta bar --- domainlab/algos/trainers/fbopt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 51a04271b..cdcc689f6 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -26,7 +26,7 @@ def __init__(self, trainer, **kwargs): # for exponential increase of mu, mu can not be starting from zero self.beta_mu = trainer.aconf.beta_mu self.dict_theta_bar = None - self.dict_theta = None + self.dict_theta = copy.deepcopy(self.trainer.model.named_parameters()) # theta_ref should be equal to either theta or theta bar as reference # since theta_ref will be used to judge if criteria is met self.dict_theta_ref = None @@ -42,8 +42,11 @@ def search_mu(self, dict_theta, iter_start): to see if the criteria is met """ self.count_search_mu += 1 - self.dict_theta = copy.deepcopy(dict_theta) - self.dict_theta_ref = self.dict_theta + self.dict_theta_bar = copy.deepcopy(dict_theta) + self.dict_theta_ref = self.dict_theta_bar + # theta_ref should be equal to either theta or theta bar as reference + # since theta_ref will be used to judge if criteria is met + # I am not sure if necessary here to deepcopy, but safer logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") mmu = None From b0c7e8ae8bb5a0fb3fc0f4c69ac3524c4d76319c Mon Sep 17 00:00:00 2001 From: lisab00 Date: Thu, 14 Sep 2023 15:55:44 +0200 Subject: [PATCH 059/762] increase beta_mu --- examples/benchmark/test_benchmark_fbopt.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/test_benchmark_fbopt.yaml b/examples/benchmark/test_benchmark_fbopt.yaml index 2c9254049..05948b3c7 100644 --- a/examples/benchmark/test_benchmark_fbopt.yaml +++ b/examples/benchmark/test_benchmark_fbopt.yaml @@ -39,9 +39,9 @@ Test1: distribution: uniform beta_mu: - min: 1 + min: 1.2 max: 2 - num: 3 + num: 4 step: 0.1 distribution: uniform From e95e9f0eb9da78bc7eaca5355c733da5814d9b3d Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 15:58:47 +0200 Subject: [PATCH 060/762] works --- domainlab/algos/trainers/fbopt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index cdcc689f6..924754348 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -26,7 +26,7 @@ def __init__(self, trainer, **kwargs): # for exponential increase of mu, mu can not be starting from zero self.beta_mu = trainer.aconf.beta_mu self.dict_theta_bar = None - self.dict_theta = copy.deepcopy(self.trainer.model.named_parameters()) + self.dict_theta = copy.deepcopy(dict(self.trainer.model.named_parameters())) # theta_ref should be equal to either theta or theta bar as reference # since theta_ref will be used to judge if criteria is met self.dict_theta_ref = None @@ -43,7 +43,7 @@ def search_mu(self, dict_theta, iter_start): """ self.count_search_mu += 1 self.dict_theta_bar = copy.deepcopy(dict_theta) - self.dict_theta_ref = self.dict_theta_bar + self.dict_theta_ref = copy.deepcopy(self.dict_theta) # theta_ref should be equal to either theta or theta bar as reference # since theta_ref will be used to judge if criteria is met @@ -72,7 +72,7 @@ def search_theta(self, mmu_new): the execution will set the value for mu and theta as well """ self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta_ref) - theta4mu_new = copy.deepcopy(self.dict_theta) + theta4mu_new = copy.deepcopy(self.dict_theta_bar) for i in range(self.budget_theta_update_per_mu): print(f"search theta at iteration {i} with mu={mmu_new}") theta4mu_new = self.trainer.opt_theta(mmu_new, theta4mu_new) @@ -80,6 +80,7 @@ def search_theta(self, mmu_new): self.ploss_new_theta_old_mu = self.trainer.eval_p_loss(self.mmu, theta4mu_new) if self.is_criteria_met(): self.mmu = mmu_new + # theta_bar is set at search_mu, no need to update self.dict_theta = theta4mu_new return True return False @@ -92,6 +93,8 @@ def is_criteria_met(self): flag_deteriorate = self.ploss_new_theta_old_mu > self.ploss_old_theta_old_mu return flag_improve & flag_deteriorate + # below are just auxilliary code + def dict_mu_iter(self, miter): """ update the dictionary of mu w.r.t. its current value, and its iteration, and its iteration From 4538fff22801f293f66f1d1d9f023ed892627909 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 16:27:06 +0200 Subject: [PATCH 061/762] free descent operator --- domainlab/algos/trainers/fbopt.py | 15 +++++++++++++++ domainlab/algos/trainers/train_fbopt.py | 8 +++++--- run_fbopt.sh | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 51a04271b..9b9940e54 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -89,6 +89,21 @@ def is_criteria_met(self): flag_deteriorate = self.ploss_new_theta_old_mu > self.ploss_old_theta_old_mu return flag_improve & flag_deteriorate + def observe_state(self, mmu_new, theta4mu_new): + """ + FIXME: the function maybe not be needed anymore + depreatecated: + it can happen, the GD operator on the penalized function reduces both R and L + in this case, we get a descent operator for free. + + the state variable for high level control is the loss, we query them here + we only update the controller theta, the neural network theta is done by the trainer + """ + self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta_ref) + self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta_ref) + self.ploss_new_theta_new_mu = self.trainer.eval_p_loss(mmu_new, theta4mu_new) + self.ploss_new_theta_old_mu = self.trainer.eval_p_loss(self.mmu, theta4mu_new) + def dict_mu_iter(self, miter): """ update the dictionary of mu w.r.t. its current value, and its iteration, and its iteration diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 8bd2c987b..d50a8e639 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -149,11 +149,11 @@ def tr_epoch(self, epoch): # if failed to find reg-pareto descent operator, continue training logger.info("failed to find pivot, move forward \\bar{\\theta}, \ this will deteriorate reg loss!") - epo_reg_loss, epo_task_loss = self.eval_r_loss() + epo_reg_loss_before, epo_task_loss_before = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info( - f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ - epo_task_loss={epo_task_loss}") + f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss_before}, \ + epo_task_loss={epo_task_loss_before}") theta = dict(self.model.named_parameters()) dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) @@ -164,6 +164,8 @@ def tr_epoch(self, epoch): logger.info( f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") + if epo_reg_loss < epo_reg_loss_before: + logger.info("!!!!found free descent operator") self.observer.update(epoch) self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return False # total number of epochs controled in args diff --git a/run_fbopt.sh b/run_fbopt.sh index 6ea5b174c..060326bf0 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=30 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 From e66faa808132e20dbddb0a8b8a4db98387a3a220 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Sep 2023 16:28:06 +0200 Subject: [PATCH 062/762] . --- domainlab/algos/trainers/fbopt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 9b9940e54..1ef1f4f1f 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -54,10 +54,10 @@ def search_mu(self, dict_theta, iter_start): print(f"trying mu={mmu} at mu iteration {miter} of {self.budget_mu_per_step}") if self.search_theta(mmu): self.count_found_operator += 1 - logger.info(f"!!!found reg-pareto operator with mu={mmu}") + logger.info(f"!!!!!!!!!!!!!found reg-pareto operator with mu={mmu}") logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") return True - logger.warn(f"!!!!!!failed to find mu within budget, mu={mmu}") + logger.warn(f"!failed to find mu within budget, mu={mmu}") logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") return False From 71698f40bb41314dc671861cd8d1d1ff189d4c07 Mon Sep 17 00:00:00 2001 From: lisab00 Date: Fri, 15 Sep 2023 13:39:41 +0200 Subject: [PATCH 063/762] add datatype --- examples/benchmark/test_benchmark_fbopt.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/test_benchmark_fbopt.yaml b/examples/benchmark/test_benchmark_fbopt.yaml index 05948b3c7..028075e35 100644 --- a/examples/benchmark/test_benchmark_fbopt.yaml +++ b/examples/benchmark/test_benchmark_fbopt.yaml @@ -17,7 +17,7 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 50 + epos: 3 es: 5 bs: 64 nname: conv_bn_pool_2 @@ -26,7 +26,7 @@ domainlab_args: # Test fbopt with different hyperparameter configurations -Test1: +TestFbopt: aname: dann trainer: fbopt @@ -55,13 +55,15 @@ Test1: budget_mu_per_step: min: 4 max: 10 - num: 7 + num: 2 step: 1 + datatype: int distribution: uniform budget_theta_update_per_mu: min: 4 max: 10 - num: 7 + num: 2 step: 1 + datatype: int distribution: uniform From 9f5aa78ec5e88b8eb31625d9df432ada77b5626a Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Sep 2023 11:47:34 +0200 Subject: [PATCH 064/762] merge --- domainlab/algos/trainers/args_fbopt.py | 2 ++ domainlab/algos/trainers/fbopt.py | 16 +++++++++++++++- domainlab/algos/trainers/train_fbopt.py | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index fa731032b..b02933701 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -17,4 +17,6 @@ def add_args2parser_fbopt(parser): help='number of mu iterations to try') parser.add_argument('--budget_theta_update_per_mu', type=int, default=5, help='number of theta update for each fixed mu') + parser.add_argument('--anchor_bar', action='store_true', default=False, + help='use theta bar as anchor point') return parser diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 2bc042b0d..db2baebd7 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -35,6 +35,16 @@ def __init__(self, trainer, **kwargs): self.count_found_operator = 0 self.count_search_mu = 0 + def set_theta_ref(self): + """ + # theta_ref should be equal to either theta or theta bar as reference + # since theta_ref will be used to judge if criteria is met + """ + if self.trainer.aconf.anchor_bar: + self.dict_theta_ref = copy.deepcopy(self.dict_theta_bar) + else: + self.dict_theta_ref = copy.deepcopy(self.dict_theta) + def search_mu(self, dict_theta, iter_start): """ start from parameter dictionary dict_theta: {"layer":tensor}, @@ -42,8 +52,10 @@ def search_mu(self, dict_theta, iter_start): to see if the criteria is met """ self.count_search_mu += 1 + # FIXME: theta_bar always be overwriten by theta, to keep both at the same shoulder index + # Search always start from the model parameter self.dict_theta_bar = copy.deepcopy(dict_theta) - self.dict_theta_ref = copy.deepcopy(self.dict_theta) + self.set_theta_ref() # theta_ref should be equal to either theta or theta bar as reference # since theta_ref will be used to judge if criteria is met @@ -72,6 +84,8 @@ def search_theta(self, mmu_new): the execution will set the value for mu and theta as well """ self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta_ref) + # FIXME: where the search should start? theta_bar is the gradient descent result of old mu, + # it makes sense to start the search there? theta4mu_new = copy.deepcopy(self.dict_theta_bar) for i in range(self.budget_theta_update_per_mu): print(f"search theta at iteration {i} with mu={mmu_new}") diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index d50a8e639..1994c61f5 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -146,7 +146,8 @@ def tr_epoch(self, epoch): f"at epoch {epoch}, after shooting: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") else: - # if failed to find reg-pareto descent operator, continue training + # if failed to find reg-pareto descent operator, continue training without + # mu being updated logger.info("failed to find pivot, move forward \\bar{\\theta}, \ this will deteriorate reg loss!") epo_reg_loss_before, epo_task_loss_before = self.eval_r_loss() @@ -165,6 +166,7 @@ def tr_epoch(self, epoch): f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") if epo_reg_loss < epo_reg_loss_before: + # FIXME: update reference parameter in mu controller logger.info("!!!!found free descent operator") self.observer.update(epoch) self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) From 1b4ead5bfb598273f98b74e4c460ef034379d175 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Sep 2023 13:30:25 +0200 Subject: [PATCH 065/762] . --- run_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index 060326bf0..429848ca4 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --anchor_bar From b4c32354c81d78ec3af30e6340e6a4feef7e1357 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Sep 2023 14:28:02 +0200 Subject: [PATCH 066/762] . --- domainlab/algos/trainers/args_fbopt.py | 2 ++ domainlab/algos/trainers/fbopt.py | 6 ++++++ domainlab/algos/trainers/train_fbopt.py | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index b02933701..83f1ec193 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -19,4 +19,6 @@ def add_args2parser_fbopt(parser): help='number of theta update for each fixed mu') parser.add_argument('--anchor_bar', action='store_true', default=False, help='use theta bar as anchor point') + parser.add_argument('--myoptic_pareto', action='store_true', default=False, + help='update theta^{k} upon pareto descent') return parser diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index db2baebd7..221926f11 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -35,6 +35,12 @@ def __init__(self, trainer, **kwargs): self.count_found_operator = 0 self.count_search_mu = 0 + def update_anchor(self, dict_par): + """ + update the last ensured value of theta^{(k)} + """ + self.dict_theta = copy.deepcopy(dict_par) + def set_theta_ref(self): """ # theta_ref should be equal to either theta or theta bar as reference diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 1994c61f5..861e1defc 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -138,6 +138,7 @@ def tr_epoch(self, epoch): f"at epoch {epoch}, before shooting: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") + # shoot/tunnel to new found parameter configuration self.model.set_params(self.hyper_scheduler.dict_theta) epo_reg_loss, epo_task_loss = self.eval_r_loss() @@ -158,6 +159,7 @@ def tr_epoch(self, epoch): theta = dict(self.model.named_parameters()) dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) + # move according to gradient to update theta_bar self.model.set_params(dict_par) epo_reg_loss, epo_task_loss = self.eval_r_loss() @@ -166,8 +168,9 @@ def tr_epoch(self, epoch): f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") if epo_reg_loss < epo_reg_loss_before: - # FIXME: update reference parameter in mu controller logger.info("!!!!found free descent operator") + if self.aconf.myoptic_pareto: + self.hyper_scheduler.update_anchor(dict_par) self.observer.update(epoch) self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return False # total number of epochs controled in args From 420d94ae12d46c940ddda9652f1f778fa57a885a Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Sep 2023 15:46:33 +0200 Subject: [PATCH 067/762] . --- domainlab/algos/trainers/train_fbopt.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 861e1defc..076da9d9c 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -7,6 +7,7 @@ from domainlab.algos.trainers.a_trainer import AbstractTrainer from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.fbopt import HyperSchedulerFeedback +from domainlab.algos.msels.c_msel_bang import MSelBang from domainlab.utils.logger import Logger @@ -38,6 +39,7 @@ def before_tr(self): """ before training begins, construct helper objects """ + self.observer.msel = MSelBang(max_es=None) self.set_scheduler(scheduler=HyperSchedulerFeedback) self.model.evaluate(self.loader_te, self.device) self.inner_trainer = TrainerBasic() # look ahead From e6701be00ba5f2cff33f37ae862064168b61d834 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Sep 2023 15:46:39 +0200 Subject: [PATCH 068/762] . --- run_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index 429848ca4..1e4533573 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --anchor_bar +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto From 596fae555ff16e8f59cdd0be696d3294772d446d Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Sep 2023 15:48:02 +0200 Subject: [PATCH 069/762] . --- domainlab/algos/msels/c_msel_bang.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 domainlab/algos/msels/c_msel_bang.py diff --git a/domainlab/algos/msels/c_msel_bang.py b/domainlab/algos/msels/c_msel_bang.py new file mode 100644 index 000000000..ec422befa --- /dev/null +++ b/domainlab/algos/msels/c_msel_bang.py @@ -0,0 +1,20 @@ +""" +Model Selection should be decoupled from +""" +from domainlab.algos.msels.a_model_sel import AMSel + + +class MSelBang(AMSel): + """ + 1. Model selection using validation performance + 2. Visitor pattern to trainer + """ + def __init__(self, max_es): + self.best_val_acc = 0.0 + + def update(self): + """ + if the best model should be updated + """ + flag = True + return flag From d6ad31b389db285ca647bd3c2c80b4ace37e4b38 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Sep 2023 16:12:29 +0200 Subject: [PATCH 070/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 84 +++++++++++++++++++++ domainlab/algos/trainers/train_fbopt.py | 4 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 domainlab/algos/trainers/fbopt_alternate.py diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py new file mode 100644 index 000000000..c2eb90861 --- /dev/null +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -0,0 +1,84 @@ +""" +update hyper-parameters during training +""" +import copy +import numpy as np +from domainlab.utils.logger import Logger + + +class HyperSchedulerFeedbackAlternave(): + """ + design $\\mu$$ sequence based on state of penalized loss + """ + def __init__(self, trainer, **kwargs): + """ + kwargs is a dictionary with key the hyper-parameter name and its value + """ + self.trainer = trainer + self.mmu = kwargs + self.mmu = {key: 1.0 for key, val in self.mmu.items()} + self.ploss_old_theta_old_mu = None + self.ploss_old_theta_new_mu = None + self.ploss_new_theta_old_mu = None + self.ploss_new_theta_new_mu = None + self.delta_mu = trainer.aconf.delta_mu + self.init_mu = trainer.aconf.init_mu4beta + # for exponential increase of mu, mu can not be starting from zero + self.beta_mu = trainer.aconf.beta_mu + self.dict_theta_bar = None + self.dict_theta = copy.deepcopy(dict(self.trainer.model.named_parameters())) + # theta_ref should be equal to either theta or theta bar as reference + # since theta_ref will be used to judge if criteria is met + self.dict_theta_ref = None + self.budget_mu_per_step = trainer.aconf.budget_mu_per_step + self.budget_theta_update_per_mu = trainer.aconf.budget_theta_update_per_mu + self.count_found_operator = 0 + self.count_search_mu = 0 + ######################################## + self.rate_exp_shoulder = 0.0001 + self.epsilon_r = 20 + + def update_anchor(self, dict_par): + """ + update the last ensured value of theta^{(k)} + """ + self.dict_theta = copy.deepcopy(dict_par) + + def set_theta_ref(self): + """ + # theta_ref should be equal to either theta or theta bar as reference + # since theta_ref will be used to judge if criteria is met + """ + if self.trainer.aconf.anchor_bar: + self.dict_theta_ref = copy.deepcopy(self.dict_theta_bar) + else: + self.dict_theta_ref = copy.deepcopy(self.dict_theta) + + def search_mu(self, dict_theta=None, iter_start=None): + """ + start from parameter dictionary dict_theta: {"layer":tensor}, + enlarge mu w.r.t. its current value + to see if the criteria is met + $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-epsilon_R])$$ + """ + epo_reg_loss, _ = self.trainer.eval_r_loss() + multiplier = np.exp(self.rate_exp_shoulder * (epo_reg_loss - self.epsilon_r)) + target = self.dict_multiply(self.mmu, multiplier) + self.mmu = target + return False + + def dict_is_zero(self, dict_mu): + """ + check if hyper-parameter start from zero + """ + for key in dict_mu.keys(): + if dict_mu[key] == 0.0: + return True + return False + + def dict_multiply(self, dict_base, multiplier): + """ + multiply a float to each element of a dictionary + """ + assert multiplier > 1 + return {key: val*multiplier for key, val in dict_base.items()} diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 076da9d9c..e14220b6b 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -7,6 +7,7 @@ from domainlab.algos.trainers.a_trainer import AbstractTrainer from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.fbopt import HyperSchedulerFeedback +from domainlab.algos.trainers.fbopt_alternate import HyperSchedulerFeedbackAlternave from domainlab.algos.msels.c_msel_bang import MSelBang from domainlab.utils.logger import Logger @@ -40,7 +41,8 @@ def before_tr(self): before training begins, construct helper objects """ self.observer.msel = MSelBang(max_es=None) - self.set_scheduler(scheduler=HyperSchedulerFeedback) + # self.set_scheduler(scheduler=HyperSchedulerFeedback) + self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) self.model.evaluate(self.loader_te, self.device) self.inner_trainer = TrainerBasic() # look ahead # here we need a mechanism to generate deep copy of the model From 242ecf2025817377b3afbfc5d36045604b921c14 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Sep 2023 16:23:51 +0200 Subject: [PATCH 071/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index c2eb90861..7a763fb86 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -35,6 +35,7 @@ def __init__(self, trainer, **kwargs): self.count_found_operator = 0 self.count_search_mu = 0 ######################################## + # FIXME: make the following a vector, (or dictionary) self.rate_exp_shoulder = 0.0001 self.epsilon_r = 20 @@ -62,6 +63,7 @@ def search_mu(self, dict_theta=None, iter_start=None): $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-epsilon_R])$$ """ epo_reg_loss, _ = self.trainer.eval_r_loss() + # FIXME: use dictionary to replace scalar representation multiplier = np.exp(self.rate_exp_shoulder * (epo_reg_loss - self.epsilon_r)) target = self.dict_multiply(self.mmu, multiplier) self.mmu = target @@ -80,5 +82,6 @@ def dict_multiply(self, dict_base, multiplier): """ multiply a float to each element of a dictionary """ + # FIXME: make multipler also a dictionary assert multiplier > 1 return {key: val*multiplier for key, val in dict_base.items()} From 321004610b749f59149deb46a31ff496af664f13 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 12:19:42 +0200 Subject: [PATCH 072/762] manual decorate dial with fbopt --- domainlab/algos/builder_fbopt_dial.py | 45 ++++++++++++++++++++++++++ domainlab/algos/trainers/a_trainer.py | 34 +++++++++++++++++++ domainlab/algos/trainers/train_dial.py | 15 +++++++++ 3 files changed, 94 insertions(+) create mode 100644 domainlab/algos/builder_fbopt_dial.py diff --git a/domainlab/algos/builder_fbopt_dial.py b/domainlab/algos/builder_fbopt_dial.py new file mode 100644 index 000000000..ef4b4ea66 --- /dev/null +++ b/domainlab/algos/builder_fbopt_dial.py @@ -0,0 +1,45 @@ +""" +builder for feedback optimization of dial +""" +from domainlab.algos.a_algo_builder import NodeAlgoBuilder +from domainlab.algos.msels.c_msel_val import MSelValPerf +from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor +from domainlab.algos.observers.b_obvisitor import ObVisitor +from domainlab.algos.trainers.zoo_trainer import TrainerChainNodeGetter +from domainlab.algos.trainers.train_fbopt import TrainerFbOpt +from domainlab.algos.trainers.train_dial import TrainerDIAL +from domainlab.compos.zoo_nn import FeatExtractNNBuilderChainNodeGetter +from domainlab.models.model_deep_all import mk_deepall +from domainlab.utils.utils_cuda import get_device + + +class NodeAlgoBuilderFbOptDial(NodeAlgoBuilder): + """ + builder for feedback optimization for dial + """ + def init_business(self, exp): + """ + return trainer, model, observer + """ + task = exp.task + args = exp.args + device = get_device(args) + model_sel = MSelOracleVisitor(MSelValPerf(max_es=args.es)) + observer = ObVisitor(exp, model_sel, device) + + builder = FeatExtractNNBuilderChainNodeGetter( + args, arg_name_of_net="nname", + arg_path_of_net="npath")() # request, # @FIXME, constant string + + net = builder.init_business(flag_pretrain=True, dim_out=task.dim_y, + remove_last_layer=False, args=args, + i_c=task.isize.i_c, + i_h=task.isize.i_h, + i_w=task.isize.i_w) + + model = mk_deepall()(net, list_str_y=task.list_str_y) + trainer_in = TrainerDIAL() + trainer_in.init_business(model, task, observer, device, args) + trainer = TrainerFbOpt() + trainer.init_business(trainer_in, task, observer, device, args) + return trainer, model, observer, device diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index ad6050d5e..04a0db780 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -136,3 +136,37 @@ def is_myjob(self, request): :param request: string """ return request == self.name + + def hyper_init(self): + """ + safe API as model + """ + + def get_model(self): + """ + treat trainer as a model + """ + if "trainer" not in str(type(self.model)).lower(): + return self.model + return self.model.model + + def as_model(self): + """ + used for decorator pattern + + It is not necessary to write any function that just copies the pattern + self.get_model().do_something() + """ + + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): + """ + use trainer as a model, this is the default behavior, if we want to have decorated + behavior of regularization loss, then this default behavior has to be changed. + """ + return self.get_model().cal_reg_loss(tensor_x, tensor_y, tensor_d) + + def cal_task_loss(self, tensor_x, tensor_y): + """ + depute to the inner most trainer's model + """ + return self.get_model().cal_task_loss(tensor_x, tensor_y) diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index 54ff6d0eb..0bc357461 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -36,6 +36,21 @@ def gen_adversarial(self, device, img_natural, vec_y): img_adv = torch.clamp(img_adv, 0.0, 1.0) return img_adv + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): + """ + Let trainer behave like a model, so that other trainer could use it + """ + tensor_x_adv = self.gen_adversarial(self.device, tensor_x, tensor_y) + tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) + loss_dial = self.model.cal_loss(tensor_x_batch_adv_no_grad, tensor_y, tensor_d) + # FIXME: dial is different from other regularizer, + # no matter if self.model is a trainer or complex model like diva? + # self.model should return cal_loss, and loss_dial is the same function evaluated + # on the augmented data + # However, if we want to tune all the multipliers, we should return all reg losses in the decorator chain, + # but the current implementation is enough to be used for deepall/ERM + return [loss_dial.sum()], [self.aconf.gamma_reg] + def tr_epoch(self, epoch): self.model.train() self.epo_loss_tr = 0 From aa514c773a0ca3b2c79d3ea0f6f853545cf795aa Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 13:26:00 +0200 Subject: [PATCH 073/762] tensorboard ready --- domainlab/algos/trainers/fbopt_alternate.py | 9 +++++++-- domainlab/algos/trainers/train_fbopt.py | 2 +- run_fbopt.sh | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 7a763fb86..532cb3915 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -4,6 +4,7 @@ import copy import numpy as np from domainlab.utils.logger import Logger +from torch.utils.tensorboard import SummaryWriter class HyperSchedulerFeedbackAlternave(): @@ -38,6 +39,7 @@ def __init__(self, trainer, **kwargs): # FIXME: make the following a vector, (or dictionary) self.rate_exp_shoulder = 0.0001 self.epsilon_r = 20 + self.writer = SummaryWriter() def update_anchor(self, dict_par): """ @@ -55,7 +57,7 @@ def set_theta_ref(self): else: self.dict_theta_ref = copy.deepcopy(self.dict_theta) - def search_mu(self, dict_theta=None, iter_start=None): + def search_mu(self, dict_theta=None, miter=None): """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value @@ -67,6 +69,9 @@ def search_mu(self, dict_theta=None, iter_start=None): multiplier = np.exp(self.rate_exp_shoulder * (epo_reg_loss - self.epsilon_r)) target = self.dict_multiply(self.mmu, multiplier) self.mmu = target + val = list(target.values())[0] + self.writer.add_scalar('mmu', val, miter) + self.writer.add_scalar('reg', epo_reg_loss, miter) return False def dict_is_zero(self, dict_mu): @@ -83,5 +88,5 @@ def dict_multiply(self, dict_base, multiplier): multiply a float to each element of a dictionary """ # FIXME: make multipler also a dictionary - assert multiplier > 1 + # NOTE: allow multipler be bigger than 1 return {key: val*multiplier for key, val in dict_base.items()} diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index e14220b6b..fbec47386 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -131,7 +131,7 @@ def tr_epoch(self, epoch): flag_success = self.hyper_scheduler.search_mu( dict(self.model.named_parameters()), - iter_start=1) # FIXME: iter_start=0 or 1? + miter=epoch) # FIXME: iter_start=0 or 1? if flag_success: # only in success case, mu will be updated diff --git a/run_fbopt.sh b/run_fbopt.sh index 1e4533573..2b2e7d064 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=200 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto From a15a721746d4c15743ceef1b471e057ad2a164db Mon Sep 17 00:00:00 2001 From: nutan Date: Tue, 19 Sep 2023 13:39:35 +0200 Subject: [PATCH 074/762] moving average --- domainlab/algos/trainers/fbopt_alternate.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 532cb3915..bb8928bce 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -39,7 +39,10 @@ def __init__(self, trainer, **kwargs): # FIXME: make the following a vector, (or dictionary) self.rate_exp_shoulder = 0.0001 self.epsilon_r = 20 + self.reg_lower_bound = 20 self.writer = SummaryWriter() + self.ma = 0.5 + self.epsilon_r = False def update_anchor(self, dict_par): """ @@ -66,6 +69,12 @@ def search_mu(self, dict_theta=None, miter=None): """ epo_reg_loss, _ = self.trainer.eval_r_loss() # FIXME: use dictionary to replace scalar representation + epsilon_r = epo_reg_loss - self.reg_lower_bound + # TODO: can be replaced by a controller + if self.epsilon_r is False: + self.epsilon_r = epsilon_r + else: + self.epsilon_r = (1 - self.ma) * self.epsilon_r + self.ma * epsilon_r multiplier = np.exp(self.rate_exp_shoulder * (epo_reg_loss - self.epsilon_r)) target = self.dict_multiply(self.mmu, multiplier) self.mmu = target From d61684a44b463bfa1a9293ad9f3e8d5944b6af50 Mon Sep 17 00:00:00 2001 From: nutan Date: Tue, 19 Sep 2023 13:46:35 +0200 Subject: [PATCH 075/762] moving average --- domainlab/algos/trainers/fbopt_alternate.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index bb8928bce..52664f9a7 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -38,7 +38,6 @@ def __init__(self, trainer, **kwargs): ######################################## # FIXME: make the following a vector, (or dictionary) self.rate_exp_shoulder = 0.0001 - self.epsilon_r = 20 self.reg_lower_bound = 20 self.writer = SummaryWriter() self.ma = 0.5 @@ -69,13 +68,16 @@ def search_mu(self, dict_theta=None, miter=None): """ epo_reg_loss, _ = self.trainer.eval_r_loss() # FIXME: use dictionary to replace scalar representation - epsilon_r = epo_reg_loss - self.reg_lower_bound + delta_epsilon_r = epo_reg_loss - self.reg_lower_bound # TODO: can be replaced by a controller - if self.epsilon_r is False: - self.epsilon_r = epsilon_r + if self.delta_epsilon_r is False: + self.delta_epsilon_r = delta_epsilon_r else: - self.epsilon_r = (1 - self.ma) * self.epsilon_r + self.ma * epsilon_r - multiplier = np.exp(self.rate_exp_shoulder * (epo_reg_loss - self.epsilon_r)) + # PI control. + # self.delta_epsilon_r is the previous time step. + # delta_epsilon_r is the current time step + self.delta_epsilon_r = (1 - self.ma) * self.delta_epsilon_r + self.ma * delta_epsilon_r + multiplier = np.exp(self.rate_exp_shoulder * (self.delta_epsilon_r)) target = self.dict_multiply(self.mmu, multiplier) self.mmu = target val = list(target.values())[0] From f09a9ce9ffa650569b908f6acff53510c15a0df2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 13:47:29 +0200 Subject: [PATCH 076/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 532cb3915..28e5369b5 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -72,7 +72,7 @@ def search_mu(self, dict_theta=None, miter=None): val = list(target.values())[0] self.writer.add_scalar('mmu', val, miter) self.writer.add_scalar('reg', epo_reg_loss, miter) - return False + return True def dict_is_zero(self, dict_mu): """ From 6ba72c2423814a80956ade0ddc9e73e024e15968 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 13:55:15 +0200 Subject: [PATCH 077/762] moving average runable, loss being supressed --- domainlab/algos/trainers/fbopt_alternate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 47b3a0869..2775530e8 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -38,7 +38,9 @@ def __init__(self, trainer, **kwargs): ######################################## # FIXME: make the following a vector, (or dictionary) self.rate_exp_shoulder = 0.0001 + self.delta_epsilon_r = False # False here just used to decide if value first use or not self.reg_lower_bound = 20 + self.mu_clip = 100_000 self.writer = SummaryWriter() self.ma = 0.5 self.epsilon_r = False @@ -73,8 +75,8 @@ def search_mu(self, dict_theta=None, miter=None): if self.delta_epsilon_r is False: self.delta_epsilon_r = delta_epsilon_r else: - # PI control. - # self.delta_epsilon_r is the previous time step. + # PI control. + # self.delta_epsilon_r is the previous time step. # delta_epsilon_r is the current time step self.delta_epsilon_r = (1 - self.ma) * self.delta_epsilon_r + self.ma * delta_epsilon_r multiplier = np.exp(self.rate_exp_shoulder * (self.delta_epsilon_r)) @@ -83,6 +85,7 @@ def search_mu(self, dict_theta=None, miter=None): val = list(target.values())[0] self.writer.add_scalar('mmu', val, miter) self.writer.add_scalar('reg', epo_reg_loss, miter) + self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True def dict_is_zero(self, dict_mu): From 2db9cc9534fd644272fc3a01f285542c9a39abe4 Mon Sep 17 00:00:00 2001 From: nutan Date: Tue, 19 Sep 2023 13:57:10 +0200 Subject: [PATCH 078/762] clip --- domainlab/algos/trainers/fbopt_alternate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 2775530e8..891c6b0aa 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -40,7 +40,7 @@ def __init__(self, trainer, **kwargs): self.rate_exp_shoulder = 0.0001 self.delta_epsilon_r = False # False here just used to decide if value first use or not self.reg_lower_bound = 20 - self.mu_clip = 100_000 + self.mu_clip = 10000 self.writer = SummaryWriter() self.ma = 0.5 self.epsilon_r = False @@ -81,7 +81,7 @@ def search_mu(self, dict_theta=None, miter=None): self.delta_epsilon_r = (1 - self.ma) * self.delta_epsilon_r + self.ma * delta_epsilon_r multiplier = np.exp(self.rate_exp_shoulder * (self.delta_epsilon_r)) target = self.dict_multiply(self.mmu, multiplier) - self.mmu = target + self.mmu = np.clip(target, a_min=0.0, a_max=self.mu_clip) val = list(target.values())[0] self.writer.add_scalar('mmu', val, miter) self.writer.add_scalar('reg', epo_reg_loss, miter) From b5d6720ae88287df41cf3fa624e032e08862a48f Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 14:04:03 +0200 Subject: [PATCH 079/762] clip works for mu --- domainlab/algos/trainers/fbopt_alternate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 891c6b0aa..becc12c0d 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -81,13 +81,16 @@ def search_mu(self, dict_theta=None, miter=None): self.delta_epsilon_r = (1 - self.ma) * self.delta_epsilon_r + self.ma * delta_epsilon_r multiplier = np.exp(self.rate_exp_shoulder * (self.delta_epsilon_r)) target = self.dict_multiply(self.mmu, multiplier) - self.mmu = np.clip(target, a_min=0.0, a_max=self.mu_clip) + self.mmu = self.dict_clip(self.mmu) val = list(target.values())[0] self.writer.add_scalar('mmu', val, miter) self.writer.add_scalar('reg', epo_reg_loss, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True + def dict_clip(self, dict_base): + return {key: np.clip(val, a_min=0.0, a_max=self.mu_clip) for key, val in dict_base.items()} + def dict_is_zero(self, dict_mu): """ check if hyper-parameter start from zero From e8de85b2a76c9d47b15033e460752f1270aacbbc Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 14:12:09 +0200 Subject: [PATCH 080/762] fix bug clip and report --- domainlab/algos/trainers/fbopt_alternate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index becc12c0d..4e42dbe56 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -81,8 +81,8 @@ def search_mu(self, dict_theta=None, miter=None): self.delta_epsilon_r = (1 - self.ma) * self.delta_epsilon_r + self.ma * delta_epsilon_r multiplier = np.exp(self.rate_exp_shoulder * (self.delta_epsilon_r)) target = self.dict_multiply(self.mmu, multiplier) - self.mmu = self.dict_clip(self.mmu) - val = list(target.values())[0] + self.mmu = self.dict_clip(target) + val = list(self.mmu.values())[0] self.writer.add_scalar('mmu', val, miter) self.writer.add_scalar('reg', epo_reg_loss, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) From 1ee4680438aeeb4b7195dafb31ab6e2a8a7e3f8c Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 14:55:47 +0200 Subject: [PATCH 081/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 4 ++-- run_fbopt.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 4e42dbe56..13b6f5baf 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -37,9 +37,9 @@ def __init__(self, trainer, **kwargs): self.count_search_mu = 0 ######################################## # FIXME: make the following a vector, (or dictionary) - self.rate_exp_shoulder = 0.0001 + self.rate_exp_shoulder = 0.001 self.delta_epsilon_r = False # False here just used to decide if value first use or not - self.reg_lower_bound = 20 + self.reg_lower_bound = 100 # FIXME: set this value according to initial evaluation of neural network self.mu_clip = 10000 self.writer = SummaryWriter() self.ma = 0.5 diff --git a/run_fbopt.sh b/run_fbopt.sh index 2b2e7d064..da181fe92 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=200 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto From b99ffa65841b98aa8f5f79816e46547da132de71 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 15:21:45 +0200 Subject: [PATCH 082/762] refine code, rename --- domainlab/algos/trainers/fbopt_alternate.py | 11 +++++++---- domainlab/algos/trainers/train_fbopt.py | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 13b6f5baf..71aa922f4 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -39,7 +39,7 @@ def __init__(self, trainer, **kwargs): # FIXME: make the following a vector, (or dictionary) self.rate_exp_shoulder = 0.001 self.delta_epsilon_r = False # False here just used to decide if value first use or not - self.reg_lower_bound = 100 # FIXME: set this value according to initial evaluation of neural network + self.reg_lower_bound_as_setpoint = 100 # FIXME: set this value according to initial evaluation of neural network self.mu_clip = 10000 self.writer = SummaryWriter() self.ma = 0.5 @@ -70,7 +70,7 @@ def search_mu(self, dict_theta=None, miter=None): """ epo_reg_loss, _ = self.trainer.eval_r_loss() # FIXME: use dictionary to replace scalar representation - delta_epsilon_r = epo_reg_loss - self.reg_lower_bound + delta_epsilon_r = epo_reg_loss - self.reg_lower_bound_as_setpoint # TODO: can be replaced by a controller if self.delta_epsilon_r is False: self.delta_epsilon_r = delta_epsilon_r @@ -79,8 +79,8 @@ def search_mu(self, dict_theta=None, miter=None): # self.delta_epsilon_r is the previous time step. # delta_epsilon_r is the current time step self.delta_epsilon_r = (1 - self.ma) * self.delta_epsilon_r + self.ma * delta_epsilon_r - multiplier = np.exp(self.rate_exp_shoulder * (self.delta_epsilon_r)) - target = self.dict_multiply(self.mmu, multiplier) + gain = np.exp(self.rate_exp_shoulder * (self.delta_epsilon_r)) + target = self.dict_multiply(self.mmu, gain) self.mmu = self.dict_clip(target) val = list(self.mmu.values())[0] self.writer.add_scalar('mmu', val, miter) @@ -89,6 +89,9 @@ def search_mu(self, dict_theta=None, miter=None): return True def dict_clip(self, dict_base): + """ + clip each entry of the mu according to pre-set self.mu_clip + """ return {key: np.clip(val, a_min=0.0, a_max=self.mu_clip) for key, val in dict_base.items()} def dict_is_zero(self, dict_mu): diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index fbec47386..6ce0c4266 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -115,7 +115,6 @@ def tr_epoch(self, epoch): the model will tunnel/jump/shoot into the found pivot parameter $\\theta^{(k+1)}$, otherwise, """ - # FIXME: check if reg is decreasing by logging and plot epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") @@ -175,6 +174,6 @@ def tr_epoch(self, epoch): logger.info("!!!!found free descent operator") if self.aconf.myoptic_pareto: self.hyper_scheduler.update_anchor(dict_par) - self.observer.update(epoch) + self.observer.update(epoch) # FIXME: model selection should be disabled self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return False # total number of epochs controled in args From e406cc36791a05f5315bca59c4219f51861c7ebb Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 16:16:57 +0200 Subject: [PATCH 083/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 2 +- run_fbopt.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 71aa922f4..e44bc19c8 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -39,7 +39,7 @@ def __init__(self, trainer, **kwargs): # FIXME: make the following a vector, (or dictionary) self.rate_exp_shoulder = 0.001 self.delta_epsilon_r = False # False here just used to decide if value first use or not - self.reg_lower_bound_as_setpoint = 100 # FIXME: set this value according to initial evaluation of neural network + self.reg_lower_bound_as_setpoint = 117 # FIXME: set this value according to initial evaluation of neural network self.mu_clip = 10000 self.writer = SummaryWriter() self.ma = 0.5 diff --git a/run_fbopt.sh b/run_fbopt.sh index da181fe92..fede457f9 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=2000 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto From 8ec956a7bfff61198c0412ccee6074214773673a Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 16:26:57 +0200 Subject: [PATCH 084/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index e44bc19c8..a413a536b 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -37,7 +37,7 @@ def __init__(self, trainer, **kwargs): self.count_search_mu = 0 ######################################## # FIXME: make the following a vector, (or dictionary) - self.rate_exp_shoulder = 0.001 + self.k_p_control = 0.001 self.delta_epsilon_r = False # False here just used to decide if value first use or not self.reg_lower_bound_as_setpoint = 117 # FIXME: set this value according to initial evaluation of neural network self.mu_clip = 10000 @@ -79,7 +79,7 @@ def search_mu(self, dict_theta=None, miter=None): # self.delta_epsilon_r is the previous time step. # delta_epsilon_r is the current time step self.delta_epsilon_r = (1 - self.ma) * self.delta_epsilon_r + self.ma * delta_epsilon_r - gain = np.exp(self.rate_exp_shoulder * (self.delta_epsilon_r)) + gain = np.exp(self.k_p_control * (self.delta_epsilon_r)) target = self.dict_multiply(self.mmu, gain) self.mmu = self.dict_clip(target) val = list(self.mmu.values())[0] From 38a8a22baa089116f23e9db2f308b3e0aeb913c2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 16:29:20 +0200 Subject: [PATCH 085/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index a413a536b..740d7ef54 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -39,7 +39,7 @@ def __init__(self, trainer, **kwargs): # FIXME: make the following a vector, (or dictionary) self.k_p_control = 0.001 self.delta_epsilon_r = False # False here just used to decide if value first use or not - self.reg_lower_bound_as_setpoint = 117 # FIXME: set this value according to initial evaluation of neural network + self.reg_lower_bound_as_setpoint = 117.5 # FIXME: set this value according to initial evaluation of neural network self.mu_clip = 10000 self.writer = SummaryWriter() self.ma = 0.5 From db548ca0272fad4f7a2adfa772d2ca0ff6ccde50 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 17:01:29 +0200 Subject: [PATCH 086/762] automatic initialization of epsilon as setpoint --- domainlab/algos/trainers/train_fbopt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 6ce0c4266..54d3fa8d4 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -50,6 +50,9 @@ def before_tr(self): copy.deepcopy(self.model), self.task, self.observer, self.device, self.aconf, flag_accept=False) + epo_reg_loss, epo_task_loss = self.eval_r_loss() + self.hyper_scheduler.reg_lower_bound_as_setpoint = epo_reg_loss * 0.999 # FIXME: set 0.999 as hyperparameter + def opt_theta(self, dict4mu, dict_theta0): """ operator for theta, move gradient for one epoch, then check if criteria is met From abd88e276459efbd5ad67b512c5efe253dfd71a5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 19 Sep 2023 20:24:23 +0200 Subject: [PATCH 087/762] . --- run_fbopt_pacs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_pacs.sh b/run_fbopt_pacs.sh index 188d475fa..73c1e61ab 100644 --- a/run_fbopt_pacs.sh +++ b/run_fbopt_pacs.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 +python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=20 From 6f0ac6ef0b41f344c28c2f3d807ab9dbd0cb1027 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 09:19:58 +0200 Subject: [PATCH 088/762] rename --- domainlab/algos/trainers/fbopt_alternate.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 740d7ef54..abcacaf55 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -38,11 +38,12 @@ def __init__(self, trainer, **kwargs): ######################################## # FIXME: make the following a vector, (or dictionary) self.k_p_control = 0.001 - self.delta_epsilon_r = False # False here just used to decide if value first use or not - self.reg_lower_bound_as_setpoint = 117.5 # FIXME: set this value according to initial evaluation of neural network + self.delta_epsilon_r = False # False here just used to decide if value first use or not + self.reg_lower_bound_as_setpoint = None + # NOTE: this value will be set according to initial evaluation of neural network self.mu_clip = 10000 self.writer = SummaryWriter() - self.ma = 0.5 + self.coeff_ma = 0.5 self.epsilon_r = False def update_anchor(self, dict_par): @@ -78,7 +79,7 @@ def search_mu(self, dict_theta=None, miter=None): # PI control. # self.delta_epsilon_r is the previous time step. # delta_epsilon_r is the current time step - self.delta_epsilon_r = (1 - self.ma) * self.delta_epsilon_r + self.ma * delta_epsilon_r + self.delta_epsilon_r = (1 - self.coeff_ma) * self.delta_epsilon_r + self.coeff_ma * delta_epsilon_r gain = np.exp(self.k_p_control * (self.delta_epsilon_r)) target = self.dict_multiply(self.mmu, gain) self.mmu = self.dict_clip(target) From b93ce1d1235bbc4b45ad74e008c42874f4008d41 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 11:06:18 +0200 Subject: [PATCH 089/762] dial adversarial image no grad --- domainlab/algos/observers/b_obvisitor.py | 2 +- domainlab/algos/trainers/a_trainer.py | 18 ++++++++++-------- domainlab/algos/trainers/fbopt.py | 2 +- domainlab/algos/trainers/train_dial.py | 8 ++++++-- domainlab/algos/trainers/train_fbopt.py | 18 +++++++++--------- domainlab/algos/zoo_algos.py | 2 ++ domainlab/models/a_model.py | 6 ++++++ run_fbopt.sh | 2 +- 8 files changed, 36 insertions(+), 22 deletions(-) diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index 497c71b85..de2838404 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -62,7 +62,7 @@ def accept(self, trainer): accept invitation as a visitor """ self.host_trainer = trainer - self.perf_metric = self.host_trainer.model.create_perf_obj(self.task) + self.perf_metric = self.host_trainer.model.as_model().create_perf_obj(self.task) self.model_sel.accept(trainer, self) def after_all(self): diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 04a0db780..09c8caeac 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -34,6 +34,7 @@ def __init__(self, successor_node=None): self.observer = None self.device = None self.aconf = None + self.gamma_reg = None # self.loader_tr = None self.loader_tr_no_drop = None @@ -66,6 +67,7 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True): self.observer = observer self.device = device self.aconf = aconf + self.gamma_reg = self.aconf.gamma_reg # self.loader_tr = task.loader_tr self.loader_tr_no_drop = task._loader_tr_no_drop @@ -74,21 +76,20 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True): if flag_accept: self.observer.accept(self) - self.model = self.model.to(device) # self.num_batches = len(self.loader_tr) self.flag_update_hyper_per_epoch = False self.flag_update_hyper_per_batch = False self.epo_loss_tr = None self.hyper_scheduler = None - self.optimizer = mk_opt(self.model, self.aconf) + self.optimizer = mk_opt(self.model.as_model(), self.aconf) self.flag_initialized = True def reset(self): """ make a new optimizer to clear internal state """ - self.optimizer = mk_opt(self.model, self.aconf) + self.optimizer = mk_opt(self.model.as_model(), self.aconf) @abc.abstractmethod def tr_epoch(self, epoch): @@ -137,11 +138,6 @@ def is_myjob(self, request): """ return request == self.name - def hyper_init(self): - """ - safe API as model - """ - def get_model(self): """ treat trainer as a model @@ -157,6 +153,12 @@ def as_model(self): It is not necessary to write any function that just copies the pattern self.get_model().do_something() """ + return self.get_model() + + def get_dict_model_params(self): + """ + """ + return dict(self.as_model().named_parameters()) def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): """ diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 221926f11..ef8110bf2 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -26,7 +26,7 @@ def __init__(self, trainer, **kwargs): # for exponential increase of mu, mu can not be starting from zero self.beta_mu = trainer.aconf.beta_mu self.dict_theta_bar = None - self.dict_theta = copy.deepcopy(dict(self.trainer.model.named_parameters())) + self.dict_theta = copy.deepcopy(self.trainer.get_dict_model_params()) # theta_ref should be equal to either theta or theta bar as reference # since theta_ref will be used to judge if criteria is met self.dict_theta_ref = None diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index 0bc357461..360570e26 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -40,6 +40,7 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): """ Let trainer behave like a model, so that other trainer could use it """ + self.model.train() tensor_x_adv = self.gen_adversarial(self.device, tensor_x, tensor_y) tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) loss_dial = self.model.cal_loss(tensor_x_batch_adv_no_grad, tensor_y, tensor_d) @@ -49,7 +50,7 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): # on the augmented data # However, if we want to tune all the multipliers, we should return all reg losses in the decorator chain, # but the current implementation is enough to be used for deepall/ERM - return [loss_dial.sum()], [self.aconf.gamma_reg] + return [loss_dial], [self.gamma_reg] def tr_epoch(self, epoch): self.model.train() @@ -62,10 +63,13 @@ def tr_epoch(self, epoch): tensor_x_adv = self.gen_adversarial(self.device, tensor_x, vec_y) tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) loss_dial = self.model.cal_loss(tensor_x_batch_adv_no_grad, vec_y, vec_d) # @FIXME - loss = loss.sum() + self.aconf.gamma_reg * loss_dial.sum() + loss = loss.sum() + self.gamma_reg * loss_dial.sum() loss.backward() self.optimizer.step() self.epo_loss_tr += loss.detach().item() self.after_batch(epoch, ind_batch) flag_stop = self.observer.update(epoch) # notify observer return flag_stop + + def hyper_init(self, functor_scheduler, trainer): + return functor_scheduler(trainer=trainer, gamma_reg=self.gamma_reg) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 076da9d9c..88e3ed6f9 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -41,11 +41,11 @@ def before_tr(self): """ self.observer.msel = MSelBang(max_es=None) self.set_scheduler(scheduler=HyperSchedulerFeedback) - self.model.evaluate(self.loader_te, self.device) + self.model.as_model().evaluate(self.loader_te, self.device) self.inner_trainer = TrainerBasic() # look ahead # here we need a mechanism to generate deep copy of the model self.inner_trainer.init_business( - copy.deepcopy(self.model), self.task, self.observer, self.device, self.aconf, + copy.deepcopy(self.model.as_model()), self.task, self.observer, self.device, self.aconf, flag_accept=False) def opt_theta(self, dict4mu, dict_theta0): @@ -69,7 +69,7 @@ def eval_p_loss(self, dict4mu, dict_theta): evaluate the penalty function value on all available training data # TODO: normalize loss via batchsize """ - temp_model = copy.deepcopy(self.model) + temp_model = copy.deepcopy(self.model.as_model()) # mock the model hyper-parameter to be from dict4mu temp_model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) temp_model.set_params(dict_theta) @@ -89,8 +89,8 @@ def eval_r_loss(self): ERM loss on all available training data # TODO: normalize loss via batchsize """ - temp_model = copy.deepcopy(self.model) - temp_model.eval() + temp_model = self.model + # temp_model.as_model().eval() # mock the model hyper-parameter to be from dict4mu epo_reg_loss = 0 epo_task_loss = 0 @@ -128,7 +128,7 @@ def tr_epoch(self, epoch): # self.model.train() # FIXME: i guess no need to put into train mode? flag_success = self.hyper_scheduler.search_mu( - dict(self.model.named_parameters()), + dict(self.model.as_model().named_parameters()), iter_start=1) # FIXME: iter_start=0 or 1? if flag_success: @@ -141,7 +141,7 @@ def tr_epoch(self, epoch): epo_task_loss={epo_task_loss}") # shoot/tunnel to new found parameter configuration - self.model.set_params(self.hyper_scheduler.dict_theta) + self.model.as_model().set_params(self.hyper_scheduler.dict_theta) epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") @@ -159,10 +159,10 @@ def tr_epoch(self, epoch): f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss_before}, \ epo_task_loss={epo_task_loss_before}") - theta = dict(self.model.named_parameters()) + theta = dict(self.model.as_model().named_parameters()) dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) # move according to gradient to update theta_bar - self.model.set_params(dict_par) + self.model.as_model().set_params(dict_par) epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") diff --git a/domainlab/algos/zoo_algos.py b/domainlab/algos/zoo_algos.py index 3fa735170..a342abb73 100644 --- a/domainlab/algos/zoo_algos.py +++ b/domainlab/algos/zoo_algos.py @@ -9,6 +9,7 @@ from domainlab.algos.builder_matchdg import NodeAlgoBuilderMatchDG from domainlab.algos.builder_match_hduva import NodeAlgoBuilderMatchHDUVA from domainlab.algos.builder_api_model import NodeAlgoBuilderAPIModel +from domainlab.algos.builder_fbopt_dial import NodeAlgoBuilderFbOptDial from domainlab.utils.u_import import import_path @@ -46,6 +47,7 @@ def __call__(self): chain = NodeAlgoBuilderMatchDG(chain) chain = NodeAlgoBuilderMatchHDUVA(chain) chain = NodeAlgoBuilderAPIModel(chain) + chain = NodeAlgoBuilderFbOptDial(chain) chain = self.register_external_node(chain) node = chain.handle(self.aname) return node diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index ccd4e6556..040ebc6a7 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -55,6 +55,12 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): task independent regularization loss for domain generalization """ + def as_model(self): + """ + redundant method to be consistent with trainer + """ + return self + def forward(self, tensor_x, tensor_y, tensor_d, others=None): """forward. diff --git a/run_fbopt.sh b/run_fbopt.sh index 1e4533573..f2314efcd 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=fboptdial --trainer=dial --nname=alexnet --epos=20 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto From eba818f788c10d3ce8ad9f7dd84fd5dcd5a2147b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 20 Sep 2023 11:11:12 +0200 Subject: [PATCH 090/762] Delete demo_draw_loss.py --- demo_draw_loss.py | 97 ----------------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 demo_draw_loss.py diff --git a/demo_draw_loss.py b/demo_draw_loss.py deleted file mode 100644 index 3c8b6f3df..000000000 --- a/demo_draw_loss.py +++ /dev/null @@ -1,97 +0,0 @@ -""" -test if it is possible to have stable evaluation of a deepcopied model's loss -i.e. -1. if we evaluate it twice, will it get the same loss? -2. -""" -import torch -import torch.nn.functional as F -import torchvision -import torchvision.transforms as transforms -from torch import nn -import torch.optim as optim -import copy - -class Net(nn.Module): - def __init__(self): - super().__init__() - self.conv1 = nn.Conv2d(3, 6, 5) - self.pool = nn.MaxPool2d(2, 2) - self.conv2 = nn.Conv2d(6, 16, 5) - self.fc1 = nn.Linear(16 * 5 * 5, 120) - self.fc2 = nn.Linear(120, 84) - self.fc3 = nn.Linear(84, 10) - - def forward(self, x): - x = self.pool(F.relu(self.conv1(x))) - x = self.pool(F.relu(self.conv2(x))) - x = torch.flatten(x, 1) # flatten all dimensions except batch - x = F.relu(self.fc1(x)) - x = F.relu(self.fc2(x)) - x = self.fc3(x) - return x - - -net = Net() -criterion = nn.CrossEntropyLoss() -optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9) - - -transform = transforms.Compose( - [transforms.ToTensor(), - transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))]) - -batch_size = 4 - -trainset = torchvision.datasets.CIFAR10(root='./data', train=True, - download=True, transform=transform) -trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size, - shuffle=True, num_workers=2) - -testset = torchvision.datasets.CIFAR10(root='./data', train=False, - download=True, transform=transform) -testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size, - shuffle=False, num_workers=2) - -classes = ('plane', 'car', 'bird', 'cat', - 'deer', 'dog', 'frog', 'horse', 'ship', 'truck') - - - -def train_model(net): - running_loss = 0 - for i, data in enumerate(trainloader, 0): - # get the inputs; data is a list of [inputs, labels] - inputs, labels = data - # zero the parameter gradients - optimizer.zero_grad() - # forward + backward + optimize - outputs = net(inputs) - loss = criterion(outputs, labels) - loss.backward() - optimizer.step() - # print statistics - running_loss += loss.item() - print(f'train loss={running_loss}') - return running_loss - - -def eval_model(net): - net = copy.deepcopy(net) - running_loss = 0 - net.eval() - for i, data in enumerate(trainloader, 0): - # get the inputs; data is a list of [inputs, labels] - inputs, labels = data - # zero the parameter gradients - # forward + backward + optimize - outputs = net(inputs) - loss = criterion(outputs, labels) - # print statistics - running_loss += loss.item() - print(f'eval loss={running_loss}') - return running_loss - -eval_model(net) -train_model(net) -eval_model(net) From 394549dbf7aab9307c2ee099be2797f3f36ee7a9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 12:04:16 +0200 Subject: [PATCH 091/762] diva --- domainlab/models/model_diva.py | 4 ++-- run_fbopt_diva.sh | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 run_fbopt_diva.sh diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index e2d834885..84217d1af 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -88,14 +88,14 @@ def hyper_update(self, epoch, fun_scheduler): self.beta_y = dict_rst["beta_y"] self.beta_x = dict_rst["beta_x"] - def hyper_init(self, functor_scheduler): + def hyper_init(self, functor_scheduler, trainer=None): """ initiate a scheduler object via class name and things inside this model :param functor_scheduler: the class name of the scheduler """ return functor_scheduler( - trainer=None, + trainer=trainer, beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x) def get_list_str_y(self): diff --git a/run_fbopt_diva.sh b/run_fbopt_diva.sh new file mode 100644 index 000000000..ee821fdda --- /dev/null +++ b/run_fbopt_diva.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py +python main_out.py --te_d=caltech --task=mini_vlcs --bs=2 --aname=diva --trainer=fbopt --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=2000 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto From 043f75db01f6690ef87e9d6608598c13dea03cf8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 12:20:47 +0200 Subject: [PATCH 092/762] setpoint ratio hyper --- domainlab/algos/trainers/args_fbopt.py | 3 +++ domainlab/algos/trainers/train_fbopt.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 83f1ec193..a040d07c8 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -9,6 +9,9 @@ def add_args2parser_fbopt(parser): """ parser.add_argument('--init_mu4beta', type=float, default=0.001, help='initial beta for multiplication') + parser.add_argument('--ini_setpoint_ratio', type=float, default=0.9, + help='before training start, evaluate reg loss, \ + setpoint will be 0.9 of this loss') parser.add_argument('--beta_mu', type=float, default=1.1, help='how much to multiply mu each time') parser.add_argument('--delta_mu', type=float, default=None, diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 54d3fa8d4..67090ef8d 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -50,8 +50,9 @@ def before_tr(self): copy.deepcopy(self.model), self.task, self.observer, self.device, self.aconf, flag_accept=False) - epo_reg_loss, epo_task_loss = self.eval_r_loss() - self.hyper_scheduler.reg_lower_bound_as_setpoint = epo_reg_loss * 0.999 # FIXME: set 0.999 as hyperparameter + epo_reg_loss, _ = self.eval_r_loss() + self.hyper_scheduler.reg_lower_bound_as_setpoint = \ + epo_reg_loss * self.aconf.ini_setpoint_ratio def opt_theta(self, dict4mu, dict_theta0): """ From b5117e9fe67c992bdd2c43e64bcecbc23111b9f1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 13:48:08 +0200 Subject: [PATCH 093/762] . --- run_fbopt_diva.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_diva.sh b/run_fbopt_diva.sh index ee821fdda..e882663f2 100644 --- a/run_fbopt_diva.sh +++ b/run_fbopt_diva.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=2 --aname=diva --trainer=fbopt --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=2000 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto +python main_out.py --te_d=caltech --task=mini_vlcs --bs=8 --aname=diva --trainer=fbopt --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=2000 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto From d8301d69abe56a3a961f9033413fbafe8a655b70 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 14:20:59 +0200 Subject: [PATCH 094/762] . --- domainlab/algos/trainers/train_fbopt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 67090ef8d..f37fefa14 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -105,7 +105,10 @@ def eval_r_loss(self): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) tuple_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d) + # NOTE: first [0] extract the loss, second [0] get the list b_reg_loss = tuple_reg_loss[0][0] # FIXME: this only works when scalar multiplier + # FIXME: change this to vector + # each component of vector is a mini batch loss b_reg_loss = b_reg_loss.sum().item() b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() # sum will kill the dimension of the mini batch From 9cb53b86f2b86b3a98a1851fb3a65bc535c8de3b Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 14:25:41 +0200 Subject: [PATCH 095/762] . --- domainlab/algos/trainers/train_fbopt.py | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index f37fefa14..027e040ec 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -156,28 +156,28 @@ def tr_epoch(self, epoch): logger.info( f"at epoch {epoch}, after shooting: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") - else: + if 1: # if failed to find reg-pareto descent operator, continue training without # mu being updated - logger.info("failed to find pivot, move forward \\bar{\\theta}, \ - this will deteriorate reg loss!") - epo_reg_loss_before, epo_task_loss_before = self.eval_r_loss() - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info( - f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss_before}, \ - epo_task_loss={epo_task_loss_before}") - - theta = dict(self.model.named_parameters()) - dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) + #logger.info("failed to find pivot, move forward \\bar{\\theta}, \ + # this will deteriorate reg loss!") + #epo_reg_loss_before, epo_task_loss_before = self.eval_r_loss() + #logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + #logger.info( + # f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss_before}, \ + # epo_task_loss={epo_task_loss_before}") + + #theta = dict(self.model.named_parameters()) + # dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) # move according to gradient to update theta_bar - self.model.set_params(dict_par) + #self.model.set_params(dict_par) epo_reg_loss, epo_task_loss = self.eval_r_loss() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info( f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") - if epo_reg_loss < epo_reg_loss_before: + if epo_reg_loss < self.hyper_scheduler.: logger.info("!!!!found free descent operator") if self.aconf.myoptic_pareto: self.hyper_scheduler.update_anchor(dict_par) From 14b46f669d6a0ef378ce2155757b35e418179ddc Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 14:31:35 +0200 Subject: [PATCH 096/762] . --- domainlab/algos/trainers/train_fbopt.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 027e040ec..5ab31b410 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -177,10 +177,11 @@ def tr_epoch(self, epoch): logger.info( f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") - if epo_reg_loss < self.hyper_scheduler.: - logger.info("!!!!found free descent operator") - if self.aconf.myoptic_pareto: - self.hyper_scheduler.update_anchor(dict_par) + if epo_reg_loss < self.hyper_scheduler.reg_lower_bound_as_setpoint: + logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") + self.hyper_scheduler.reg_lower_bound_as_setpoint = epo_reg_loss + #if self.aconf.myoptic_pareto: + # self.hyper_scheduler.update_anchor(dict_par) self.observer.update(epoch) # FIXME: model selection should be disabled self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return False # total number of epochs controled in args From 938f570dc4bafba7dac99b954c7fe095e387835c Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 14:41:15 +0200 Subject: [PATCH 097/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index abcacaf55..6f922b302 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -2,6 +2,7 @@ update hyper-parameters during training """ import copy +import torch import numpy as np from domainlab.utils.logger import Logger from torch.utils.tensorboard import SummaryWriter @@ -85,7 +86,8 @@ def search_mu(self, dict_theta=None, miter=None): self.mmu = self.dict_clip(target) val = list(self.mmu.values())[0] self.writer.add_scalar('mmu', val, miter) - self.writer.add_scalar('reg', epo_reg_loss, miter) + self.writer.add_scalar('reg/dyn', epo_reg_loss, miter) + self.writer.add_scalar('reg/setpoint', self.reg_lower_bound_as_setpoint, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True From 265b3caa591f1b1ef8492d8a1ceb6f13f59b1c41 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 15:10:06 +0200 Subject: [PATCH 098/762] . --- domainlab/algos/trainers/train_fbopt.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index f37fefa14..9ac41c863 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -10,6 +10,7 @@ from domainlab.algos.trainers.fbopt_alternate import HyperSchedulerFeedbackAlternave from domainlab.algos.msels.c_msel_bang import MSelBang from domainlab.utils.logger import Logger +from operators import add class HyperSetter(): @@ -98,7 +99,7 @@ def eval_r_loss(self): temp_model = copy.deepcopy(self.model) temp_model.eval() # mock the model hyper-parameter to be from dict4mu - epo_reg_loss = 0 + epo_reg_loss = [] epo_task_loss = 0 with torch.no_grad(): for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): @@ -106,13 +107,16 @@ def eval_r_loss(self): tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) tuple_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d) # NOTE: first [0] extract the loss, second [0] get the list - b_reg_loss = tuple_reg_loss[0][0] # FIXME: this only works when scalar multiplier + list_b_reg_loss = tuple_reg_loss[0] # FIXME: this only works when scalar multiplier + list_b_reg_loss_sumed = [ele.sum().item() for ele in list_b_reg_loss] + if len(epo_reg_loss) == 0: + epo_reg_loss = list_b_reg_loss_sumed + else: + epo_reg_loss = list(map(add, epo_reg_loss, list_b_reg_loss_sumed)) # FIXME: change this to vector # each component of vector is a mini batch loss - b_reg_loss = b_reg_loss.sum().item() b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() # sum will kill the dimension of the mini batch - epo_reg_loss += b_reg_loss epo_task_loss += b_task_loss return epo_reg_loss, epo_task_loss From 920c05d52c8534c1223ca3031245f23f4f2b7c8b Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 15:12:10 +0200 Subject: [PATCH 099/762] . --- domainlab/algos/trainers/train_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 9ac41c863..fef885b1a 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -10,7 +10,7 @@ from domainlab.algos.trainers.fbopt_alternate import HyperSchedulerFeedbackAlternave from domainlab.algos.msels.c_msel_bang import MSelBang from domainlab.utils.logger import Logger -from operators import add +from operator import add class HyperSetter(): From 08f1ba026534d7b0291f9d4909c0e198ea452f7a Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 15:31:44 +0200 Subject: [PATCH 100/762] moving average of setpoint switch --- domainlab/algos/trainers/train_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 5ab31b410..fb8522300 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -179,7 +179,7 @@ def tr_epoch(self, epoch): epo_task_loss={epo_task_loss}") if epo_reg_loss < self.hyper_scheduler.reg_lower_bound_as_setpoint: logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") - self.hyper_scheduler.reg_lower_bound_as_setpoint = epo_reg_loss + self.hyper_scheduler.reg_lower_bound_as_setpoint = self.hyper_scheduler.coeff_ma * epo_reg_loss + (1-self.hyper_scheduler.coeff_ma)* self.hyper_scheduler.reg_lower_bound_as_setpoint #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) self.observer.update(epoch) # FIXME: model selection should be disabled From 551e7d16683094e4cf3db449b5ecce26fa7b4e6f Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 16:19:40 +0200 Subject: [PATCH 101/762] need gain to be a dictionary --- domainlab/algos/trainers/fbopt_alternate.py | 16 +++++++++++++--- domainlab/algos/trainers/train_fbopt.py | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 6f922b302..2caad8b07 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -63,6 +63,12 @@ def set_theta_ref(self): else: self.dict_theta_ref = copy.deepcopy(self.dict_theta) + def cal_delta4control(self, list1, list_setpoint): + return [a - b for a, b in zip(list1, list_setpoint)] + + def cal_delta_integration(self, list_old, list_new, coeff): + return [(1-coeff)*a + coeff*b for a, b in zip(list_old, list_new)] + def search_mu(self, dict_theta=None, miter=None): """ start from parameter dictionary dict_theta: {"layer":tensor}, @@ -72,7 +78,8 @@ def search_mu(self, dict_theta=None, miter=None): """ epo_reg_loss, _ = self.trainer.eval_r_loss() # FIXME: use dictionary to replace scalar representation - delta_epsilon_r = epo_reg_loss - self.reg_lower_bound_as_setpoint + # delta_epsilon_r = epo_reg_loss - self.reg_lower_bound_as_setpoint + delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.reg_lower_bound_as_setpoint) # TODO: can be replaced by a controller if self.delta_epsilon_r is False: self.delta_epsilon_r = delta_epsilon_r @@ -80,8 +87,11 @@ def search_mu(self, dict_theta=None, miter=None): # PI control. # self.delta_epsilon_r is the previous time step. # delta_epsilon_r is the current time step - self.delta_epsilon_r = (1 - self.coeff_ma) * self.delta_epsilon_r + self.coeff_ma * delta_epsilon_r - gain = np.exp(self.k_p_control * (self.delta_epsilon_r)) + # self.delta_epsilon_r = (1 - self.coeff_ma) * self.delta_epsilon_r + self.coeff_ma * delta_epsilon_r + self.delta_epsilon_r = self.cal_delta_integration(self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) + # FIXME: here we can not sum up selta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary + activation = self.k_p_control * (self.delta_epsilon_r) + gain = np.exp(activation) target = self.dict_multiply(self.mmu, gain) self.mmu = self.dict_clip(target) val = list(self.mmu.values())[0] diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 26476490a..57b39f0fd 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -53,7 +53,7 @@ def before_tr(self): epo_reg_loss, _ = self.eval_r_loss() self.hyper_scheduler.reg_lower_bound_as_setpoint = \ - epo_reg_loss * self.aconf.ini_setpoint_ratio + [ele * self.aconf.ini_setpoint_ratio for ele in epo_reg_loss] def opt_theta(self, dict4mu, dict_theta0): """ From 98bc188ad04bf769e42af48219c97dca149c90a4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 16:27:30 +0200 Subject: [PATCH 102/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 6f922b302..f75f77d29 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -46,6 +46,13 @@ def __init__(self, trainer, **kwargs): self.writer = SummaryWriter() self.coeff_ma = 0.5 self.epsilon_r = False + self.layout = { + "ABCDE": { + "loss": ["Multiline", ["reg/dyn", "reg/setpoint"]], + # "accuracy": ["Multiline", ["accuracy/train", "accuracy/validation"]], + }, + } + self.writer.add_custom_scalars(self.layout) def update_anchor(self, dict_par): """ From bb765b399e84d21577c3c9d4d0e33e097ead9f47 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 20 Sep 2023 16:41:56 +0200 Subject: [PATCH 103/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 5 +++++ domainlab/algos/trainers/train_fbopt.py | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 6f922b302..a86800d6e 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -113,3 +113,8 @@ def dict_multiply(self, dict_base, multiplier): # FIXME: make multipler also a dictionary # NOTE: allow multipler be bigger than 1 return {key: val*multiplier for key, val in dict_base.items()} + + def update_setpoint(self, epo_reg_loss): + # FIXME: use pareto-reg-descent operator to decide if set point should be adjusted + if epo_reg_loss < self.hyper_scheduler.reg_lower_bound_as_setpoint: + self.reg_lower_bound_as_setpoint = self.hyper_scheduler.coeff_ma * epo_reg_loss + (1-self.hyper_scheduler.coeff_ma)* self.hyper_scheduler.reg_lower_bound_as_setpoint diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index fb8522300..343eb0654 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -177,9 +177,10 @@ def tr_epoch(self, epoch): logger.info( f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") - if epo_reg_loss < self.hyper_scheduler.reg_lower_bound_as_setpoint: - logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") - self.hyper_scheduler.reg_lower_bound_as_setpoint = self.hyper_scheduler.coeff_ma * epo_reg_loss + (1-self.hyper_scheduler.coeff_ma)* self.hyper_scheduler.reg_lower_bound_as_setpoint + self.hyper_scheduler.update_setpoint() + # if epo_reg_loss < self.hyper_scheduler.reg_lower_bound_as_setpoint: + # logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") + # self.hyper_scheduler.reg_lower_bound_as_setpoint = self.hyper_scheduler.coeff_ma * epo_reg_loss + (1-self.hyper_scheduler.coeff_ma)* self.hyper_scheduler.reg_lower_bound_as_setpoint #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) self.observer.update(epoch) # FIXME: model selection should be disabled From 57bde44b29f8995d3670ac5e375b6c03e326923f Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 21 Sep 2023 11:46:58 +0200 Subject: [PATCH 104/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 3 ++- domainlab/algos/trainers/train_fbopt.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 2caad8b07..8714cb79f 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -90,7 +90,8 @@ def search_mu(self, dict_theta=None, miter=None): # self.delta_epsilon_r = (1 - self.coeff_ma) * self.delta_epsilon_r + self.coeff_ma * delta_epsilon_r self.delta_epsilon_r = self.cal_delta_integration(self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) # FIXME: here we can not sum up selta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary - activation = self.k_p_control * (self.delta_epsilon_r) + activation = [self.k_p_control * val for val in self.delta_epsilon_r] + breakpoint() gain = np.exp(activation) target = self.dict_multiply(self.mmu, gain) self.mmu = self.dict_clip(target) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 57b39f0fd..3035c51a1 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -1,3 +1,4 @@ + """ feedback optimization """ @@ -108,6 +109,7 @@ def eval_r_loss(self): tuple_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d) # NOTE: first [0] extract the loss, second [0] get the list list_b_reg_loss = tuple_reg_loss[0] # FIXME: this only works when scalar multiplier + breakpoint() list_b_reg_loss_sumed = [ele.sum().item() for ele in list_b_reg_loss] if len(epo_reg_loss) == 0: epo_reg_loss = list_b_reg_loss_sumed From f98b82f04d6af60c0dabd9659d3d89e74356ec8e Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 21 Sep 2023 12:23:03 +0200 Subject: [PATCH 105/762] ready --- domainlab/algos/trainers/fbopt_alternate.py | 13 +++++++------ domainlab/algos/trainers/train_fbopt.py | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 8714cb79f..c181a7106 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -91,9 +91,8 @@ def search_mu(self, dict_theta=None, miter=None): self.delta_epsilon_r = self.cal_delta_integration(self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) # FIXME: here we can not sum up selta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary activation = [self.k_p_control * val for val in self.delta_epsilon_r] - breakpoint() - gain = np.exp(activation) - target = self.dict_multiply(self.mmu, gain) + list_gain = np.exp(activation) + target = self.dict_multiply(self.mmu, list_gain) self.mmu = self.dict_clip(target) val = list(self.mmu.values())[0] self.writer.add_scalar('mmu', val, miter) @@ -117,10 +116,12 @@ def dict_is_zero(self, dict_mu): return True return False - def dict_multiply(self, dict_base, multiplier): + def dict_multiply(self, dict_base, list_multiplier): """ multiply a float to each element of a dictionary """ - # FIXME: make multipler also a dictionary + list_keys = list(dict_base.keys()) + list_zip = zip(list_keys, list_multiplier) + dict_multiplier = dict(list_zip) # NOTE: allow multipler be bigger than 1 - return {key: val*multiplier for key, val in dict_base.items()} + return {key: val*dict_multiplier[key] for key, val in dict_base.items()} diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 3035c51a1..4583c74a5 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -109,7 +109,6 @@ def eval_r_loss(self): tuple_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d) # NOTE: first [0] extract the loss, second [0] get the list list_b_reg_loss = tuple_reg_loss[0] # FIXME: this only works when scalar multiplier - breakpoint() list_b_reg_loss_sumed = [ele.sum().item() for ele in list_b_reg_loss] if len(epo_reg_loss) == 0: epo_reg_loss = list_b_reg_loss_sumed From c1ca511a51f6ca08b6d3e540b4d75f35ac81c0af Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 21 Sep 2023 14:08:53 +0200 Subject: [PATCH 106/762] runs without error --- domainlab/algos/trainers/fbopt_alternate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index c181a7106..07e0d15bb 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -96,8 +96,10 @@ def search_mu(self, dict_theta=None, miter=None): self.mmu = self.dict_clip(target) val = list(self.mmu.values())[0] self.writer.add_scalar('mmu', val, miter) - self.writer.add_scalar('reg/dyn', epo_reg_loss, miter) - self.writer.add_scalar('reg/setpoint', self.reg_lower_bound_as_setpoint, miter) + for i, val in enumerate(epo_reg_loss): + self.writer.add_scalar(f'reg/dyn{i}', val, miter) + for i, val in enumerate(self.reg_lower_bound_as_setpoint): + self.writer.add_scalar(f'reg/setpoint{i}', val, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True From cdf90c0eef4d3206b3c3a6b3c42b5c2a57e8fb8f Mon Sep 17 00:00:00 2001 From: Car-la-F Date: Thu, 21 Sep 2023 15:51:26 +0200 Subject: [PATCH 107/762] add taskloss to tensorboard plots --- domainlab/algos/trainers/fbopt_alternate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 07e0d15bb..64967c41d 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -76,7 +76,7 @@ def search_mu(self, dict_theta=None, miter=None): to see if the criteria is met $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-epsilon_R])$$ """ - epo_reg_loss, _ = self.trainer.eval_r_loss() + epo_reg_loss, epos_task_loss = self.trainer.eval_r_loss() # FIXME: use dictionary to replace scalar representation # delta_epsilon_r = epo_reg_loss - self.reg_lower_bound_as_setpoint delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.reg_lower_bound_as_setpoint) @@ -100,6 +100,7 @@ def search_mu(self, dict_theta=None, miter=None): self.writer.add_scalar(f'reg/dyn{i}', val, miter) for i, val in enumerate(self.reg_lower_bound_as_setpoint): self.writer.add_scalar(f'reg/setpoint{i}', val, miter) + self.writer.add_scalar(f'task', epos_task_loss, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True From 82cd554ee7609dba0112ee1ab4de99cd6e0149b6 Mon Sep 17 00:00:00 2001 From: drEast Date: Thu, 21 Sep 2023 18:09:47 +0200 Subject: [PATCH 108/762] Tensorboard plotting: reg/dyn_i vs reg/setpoint_i --- domainlab/algos/trainers/fbopt_alternate.py | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 594c20731..ae926b740 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -46,13 +46,25 @@ def __init__(self, trainer, **kwargs): self.writer = SummaryWriter() self.coeff_ma = 0.5 self.epsilon_r = False - self.layout = { - "ABCDE": { - "loss": ["Multiline", ["reg/dyn", "reg/setpoint"]], - # "accuracy": ["Multiline", ["accuracy/train", "accuracy/validation"]], + + # Build the tensorboard plotting output + self.set_plotting_layouts(len(self.mmu)) + + def set_plotting_layouts(self, n_tasks): + """ + Sets up layout for additional plots over multiple variables for tensorboard. + """ + layout = { + #"reg/dyn & task": { + # f"reg/dyn{i} & task": ["Multiline", [f"reg/dyn{i}", "task"]] + # for i in range(n_tasks) + #}, + "reg/dyn & reg/setpoint": { + f"reg/dyn{i} & reg/setpoint{i}": ["Multiline", [f"reg/dyn{i}", f"reg/setpoint{i}"]] + for i in range(n_tasks) }, } - self.writer.add_custom_scalars(self.layout) + self.writer.add_custom_scalars(layout) def update_anchor(self, dict_par): """ From 9c280c85834bf0ca9722a4cd201ad259fd7e317c Mon Sep 17 00:00:00 2001 From: drEast Date: Thu, 21 Sep 2023 18:37:23 +0200 Subject: [PATCH 109/762] Tensorboard logging improved dual line design --- domainlab/algos/trainers/fbopt_alternate.py | 33 +++++++-------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index ae926b740..41a5bb56c 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -47,25 +47,6 @@ def __init__(self, trainer, **kwargs): self.coeff_ma = 0.5 self.epsilon_r = False - # Build the tensorboard plotting output - self.set_plotting_layouts(len(self.mmu)) - - def set_plotting_layouts(self, n_tasks): - """ - Sets up layout for additional plots over multiple variables for tensorboard. - """ - layout = { - #"reg/dyn & task": { - # f"reg/dyn{i} & task": ["Multiline", [f"reg/dyn{i}", "task"]] - # for i in range(n_tasks) - #}, - "reg/dyn & reg/setpoint": { - f"reg/dyn{i} & reg/setpoint{i}": ["Multiline", [f"reg/dyn{i}", f"reg/setpoint{i}"]] - for i in range(n_tasks) - }, - } - self.writer.add_custom_scalars(layout) - def update_anchor(self, dict_par): """ update the last ensured value of theta^{(k)} @@ -115,10 +96,16 @@ def search_mu(self, dict_theta=None, miter=None): self.mmu = self.dict_clip(target) val = list(self.mmu.values())[0] self.writer.add_scalar('mmu', val, miter) - for i, val in enumerate(epo_reg_loss): - self.writer.add_scalar(f'reg/dyn{i}', val, miter) - for i, val in enumerate(self.reg_lower_bound_as_setpoint): - self.writer.add_scalar(f'reg/setpoint{i}', val, miter) + + for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.reg_lower_bound_as_setpoint)): + self.writer.add_scalar(f'reg/dyn{i}', reg_dyn, miter) + self.writer.add_scalar(f'reg/setpoint{i}', reg_set, miter) + + self.writer.add_scalars(f'reg/dyn{i} & reg/setpoint{i}', { + f'reg/dyn{i}': reg_dyn, + f'reg/setpoint{i}': reg_set, + }, miter) + self.writer.add_scalar(f'task', epos_task_loss, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True From 6175d9a2c12c2a7ab50737163cab7e20cd7cc5f0 Mon Sep 17 00:00:00 2001 From: drEast Date: Thu, 21 Sep 2023 18:59:08 +0200 Subject: [PATCH 110/762] Tensorflow Plotting: reg/dyn vs task plot --- domainlab/algos/trainers/fbopt_alternate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 41a5bb56c..4e36a3124 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -105,6 +105,7 @@ def search_mu(self, dict_theta=None, miter=None): f'reg/dyn{i}': reg_dyn, f'reg/setpoint{i}': reg_set, }, miter) + self.writer.add_scalar(f'task vs reg/dyn{i}', reg_dyn, epos_task_loss) self.writer.add_scalar(f'task', epos_task_loss, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) From 61dd6a35046db04e40ae47dde4dbf5277f9a0229 Mon Sep 17 00:00:00 2001 From: drEast Date: Thu, 21 Sep 2023 20:31:29 +0200 Subject: [PATCH 111/762] Hotfix: But #411 - List multiplication with scalar for update setpoint --- domainlab/algos/trainers/train_fbopt.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 4583c74a5..67f892f7e 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -184,7 +184,10 @@ def tr_epoch(self, epoch): epo_task_loss={epo_task_loss}") if epo_reg_loss < self.hyper_scheduler.reg_lower_bound_as_setpoint: logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") - self.hyper_scheduler.reg_lower_bound_as_setpoint = self.hyper_scheduler.coeff_ma * epo_reg_loss + (1-self.hyper_scheduler.coeff_ma)* self.hyper_scheduler.reg_lower_bound_as_setpoint + lower_bound = self.hyper_scheduler.coeff_ma * torch.tensor(epo_reg_loss) + lower_bound += (1-self.hyper_scheduler.coeff_ma) * torch.tensor(self.hyper_scheduler.reg_lower_bound_as_setpoint) + lower_bound = lower_bound.tolist() + self.hyper_scheduler.reg_lower_bound_as_setpoint = lower_bound #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) self.observer.update(epoch) # FIXME: model selection should be disabled From d83501e5788ffa68709cdb4cd4fe33acf64658fc Mon Sep 17 00:00:00 2001 From: drEast Date: Fri, 22 Sep 2023 09:54:45 +0200 Subject: [PATCH 112/762] Added activation clip --- domainlab/algos/trainers/fbopt_alternate.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 4e36a3124..d9dbf29f6 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -43,6 +43,7 @@ def __init__(self, trainer, **kwargs): self.reg_lower_bound_as_setpoint = None # NOTE: this value will be set according to initial evaluation of neural network self.mu_clip = 10000 + self.activation_clip = 10 # untested dummy value self.writer = SummaryWriter() self.coeff_ma = 0.5 self.epsilon_r = False @@ -91,6 +92,9 @@ def search_mu(self, dict_theta=None, miter=None): self.delta_epsilon_r = self.cal_delta_integration(self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) # FIXME: here we can not sum up selta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary activation = [self.k_p_control * val for val in self.delta_epsilon_r] + if self.activation_clip is not None: + activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) + for val in activation] list_gain = np.exp(activation) target = self.dict_multiply(self.mmu, list_gain) self.mmu = self.dict_clip(target) From d292207aa6c37783bf41319babe2c26c9f915ece Mon Sep 17 00:00:00 2001 From: drEast Date: Fri, 22 Sep 2023 10:41:40 +0200 Subject: [PATCH 113/762] Adapt Readme installable on cluster --- README.md | 5 ++++- requirements.txt | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b65177871..f322a83f5 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,10 @@ then Suppose you have cloned the repository and have changed directory to the cloned repository. ```shell -pip install -r requirements.txt +conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge +conda install torchmetric==0.10.3 +pip install -r requirements.txt +conda install tensorboard ``` then diff --git a/requirements.txt b/requirements.txt index 58baf5fec..05c90d628 100644 --- a/requirements.txt +++ b/requirements.txt @@ -69,9 +69,6 @@ threadpoolctl==3.2.0 ; python_version >= "3.9" and python_version < "4.0" throttler==1.2.2 ; python_version >= "3.9" and python_version < "4.0" tomli==2.0.1 ; python_version >= "3.9" and python_version < "3.11" toposort==1.10 ; python_version >= "3.9" and python_version < "4.0" -torch==1.12.1 ; python_version >= "3.9" and python_version < "4.0" -torchmetrics==0.10.3 ; python_version >= "3.9" and python_version < "4.0" -torchvision==0.13.1 ; python_version >= "3.9" and python_version < "4.0" tqdm==4.66.1 ; python_version >= "3.9" and python_version < "4.0" traitlets==5.9.0 ; python_version >= "3.9" and python_version < "4.0" typing-extensions==4.7.1 ; python_version >= "3.9" and python_version < "4.0" From 0f3c8b4952e3f24faf02e87dad5bfaf0f1a942ee Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 12:45:36 +0200 Subject: [PATCH 114/762] clean --- domainlab/algos/trainers/fbopt_alternate.py | 9 ++++-- domainlab/algos/trainers/train_fbopt.py | 31 ++------------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 505f6beda..c8cc1a285 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -142,5 +142,10 @@ def dict_multiply(self, dict_base, list_multiplier): def update_setpoint(self, epo_reg_loss): # FIXME: use pareto-reg-descent operator to decide if set point should be adjusted - if epo_reg_loss < self.hyper_scheduler.reg_lower_bound_as_setpoint: - self.reg_lower_bound_as_setpoint = self.hyper_scheduler.coeff_ma * epo_reg_loss + (1-self.hyper_scheduler.coeff_ma)* self.hyper_scheduler.reg_lower_bound_as_setpoint \ No newline at end of file + if epo_reg_loss < self.reg_lower_bound_as_setpoint: + logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") + lower_bound = self.coeff_ma * torch.tensor(epo_reg_loss) + lower_bound += (1-self.coeff_ma) * torch.tensor(self.reg_lower_bound_as_setpoint) + lower_bound = lower_bound.tolist() + self.reg_lower_bound_as_setpoint = lower_bound + logger.info("set point updated!") diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 67f892f7e..f152d4a9f 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -3,6 +3,8 @@ feedback optimization """ import copy +from operator import add + import torch from domainlab.algos.trainers.a_trainer import AbstractTrainer @@ -11,7 +13,6 @@ from domainlab.algos.trainers.fbopt_alternate import HyperSchedulerFeedbackAlternave from domainlab.algos.msels.c_msel_bang import MSelBang from domainlab.utils.logger import Logger -from operator import add class HyperSetter(): @@ -161,33 +162,7 @@ def tr_epoch(self, epoch): logger.info( f"at epoch {epoch}, after shooting: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") - if 1: - # if failed to find reg-pareto descent operator, continue training without - # mu being updated - #logger.info("failed to find pivot, move forward \\bar{\\theta}, \ - # this will deteriorate reg loss!") - #epo_reg_loss_before, epo_task_loss_before = self.eval_r_loss() - #logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - #logger.info( - # f"at epoch {epoch}, before \\bar \\theta: epo_reg_loss={epo_reg_loss_before}, \ - # epo_task_loss={epo_task_loss_before}") - - #theta = dict(self.model.named_parameters()) - # dict_par = self.opt_theta(self.hyper_scheduler.mmu, copy.deepcopy(theta)) - # move according to gradient to update theta_bar - #self.model.set_params(dict_par) - - epo_reg_loss, epo_task_loss = self.eval_r_loss() - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info( - f"at epoch {epoch}, after \\bar \\theta: epo_reg_loss={epo_reg_loss}, \ - epo_task_loss={epo_task_loss}") - if epo_reg_loss < self.hyper_scheduler.reg_lower_bound_as_setpoint: - logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") - lower_bound = self.hyper_scheduler.coeff_ma * torch.tensor(epo_reg_loss) - lower_bound += (1-self.hyper_scheduler.coeff_ma) * torch.tensor(self.hyper_scheduler.reg_lower_bound_as_setpoint) - lower_bound = lower_bound.tolist() - self.hyper_scheduler.reg_lower_bound_as_setpoint = lower_bound + self.hyper_scheduler.update_setpoint(epo_reg_loss) #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) self.observer.update(epoch) # FIXME: model selection should be disabled From 342b34390008e3c49d576056e7bae60abc3153cf Mon Sep 17 00:00:00 2001 From: drEast Date: Fri, 22 Sep 2023 12:53:16 +0200 Subject: [PATCH 115/762] Clearified x and y label in task vs reg plots --- domainlab/algos/trainers/fbopt_alternate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index d9dbf29f6..95354d0dd 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -109,8 +109,9 @@ def search_mu(self, dict_theta=None, miter=None): f'reg/dyn{i}': reg_dyn, f'reg/setpoint{i}': reg_set, }, miter) - self.writer.add_scalar(f'task vs reg/dyn{i}', reg_dyn, epos_task_loss) + self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{i}', reg_dyn, epos_task_loss) + #self.writer.add_scalar('loss_penalized', epos_task_loss+, miter) self.writer.add_scalar(f'task', epos_task_loss, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True From fac9616acba236e66f5535d0fe1d021e94722055 Mon Sep 17 00:00:00 2001 From: drEast Date: Fri, 22 Sep 2023 13:00:30 +0200 Subject: [PATCH 116/762] Plot all mmu instead of only primary --- domainlab/algos/trainers/fbopt_alternate.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 95354d0dd..7f6079efb 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -98,8 +98,9 @@ def search_mu(self, dict_theta=None, miter=None): list_gain = np.exp(activation) target = self.dict_multiply(self.mmu, list_gain) self.mmu = self.dict_clip(target) - val = list(self.mmu.values())[0] - self.writer.add_scalar('mmu', val, miter) + + for key, val in self.mmu.items(): + self.writer.add_scalar(f'mmu/{key}', val, miter) for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.reg_lower_bound_as_setpoint)): self.writer.add_scalar(f'reg/dyn{i}', reg_dyn, miter) From ef4e8215f13fc812d46f30d24eb19a8e5b75281e Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 14:29:45 +0200 Subject: [PATCH 117/762] hyper parameter --- domainlab/algos/trainers/args_fbopt.py | 21 ++++++++++++++++++--- domainlab/algos/trainers/fbopt_alternate.py | 21 +++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index a040d07c8..c80570f6e 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -7,11 +7,26 @@ def add_args2parser_fbopt(parser): """ append hyper-parameters to the main argparser """ - parser.add_argument('--init_mu4beta', type=float, default=0.001, - help='initial beta for multiplication') - parser.add_argument('--ini_setpoint_ratio', type=float, default=0.9, + + parser.add_argument('--k_i_gain', type=float, default=0.001, + help='PID control gain for integrator') + + parser.add_argument('--mu_clip', type=float, default=1e4, + help='maximum value of mu') + + parser.add_argument('--coeff_ma', type=float, default=0.5, + help='exponential moving average') + + parser.add_argument('--exp_shoulder_clip', type=float, default=10, + help='clip before exponential operation') + + parser.add_argument('--ini_setpoint_ratio', type=float, default=0.99, help='before training start, evaluate reg loss, \ setpoint will be 0.9 of this loss') + + # the following hyperparamters do not need to be tuned + parser.add_argument('--init_mu4beta', type=float, default=0.001, + help='initial beta for multiplication') parser.add_argument('--beta_mu', type=float, default=1.1, help='how much to multiply mu each time') parser.add_argument('--delta_mu', type=float, default=None, diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index c8cc1a285..a6ff8832d 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -3,9 +3,11 @@ """ import copy import torch + +from torch.utils.tensorboard import SummaryWriter + import numpy as np from domainlab.utils.logger import Logger -from torch.utils.tensorboard import SummaryWriter class HyperSchedulerFeedbackAlternave(): @@ -18,7 +20,7 @@ def __init__(self, trainer, **kwargs): """ self.trainer = trainer self.mmu = kwargs - self.mmu = {key: 1.0 for key, val in self.mmu.items()} + self.mmu = {key: 1.0 for key, val in self.mmu.items()} # FIXME: change this from user configuration self.ploss_old_theta_old_mu = None self.ploss_old_theta_new_mu = None self.ploss_new_theta_old_mu = None @@ -37,15 +39,14 @@ def __init__(self, trainer, **kwargs): self.count_found_operator = 0 self.count_search_mu = 0 ######################################## - # FIXME: make the following a vector, (or dictionary) - self.k_p_control = 0.001 + self.k_i_control = trainer.aconf.k_i_gain self.delta_epsilon_r = False # False here just used to decide if value first use or not self.reg_lower_bound_as_setpoint = None # NOTE: this value will be set according to initial evaluation of neural network - self.mu_clip = 10000 - self.activation_clip = 10 # untested dummy value + self.mu_clip = trainer.aconf.mu_clip + self.activation_clip = trainer.aconf.exp_shoulder_clip self.writer = SummaryWriter() - self.coeff_ma = 0.5 + self.coeff_ma = trainer.aconf.coeff_ma self.epsilon_r = False def update_anchor(self, dict_par): @@ -91,7 +92,7 @@ def search_mu(self, dict_theta=None, miter=None): # self.delta_epsilon_r = (1 - self.coeff_ma) * self.delta_epsilon_r + self.coeff_ma * delta_epsilon_r self.delta_epsilon_r = self.cal_delta_integration(self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) # FIXME: here we can not sum up selta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary - activation = [self.k_p_control * val for val in self.delta_epsilon_r] + activation = [self.k_i_control * val for val in self.delta_epsilon_r] if self.activation_clip is not None: activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) for val in activation] @@ -141,8 +142,12 @@ def dict_multiply(self, dict_base, list_multiplier): return {key: val*dict_multiplier[key] for key, val in dict_base.items()} def update_setpoint(self, epo_reg_loss): + """ + FIXME: setpoint should also be able to be eliviated + """ # FIXME: use pareto-reg-descent operator to decide if set point should be adjusted if epo_reg_loss < self.reg_lower_bound_as_setpoint: + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") lower_bound = self.coeff_ma * torch.tensor(epo_reg_loss) lower_bound += (1-self.coeff_ma) * torch.tensor(self.reg_lower_bound_as_setpoint) From d7dd05f1d7100a550cc7688a4321a2066f88e276 Mon Sep 17 00:00:00 2001 From: drEast Date: Fri, 22 Sep 2023 14:40:09 +0200 Subject: [PATCH 118/762] Added penalized loss --- domainlab/algos/trainers/fbopt_alternate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 7f6079efb..eb3d2e417 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -112,7 +112,9 @@ def search_mu(self, dict_theta=None, miter=None): }, miter) self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{i}', reg_dyn, epos_task_loss) - #self.writer.add_scalar('loss_penalized', epos_task_loss+, miter) + loss_penalized = epos_task_loss + loss_penalized += torch.inner(torch.Tensor(list(self.mmu.values())), torch.Tensor(epo_reg_loss)) + self.writer.add_scalar('loss_penalized', loss_penalized, miter) self.writer.add_scalar(f'task', epos_task_loss, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True From 03d898572db5dec329d1a0c6f8492fadb8240184 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 14:40:29 +0200 Subject: [PATCH 119/762] rename setpint --- domainlab/algos/trainers/fbopt_alternate.py | 14 +++++++------- domainlab/algos/trainers/train_fbopt.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index a6ff8832d..2d111eb7e 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -41,7 +41,7 @@ def __init__(self, trainer, **kwargs): ######################################## self.k_i_control = trainer.aconf.k_i_gain self.delta_epsilon_r = False # False here just used to decide if value first use or not - self.reg_lower_bound_as_setpoint = None + self.setpoint4R = None # NOTE: this value will be set according to initial evaluation of neural network self.mu_clip = trainer.aconf.mu_clip self.activation_clip = trainer.aconf.exp_shoulder_clip @@ -80,8 +80,8 @@ def search_mu(self, dict_theta=None, miter=None): """ epo_reg_loss, epos_task_loss = self.trainer.eval_r_loss() # FIXME: use dictionary to replace scalar representation - # delta_epsilon_r = epo_reg_loss - self.reg_lower_bound_as_setpoint - delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.reg_lower_bound_as_setpoint) + # delta_epsilon_r = epo_reg_loss - self.setpoint4R + delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.setpoint4R) # TODO: can be replaced by a controller if self.delta_epsilon_r is False: self.delta_epsilon_r = delta_epsilon_r @@ -102,7 +102,7 @@ def search_mu(self, dict_theta=None, miter=None): val = list(self.mmu.values())[0] self.writer.add_scalar('mmu', val, miter) - for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.reg_lower_bound_as_setpoint)): + for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.setpoint4R)): self.writer.add_scalar(f'reg/dyn{i}', reg_dyn, miter) self.writer.add_scalar(f'reg/setpoint{i}', reg_set, miter) @@ -146,11 +146,11 @@ def update_setpoint(self, epo_reg_loss): FIXME: setpoint should also be able to be eliviated """ # FIXME: use pareto-reg-descent operator to decide if set point should be adjusted - if epo_reg_loss < self.reg_lower_bound_as_setpoint: + if epo_reg_loss < self.setpoint4R: logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") lower_bound = self.coeff_ma * torch.tensor(epo_reg_loss) - lower_bound += (1-self.coeff_ma) * torch.tensor(self.reg_lower_bound_as_setpoint) + lower_bound += (1-self.coeff_ma) * torch.tensor(self.setpoint4R) lower_bound = lower_bound.tolist() - self.reg_lower_bound_as_setpoint = lower_bound + self.setpoint4R = lower_bound logger.info("set point updated!") diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index f152d4a9f..1184f3de4 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -54,7 +54,7 @@ def before_tr(self): flag_accept=False) epo_reg_loss, _ = self.eval_r_loss() - self.hyper_scheduler.reg_lower_bound_as_setpoint = \ + self.hyper_scheduler.setpoint4R = \ [ele * self.aconf.ini_setpoint_ratio for ele in epo_reg_loss] def opt_theta(self, dict4mu, dict_theta0): From 981fe3ed5fe238925d4568c7f2aae807cd8eeacc Mon Sep 17 00:00:00 2001 From: drEast Date: Fri, 22 Sep 2023 15:18:25 +0200 Subject: [PATCH 120/762] Added penalized loss --- domainlab/algos/trainers/fbopt_alternate.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index eb3d2e417..4af4b76eb 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -112,8 +112,7 @@ def search_mu(self, dict_theta=None, miter=None): }, miter) self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{i}', reg_dyn, epos_task_loss) - loss_penalized = epos_task_loss - loss_penalized += torch.inner(torch.Tensor(list(self.mmu.values())), torch.Tensor(epo_reg_loss)) + loss_penalized = epos_task_loss + torch.inner(torch.Tensor(list(self.mmu.values())), torch.Tensor(epo_reg_loss)) self.writer.add_scalar('loss_penalized', loss_penalized, miter) self.writer.add_scalar(f'task', epos_task_loss, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) From ae4fd7e2f62e8a4eacecef6941c72036359e58e1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 15:26:04 +0200 Subject: [PATCH 121/762] first eeidiotn --- domainlab/algos/trainers/fbopt_alternate.py | 4 +- examples/benchmark/test_benchmark_fbopt.yaml | 76 ++++++++++---------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 2d111eb7e..10257e7d1 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -116,11 +116,11 @@ def search_mu(self, dict_theta=None, miter=None): self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True - def dict_clip(self, dict_base): + def dict_clip(self, dict_base, clip_min=0.0001): """ clip each entry of the mu according to pre-set self.mu_clip """ - return {key: np.clip(val, a_min=0.0, a_max=self.mu_clip) for key, val in dict_base.items()} + return {key: np.clip(val, a_min=clip_min, a_max=self.mu_clip) for key, val in dict_base.items()} def dict_is_zero(self, dict_mu): """ diff --git a/examples/benchmark/test_benchmark_fbopt.yaml b/examples/benchmark/test_benchmark_fbopt.yaml index 028075e35..8059fb5df 100644 --- a/examples/benchmark/test_benchmark_fbopt.yaml +++ b/examples/benchmark/test_benchmark_fbopt.yaml @@ -22,48 +22,50 @@ domainlab_args: bs: 64 nname: conv_bn_pool_2 san_check: True + exp_shoulder_clip: 10 -# Test fbopt with different hyperparameter configurations +Shared params: + ini_setpoint_ratio: + min: 0.5 + max: 0.99 + num: 2 + step: 0.001 + distribution: uniform -TestFbopt: - aname: dann - trainer: fbopt + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + step: 0.0001 + distribution: uniform - hyperparameters: - init_mu4beta: - min: 0.0001 - max: 0.01 - num: 2 - step: 0.0001 - distribution: uniform + exp_shoulder_clip: + min: 5 + max: 10 + num: 2 + step: 1 + distribution: uniform - beta_mu: - min: 1.2 - max: 2 - num: 4 - step: 0.1 - distribution: uniform + mu_clip: + min: 0.001 + max: 1e4 + num: 2 + step: 10 + distribution: loguniform - delta_mu: - min: 0.001 - max: 0.1 - num: 5 - step: 0.001 - distribution: loguniform + coeff_ma: + min: 0.001 + max: 0.99 + num: 2 + step: 0.001 + distribution: uniform - budget_mu_per_step: - min: 4 - max: 10 - num: 2 - step: 1 - datatype: int - distribution: uniform +# Test fbopt with different hyperparameter configurations + +jigen_fbopt: + aname: jigen + trainer: fbopt - budget_theta_update_per_mu: - min: 4 - max: 10 - num: 2 - step: 1 - datatype: int - distribution: uniform + shared: + - ini_setpoint_raio From 6e7daedc5419d8817aab2b7bb5eac98513abba26 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 15:32:43 +0200 Subject: [PATCH 122/762] working yaml file --- examples/benchmark/benchmark_fbopt.yaml | 52 ++++++++++++++++++++ examples/benchmark/test_benchmark_fbopt.yaml | 1 - 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 examples/benchmark/benchmark_fbopt.yaml diff --git a/examples/benchmark/benchmark_fbopt.yaml b/examples/benchmark/benchmark_fbopt.yaml new file mode 100644 index 000000000..9bcf5f3ff --- /dev/null +++ b/examples/benchmark/benchmark_fbopt.yaml @@ -0,0 +1,52 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt + +num_param_samples: 8 +sampling_seed: 0 +startseed: 0 +endseed: 2 + +test_domains: + - 3 + - 0 + + +domainlab_args: + task: mnistcolor10 + tr_d: [1, 2] + dmem: False + lr: 0.001 + epos: 3 + es: 5 + bs: 64 + nname: conv_bn_pool_2 + san_check: True + exp_shoulder_clip: 10 + mu_clip: 1e4 + coeff_ma: 0.5 + + +Shared params: + ini_setpoint_ratio: + min: 0.5 + max: 0.99 + num: 5 + step: 0.05 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + step: 0.0001 + distribution: uniform + +# Test fbopt with different hyperparameter configurations + +jigen_fbopt: + aname: jigen + trainer: fbopt + + shared: + - ini_setpoint_raio diff --git a/examples/benchmark/test_benchmark_fbopt.yaml b/examples/benchmark/test_benchmark_fbopt.yaml index 8059fb5df..e009024a1 100644 --- a/examples/benchmark/test_benchmark_fbopt.yaml +++ b/examples/benchmark/test_benchmark_fbopt.yaml @@ -22,7 +22,6 @@ domainlab_args: bs: 64 nname: conv_bn_pool_2 san_check: True - exp_shoulder_clip: 10 Shared params: From def1e6789da1153ba5660980b83e3d5e8b045a56 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 15:42:48 +0200 Subject: [PATCH 123/762] working --- examples/benchmark/benchmark_fbopt.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt.yaml b/examples/benchmark/benchmark_fbopt.yaml index 9bcf5f3ff..23f586d20 100644 --- a/examples/benchmark/benchmark_fbopt.yaml +++ b/examples/benchmark/benchmark_fbopt.yaml @@ -23,7 +23,7 @@ domainlab_args: nname: conv_bn_pool_2 san_check: True exp_shoulder_clip: 10 - mu_clip: 1e4 + mu_clip: 10_000 coeff_ma: 0.5 From 32b6a510497430c46b527c1a6c60f95635453531 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 15:47:15 +0200 Subject: [PATCH 124/762] . --- examples/benchmark/benchmark_fbopt_pacs.yaml | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 examples/benchmark/benchmark_fbopt_pacs.yaml diff --git a/examples/benchmark/benchmark_fbopt_pacs.yaml b/examples/benchmark/benchmark_fbopt_pacs.yaml new file mode 100644 index 000000000..9be3cecdd --- /dev/null +++ b/examples/benchmark/benchmark_fbopt_pacs.yaml @@ -0,0 +1,53 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs + +num_param_samples: 8 +sampling_seed: 0 +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 3 + es: 5 + bs: 64 + nname: conv_bn_pool_2 + san_check: True + npath: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + + + +Shared params: + ini_setpoint_ratio: + min: 0.5 + max: 0.99 + num: 5 + step: 0.05 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + step: 0.0001 + distribution: uniform + +# Test fbopt with different hyperparameter configurations + +jigen_fbopt: + aname: jigen + trainer: fbopt + + shared: + - ini_setpoint_raio From f5047a5b4e1a520cb21ed1d409f9561df8cf130e Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 15:49:17 +0200 Subject: [PATCH 125/762] . --- examples/benchmark/benchmark_fbopt_pacs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs.yaml b/examples/benchmark/benchmark_fbopt_pacs.yaml index 9be3cecdd..a18adfe8d 100644 --- a/examples/benchmark/benchmark_fbopt_pacs.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs.yaml @@ -14,7 +14,7 @@ domainlab_args: tpath: examples/tasks/task_pacs_path_list.py dmem: False lr: 5e-5 - epos: 3 + epos: 1 es: 5 bs: 64 nname: conv_bn_pool_2 @@ -32,7 +32,7 @@ Shared params: ini_setpoint_ratio: min: 0.5 max: 0.99 - num: 5 + num: 2 step: 0.05 distribution: uniform From 6282b98d1d4384ecd023d6f939e0933631b7287f Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 16:06:28 +0200 Subject: [PATCH 126/762] pacs yaml works --- examples/benchmark/benchmark_fbopt_pacs.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs.yaml b/examples/benchmark/benchmark_fbopt_pacs.yaml index a18adfe8d..1f86286ad 100644 --- a/examples/benchmark/benchmark_fbopt_pacs.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs.yaml @@ -50,4 +50,5 @@ jigen_fbopt: trainer: fbopt shared: - - ini_setpoint_raio + - ini_setpoint_ratio + - k_i_gain From b7101916222cff04d8356444d7c1f7a0cd5045c4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 16:07:15 +0200 Subject: [PATCH 127/762] mnist benchmark works for fbopt --- examples/benchmark/benchmark_fbopt.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt.yaml b/examples/benchmark/benchmark_fbopt.yaml index 23f586d20..a8e952b0a 100644 --- a/examples/benchmark/benchmark_fbopt.yaml +++ b/examples/benchmark/benchmark_fbopt.yaml @@ -49,4 +49,5 @@ jigen_fbopt: trainer: fbopt shared: - - ini_setpoint_raio + - ini_setpoint_ratio + - k_i_gain From c8bd35385128397a300dedbffea1ece2987273f8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 16:13:59 +0200 Subject: [PATCH 128/762] . --- domainlab/algos/trainers/args_fbopt.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index c80570f6e..8b1626a4d 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -24,6 +24,10 @@ def add_args2parser_fbopt(parser): help='before training start, evaluate reg loss, \ setpoint will be 0.9 of this loss') + parser.add_argument('--no_tensorboard', action='store_true', default=False, + help='disable tensorboard') + + # the following hyperparamters do not need to be tuned parser.add_argument('--init_mu4beta', type=float, default=0.001, help='initial beta for multiplication') From ee4e3565ef50309c7be1579dbc4cb0d52588678f Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 16:24:25 +0200 Subject: [PATCH 129/762] fix bug in yaml file --- examples/benchmark/benchmark_fbopt.yaml | 1 - examples/benchmark/benchmark_fbopt_pacs.yaml | 2 - .../benchmark/benchmark_fbopt_pacs_full.yaml | 53 +++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 examples/benchmark/benchmark_fbopt_pacs_full.yaml diff --git a/examples/benchmark/benchmark_fbopt.yaml b/examples/benchmark/benchmark_fbopt.yaml index a8e952b0a..489ae5b0f 100644 --- a/examples/benchmark/benchmark_fbopt.yaml +++ b/examples/benchmark/benchmark_fbopt.yaml @@ -2,7 +2,6 @@ mode: grid output_dir: zoutput/benchmarks/benchmark_fbopt -num_param_samples: 8 sampling_seed: 0 startseed: 0 endseed: 2 diff --git a/examples/benchmark/benchmark_fbopt_pacs.yaml b/examples/benchmark/benchmark_fbopt_pacs.yaml index 1f86286ad..fa1de6d21 100644 --- a/examples/benchmark/benchmark_fbopt_pacs.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs.yaml @@ -2,7 +2,6 @@ mode: grid output_dir: zoutput/benchmarks/benchmark_fbopt_pacs -num_param_samples: 8 sampling_seed: 0 startseed: 0 endseed: 2 @@ -17,7 +16,6 @@ domainlab_args: epos: 1 es: 5 bs: 64 - nname: conv_bn_pool_2 san_check: True npath: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml new file mode 100644 index 000000000..d0c333823 --- /dev/null +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -0,0 +1,53 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 1 + es: 5 + bs: 64 + san_check: True + npath: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + + + +Shared params: + ini_setpoint_ratio: + min: 0.5 + max: 0.99 + num: 20 + step: 0.05 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.1 + num: 20 + step: 0.0001 + distribution: uniform + +# Test fbopt with different hyperparameter configurations + +jigen_fbopt: + aname: jigen + trainer: fbopt + + shared: + - ini_setpoint_ratio + - k_i_gain From 9db9445ca027f079dff1cd5cc1f741c180cf13dd Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Sep 2023 16:28:59 +0200 Subject: [PATCH 130/762] . --- examples/benchmark/benchmark_fbopt_pacs_full.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index d0c333823..9d82bcfa5 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -14,16 +14,21 @@ domainlab_args: tpath: examples/tasks/task_pacs_path_list.py dmem: False lr: 5e-5 - epos: 1 + epos: 100 es: 5 bs: 64 san_check: True npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py exp_shoulder_clip: 10 mu_clip: 10_000 coeff_ma: 0.5 + zx_dim: 0 + zy_dim: 32 + zd_dim: 32 + @@ -51,3 +56,11 @@ jigen_fbopt: shared: - ini_setpoint_ratio - k_i_gain + + +diva_fbopt: + aname: diva + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain From ee0e12bedd3bdd073ea2af2d036da4828504d9f7 Mon Sep 17 00:00:00 2001 From: edo Date: Fri, 22 Sep 2023 16:43:27 +0200 Subject: [PATCH 131/762] argument to disable tensorboard --- domainlab/algos/trainers/fbopt_alternate.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 10257e7d1..242709b6b 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -10,6 +10,16 @@ from domainlab.utils.logger import Logger +class StubSummaryWriter(): + # stub writer for tensorboard that ignores all messages + + def add_scalar(self, *args, **kwargs): + pass + + def add_scalars(self, *args, **kwargs): + pass + + class HyperSchedulerFeedbackAlternave(): """ design $\\mu$$ sequence based on state of penalized loss @@ -45,7 +55,7 @@ def __init__(self, trainer, **kwargs): # NOTE: this value will be set according to initial evaluation of neural network self.mu_clip = trainer.aconf.mu_clip self.activation_clip = trainer.aconf.exp_shoulder_clip - self.writer = SummaryWriter() + self.writer = StubSummaryWriter() if trainer.aconf.no_tensorboard else SummaryWriter() self.coeff_ma = trainer.aconf.coeff_ma self.epsilon_r = False From ac9474cd798ffa8448e918da05270bea5326ab5e Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Fri, 22 Sep 2023 16:53:24 +0200 Subject: [PATCH 132/762] disabled tensorboard in fbopt benchmark --- examples/benchmark/benchmark_fbopt.yaml | 2 ++ examples/benchmark/benchmark_fbopt_pacs.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/examples/benchmark/benchmark_fbopt.yaml b/examples/benchmark/benchmark_fbopt.yaml index a8e952b0a..cf775a391 100644 --- a/examples/benchmark/benchmark_fbopt.yaml +++ b/examples/benchmark/benchmark_fbopt.yaml @@ -25,6 +25,8 @@ domainlab_args: exp_shoulder_clip: 10 mu_clip: 10_000 coeff_ma: 0.5 + no_tensorboard: False + Shared params: diff --git a/examples/benchmark/benchmark_fbopt_pacs.yaml b/examples/benchmark/benchmark_fbopt_pacs.yaml index 1f86286ad..3ece58a25 100644 --- a/examples/benchmark/benchmark_fbopt_pacs.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs.yaml @@ -25,6 +25,7 @@ domainlab_args: exp_shoulder_clip: 10 mu_clip: 10_000 coeff_ma: 0.5 + no_tensorboard: False From ac287cacccde741c0fd9919f05e31207936f677f Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 17:18:45 +0200 Subject: [PATCH 133/762] change model selection back to validation accuracy --- domainlab/algos/trainers/train_fbopt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 1184f3de4..c269f0e58 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -43,7 +43,10 @@ def before_tr(self): """ before training begins, construct helper objects """ - self.observer.msel = MSelBang(max_es=None) + if self.aconf.msel == "last": + self.observer.msel = MSelBang(max_es=None) + # although validation distribution will be very difference from test distribution, it is still a better + # idea to not to use the last iteration of the model # self.set_scheduler(scheduler=HyperSchedulerFeedback) self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) self.model.evaluate(self.loader_te, self.device) @@ -165,6 +168,6 @@ def tr_epoch(self, epoch): self.hyper_scheduler.update_setpoint(epo_reg_loss) #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) - self.observer.update(epoch) # FIXME: model selection should be disabled + flag_early_stop = self.observer.update(epoch) self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) - return False # total number of epochs controled in args + return flag_early_stop From 8567d746e74aecb62176db113ece746f4626c5b5 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 17:24:24 +0200 Subject: [PATCH 134/762] Update arg_parser.py to have msel include "last" --- domainlab/arg_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/arg_parser.py b/domainlab/arg_parser.py index 1403243df..dfdfaa922 100644 --- a/domainlab/arg_parser.py +++ b/domainlab/arg_parser.py @@ -138,7 +138,7 @@ def mk_parser_main(): "False: parameter name is used." "Default is True.") - parser.add_argument('--msel', choices=['val', 'loss_tr'], default="val", + parser.add_argument('--msel', choices=['val', 'loss_tr', 'last'], default="val", help='model selection for early stop: val, loss_tr, recon, the \ elbo and recon only make sense for vae models,\ will be ignored by other methods') From fcba664f7437e7ca453e0d4c2e6dadb4c147386f Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Fri, 22 Sep 2023 17:34:08 +0200 Subject: [PATCH 135/762] using slurm job id to differentiate log folders --- domainlab/algos/trainers/fbopt_alternate.py | 6 +++++- domainlab/compos/exp/exp_utils.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 242709b6b..e459af33c 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -2,6 +2,7 @@ update hyper-parameters during training """ import copy +import os import torch from torch.utils.tensorboard import SummaryWriter @@ -55,7 +56,10 @@ def __init__(self, trainer, **kwargs): # NOTE: this value will be set according to initial evaluation of neural network self.mu_clip = trainer.aconf.mu_clip self.activation_clip = trainer.aconf.exp_shoulder_clip - self.writer = StubSummaryWriter() if trainer.aconf.no_tensorboard else SummaryWriter() + if trainer.aconf.no_tensorboard: + self.writer = StubSummaryWriter() + else: + self.writer = SummaryWriter(comment=os.environ.get('SLURM_JOB_ID', '')) self.coeff_ma = trainer.aconf.coeff_ma self.epsilon_r = False diff --git a/domainlab/compos/exp/exp_utils.py b/domainlab/compos/exp/exp_utils.py index 3e39a11a0..d423958f2 100644 --- a/domainlab/compos/exp/exp_utils.py +++ b/domainlab/compos/exp/exp_utils.py @@ -63,6 +63,9 @@ def mk_model_na(self, tag=None, dd_cut=19): model_name = "_".join(list4mname) if self.host.args.debug: model_name = "debug_" + model_name + slurm = os.environ.get('SLURM_JOB_ID') + if slurm: + model_name = model_name + '_' + slurm logger = Logger.get_logger() logger.info(f"model name: {model_name}") return model_name From d3bfa02db6846107f2bf7fa4a1660f48e94dbe00 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 17:55:13 +0200 Subject: [PATCH 136/762] Update c_msel_bang.py --- domainlab/algos/msels/c_msel_bang.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_bang.py b/domainlab/algos/msels/c_msel_bang.py index ec422befa..8eda99469 100644 --- a/domainlab/algos/msels/c_msel_bang.py +++ b/domainlab/algos/msels/c_msel_bang.py @@ -12,9 +12,11 @@ class MSelBang(AMSel): def __init__(self, max_es): self.best_val_acc = 0.0 + def if_stop(self): + return False + def update(self): """ if the best model should be updated """ - flag = True - return flag + return True From 73c707aab9a6b2e97f7adc4958be4c6342b3a0bf Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:08:57 +0200 Subject: [PATCH 137/762] Update train_fbopt.py --- domainlab/algos/trainers/train_fbopt.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index c269f0e58..6e5bdccca 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -132,6 +132,17 @@ def tr_epoch(self, epoch): otherwise, """ epo_reg_loss, epo_task_loss = self.eval_r_loss() + if self.aconf.msel=="reg": + self.epo_loss_tr = epo_reg_loss + elif: self.aconf.msel=="erm": + self.epo_loss_tr = epo_task_loss + elif self.aconf.msel== "tr_loss": + epo_p_loss = self.eval_p_loss() + self.epo_loss_tr = epo_p_loss + elif self.aconf.msel == "last" or self.aconf.msel == "val": + self.epo_loss_tr = 1.0 # FIXME: check if this is not used at all + else: + raise RuntimeError("msel type not supported") logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"at epoch {epoch}, epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") From 984cd0eb89b69674b51ddfc91e17f8f7f0848f53 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:12:13 +0200 Subject: [PATCH 138/762] Update arg_parser.py --- domainlab/arg_parser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/arg_parser.py b/domainlab/arg_parser.py index dfdfaa922..43512f7cf 100644 --- a/domainlab/arg_parser.py +++ b/domainlab/arg_parser.py @@ -142,6 +142,9 @@ def mk_parser_main(): help='model selection for early stop: val, loss_tr, recon, the \ elbo and recon only make sense for vae models,\ will be ignored by other methods') + + parser.add_argument('--msel_tr_loss', choices=['reg', 'task', 'ploss'], default="task", + help='model selection for tr loss') parser.add_argument('--aname', metavar="an", type=str, default=None, From 55678abd3e1593dd9ec7e07cb98de722a8c4fccf Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:14:58 +0200 Subject: [PATCH 139/762] Update train_fbopt.py --- domainlab/algos/trainers/train_fbopt.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 6e5bdccca..6d9cb8cc7 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -132,13 +132,14 @@ def tr_epoch(self, epoch): otherwise, """ epo_reg_loss, epo_task_loss = self.eval_r_loss() - if self.aconf.msel=="reg": + if self.aconf.msel == "tr_loss": + if self.aconf.msel_tr_loss =="reg": self.epo_loss_tr = epo_reg_loss - elif: self.aconf.msel=="erm": - self.epo_loss_tr = epo_task_loss - elif self.aconf.msel== "tr_loss": - epo_p_loss = self.eval_p_loss() - self.epo_loss_tr = epo_p_loss + if: self.aconf.msel_tr_loss =="erm": + self.epo_loss_tr = epo_task_loss + elif self.aconf.msel_tr_loss == "p_loss": + epo_p_loss = self.eval_p_loss() + self.epo_loss_tr = epo_p_loss elif self.aconf.msel == "last" or self.aconf.msel == "val": self.epo_loss_tr = 1.0 # FIXME: check if this is not used at all else: From 0ed622c6c7ef30b9594ad54d3b427886ce4bea11 Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Fri, 22 Sep 2023 18:19:11 +0200 Subject: [PATCH 140/762] indentation --- domainlab/algos/trainers/train_fbopt.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 6d9cb8cc7..69b93d722 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -133,13 +133,13 @@ def tr_epoch(self, epoch): """ epo_reg_loss, epo_task_loss = self.eval_r_loss() if self.aconf.msel == "tr_loss": - if self.aconf.msel_tr_loss =="reg": - self.epo_loss_tr = epo_reg_loss - if: self.aconf.msel_tr_loss =="erm": - self.epo_loss_tr = epo_task_loss + if self.aconf.msel_tr_loss =="reg": + self.epo_loss_tr = epo_reg_loss + elif self.aconf.msel_tr_loss =="erm": + self.epo_loss_tr = epo_task_loss elif self.aconf.msel_tr_loss == "p_loss": epo_p_loss = self.eval_p_loss() - self.epo_loss_tr = epo_p_loss + self.epo_loss_tr = epo_p_loss elif self.aconf.msel == "last" or self.aconf.msel == "val": self.epo_loss_tr = 1.0 # FIXME: check if this is not used at all else: From e8cb8c0d2005002fee5861c6fbf645d132a34dd6 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:32:47 +0200 Subject: [PATCH 141/762] Update train_fbopt.py --- domainlab/algos/trainers/train_fbopt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 69b93d722..d32006eef 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -180,6 +180,7 @@ def tr_epoch(self, epoch): self.hyper_scheduler.update_setpoint(epo_reg_loss) #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) - flag_early_stop = self.observer.update(epoch) + flag_early_stop_observer = self.observer.update(epoch) + flag_early_stop = self.observer.msel.if_stop() self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return flag_early_stop From fcd9addc7fe6faaa46ae200b3c1a642e5f1b53d1 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:35:20 +0200 Subject: [PATCH 142/762] Update train_fbopt.py --- domainlab/algos/trainers/train_fbopt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index d32006eef..8a650c164 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -44,7 +44,7 @@ def before_tr(self): before training begins, construct helper objects """ if self.aconf.msel == "last": - self.observer.msel = MSelBang(max_es=None) + self.observer.model_sel = MSelBang(max_es=None) # although validation distribution will be very difference from test distribution, it is still a better # idea to not to use the last iteration of the model # self.set_scheduler(scheduler=HyperSchedulerFeedback) @@ -183,4 +183,4 @@ def tr_epoch(self, epoch): flag_early_stop_observer = self.observer.update(epoch) flag_early_stop = self.observer.msel.if_stop() self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) - return flag_early_stop + return flag_early_stop_observer From bd12c17b2230a62d53c56f0243d20d9f9f420870 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:36:53 +0200 Subject: [PATCH 143/762] Update train_fbopt.py --- domainlab/algos/trainers/train_fbopt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 8a650c164..79081df15 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -181,6 +181,5 @@ def tr_epoch(self, epoch): #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) flag_early_stop_observer = self.observer.update(epoch) - flag_early_stop = self.observer.msel.if_stop() self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) return flag_early_stop_observer From b9ac0bf15150993c2135753265c7194cd8f57550 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:43:45 +0200 Subject: [PATCH 144/762] Update train_fbopt.py --- domainlab/algos/trainers/train_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 79081df15..7f595f32f 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -132,7 +132,7 @@ def tr_epoch(self, epoch): otherwise, """ epo_reg_loss, epo_task_loss = self.eval_r_loss() - if self.aconf.msel == "tr_loss": + if self.aconf.msel == "loss_tr": if self.aconf.msel_tr_loss =="reg": self.epo_loss_tr = epo_reg_loss elif self.aconf.msel_tr_loss =="erm": From 8af4ab470839026131dc2088226796c6f532b84b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:44:58 +0200 Subject: [PATCH 145/762] Update train_fbopt.py --- domainlab/algos/trainers/train_fbopt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 7f595f32f..7e1b57f23 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -181,5 +181,7 @@ def tr_epoch(self, epoch): #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) flag_early_stop_observer = self.observer.update(epoch) + flag_msel_early_stop = self.observer.model_sel.if_stop() self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) - return flag_early_stop_observer + # FIXME: after a long seesion with Emilio, we could not resovle this, this is a hack at themoment + return flag_msel_early_stop From 104268a96616d0176c14778b54f84df22e1c48d1 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:51:21 +0200 Subject: [PATCH 146/762] Update c_obvisitor_cleanup.py --- domainlab/algos/observers/c_obvisitor_cleanup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/observers/c_obvisitor_cleanup.py b/domainlab/algos/observers/c_obvisitor_cleanup.py index 38af65467..097da59f9 100644 --- a/domainlab/algos/observers/c_obvisitor_cleanup.py +++ b/domainlab/algos/observers/c_obvisitor_cleanup.py @@ -10,7 +10,7 @@ def __init__(self, observer): def after_all(self): self.observer.after_all() - self.observer.clean_up() + self.observer.clean_up() # FIXME should be self.clean_up??? def accept(self, trainer): self.observer.accept(trainer) @@ -20,3 +20,7 @@ def update(self, epoch): def clean_up(self): self.observer.clean_up() + + @property + def model_sel(self): + return self.observer.model_sel From a5c92ec49c1b1d1ec2b1b169fbd048266b667554 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 18:59:04 +0200 Subject: [PATCH 147/762] Update c_obvisitor_cleanup.py --- domainlab/algos/observers/c_obvisitor_cleanup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/algos/observers/c_obvisitor_cleanup.py b/domainlab/algos/observers/c_obvisitor_cleanup.py index 097da59f9..07d1d1871 100644 --- a/domainlab/algos/observers/c_obvisitor_cleanup.py +++ b/domainlab/algos/observers/c_obvisitor_cleanup.py @@ -24,3 +24,7 @@ def clean_up(self): @property def model_sel(self): return self.observer.model_sel + + @model_sel.setter + def model_sel(self, model_sel): + self.observer.model_sel = model_sel From e1f8b819374a3eee1593a0e74e39f44ffaf9372b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 19:08:20 +0200 Subject: [PATCH 148/762] Update benchmark_fbopt_pacs_full.yaml --- .../benchmark/benchmark_fbopt_pacs_full.yaml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index 9d82bcfa5..81ffa597a 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -26,8 +26,8 @@ domainlab_args: mu_clip: 10_000 coeff_ma: 0.5 zx_dim: 0 - zy_dim: 32 - zd_dim: 32 + zy_dim: 64 + zd_dim: 64 @@ -64,3 +64,17 @@ diva_fbopt: shared: - ini_setpoint_ratio - k_i_gain + +hduva_fbopt: + aname: hduva + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain + +dann_fbopt: + aname: dann + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain From 1f8c51dc579c8fb0f5faf02068969d3be901ba6b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 19:16:27 +0200 Subject: [PATCH 149/762] Update benchmark_fbopt_pacs_full.yaml --- .../benchmark/benchmark_fbopt_pacs_full.yaml | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index 81ffa597a..cf7d2cde9 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -14,8 +14,7 @@ domainlab_args: tpath: examples/tasks/task_pacs_path_list.py dmem: False lr: 5e-5 - epos: 100 - es: 5 + epos: 200 bs: 64 san_check: True npath: examples/nets/resnet50domainbed.py @@ -46,6 +45,27 @@ Shared params: num: 20 step: 0.0001 distribution: uniform + + msel: + distribution: categorical + values: + - last + - val + - loss_tr + + msel_tr_loss: + distribution: categorical + values: + - reg + - task + - ploss + + es: + distribution: categorical + values: + - 1 + - 5 + # Test fbopt with different hyperparameter configurations @@ -56,6 +76,9 @@ jigen_fbopt: shared: - ini_setpoint_ratio - k_i_gain + - msel_tr_loss + - msel + - es diva_fbopt: @@ -64,6 +87,9 @@ diva_fbopt: shared: - ini_setpoint_ratio - k_i_gain + - msel_tr_loss + - msel + - es hduva_fbopt: aname: hduva @@ -71,10 +97,16 @@ hduva_fbopt: shared: - ini_setpoint_ratio - k_i_gain - + - msel_tr_loss + - msel + - es + dann_fbopt: aname: dann trainer: fbopt shared: - ini_setpoint_ratio - k_i_gain + - msel_tr_loss + - msel + - es From 402291fdf40e038233e90e44ba00262c64ef4e81 Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Fri, 22 Sep 2023 19:24:54 +0200 Subject: [PATCH 150/762] new hyperparamter ranges --- .../benchmark/benchmark_fbopt_pacs_full.yaml | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index cf7d2cde9..8a3457bfe 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -35,34 +35,37 @@ Shared params: ini_setpoint_ratio: min: 0.5 max: 0.99 - num: 20 + num: 3 step: 0.05 distribution: uniform k_i_gain: min: 0.0001 max: 0.1 - num: 20 + num: 3 step: 0.0001 distribution: uniform - + msel: - distribution: categorical - values: + distribution: categorical + datatype: str + values: - last - val - loss_tr - + msel_tr_loss: - distribution: categorical - values: + distribution: categorical + datatype: str + values: - reg - task - ploss - + es: - distribution: categorical - values: + distribution: categorical + datatype: int + values: - 1 - 5 @@ -100,7 +103,7 @@ hduva_fbopt: - msel_tr_loss - msel - es - + dann_fbopt: aname: dann trainer: fbopt From 442a768a436307417ff3eade8b8bb510a99cb936 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 19:47:23 +0200 Subject: [PATCH 151/762] Update model_hduva.py --- domainlab/models/model_hduva.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index 45b59dd6e..df2e53119 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -29,7 +29,7 @@ def hyper_update(self, epoch, fun_scheduler): self.beta_x = dict_rst["beta_x"] self.beta_t = dict_rst["beta_t"] - def hyper_init(self, functor_scheduler): + def hyper_init(self, functor_scheduler, trainer=None): """hyper_init. :param functor_scheduler: """ @@ -37,7 +37,7 @@ def hyper_init(self, functor_scheduler): # class build a dictionary {"beta_d":self.beta_d, "beta_y":self.beta_y} # constructor signature is def __init__(self, **kwargs): return functor_scheduler( - trainer=None, + trainer=trainer, beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, beta_t=self.beta_t) From 512a9134e9f64bae7b095cb8e8ea121d88eb85cc Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 19:50:43 +0200 Subject: [PATCH 152/762] Create run_fbopt_hduva --- run_fbopt_hduva | 1 + 1 file changed, 1 insertion(+) create mode 100644 run_fbopt_hduva diff --git a/run_fbopt_hduva b/run_fbopt_hduva new file mode 100644 index 000000000..216e4e0e7 --- /dev/null +++ b/run_fbopt_hduva @@ -0,0 +1 @@ +python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --bs=8 --aname=hduva --trainer=fbopt --nname=conv_bn_pool_2 --gamma_y=7e5 --nname_topic_distrib_img2topic=conv_bn_pool_2 --nname_encoder_sandwich_layer_img2h4zd=conv_bn_pool_2 --gamma_y=3 --epos=2 From 55c25c598ebba573ae4cad35f79f85778078722f Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 20:05:02 +0200 Subject: [PATCH 153/762] Update train_fbopt.py --- domainlab/algos/trainers/train_fbopt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 7e1b57f23..16f8fd3b2 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -135,11 +135,13 @@ def tr_epoch(self, epoch): if self.aconf.msel == "loss_tr": if self.aconf.msel_tr_loss =="reg": self.epo_loss_tr = epo_reg_loss - elif self.aconf.msel_tr_loss =="erm": + elif self.aconf.msel_tr_loss =="task": self.epo_loss_tr = epo_task_loss elif self.aconf.msel_tr_loss == "p_loss": epo_p_loss = self.eval_p_loss() self.epo_loss_tr = epo_p_loss + else: + raise RuntimeError("msel_tr_loss set to be the wrong value") elif self.aconf.msel == "last" or self.aconf.msel == "val": self.epo_loss_tr = 1.0 # FIXME: check if this is not used at all else: From 593c34499d96c6c84cfe5b4a809d800260bc5d41 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 22 Sep 2023 20:07:17 +0200 Subject: [PATCH 154/762] Create run_fbopt_dann.sh --- run_fbopt_dann.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 run_fbopt_dann.sh diff --git a/run_fbopt_dann.sh b/run_fbopt_dann.sh new file mode 100644 index 000000000..4bb5e1374 --- /dev/null +++ b/run_fbopt_dann.sh @@ -0,0 +1 @@ +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=2 --msel=loss_tr --msel_tr_loss=task From 1f6d355ac54941980cfb41b497de2454b15b9f25 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 08:49:43 +0200 Subject: [PATCH 155/762] . --- domainlab/algos/trainers/fbopt_alternate.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index e459af33c..a7396ccdb 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -130,7 +130,7 @@ def search_mu(self, dict_theta=None, miter=None): self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True - def dict_clip(self, dict_base, clip_min=0.0001): + def dict_clip(self, dict_base, clip_min=0.0001): # FIXME: set thsi as hyperparameter """ clip each entry of the mu according to pre-set self.mu_clip """ @@ -162,9 +162,8 @@ def update_setpoint(self, epo_reg_loss): # FIXME: use pareto-reg-descent operator to decide if set point should be adjusted if epo_reg_loss < self.setpoint4R: logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info(f"!!!!found free descent operator, update setpoint to {epo_reg_loss}") lower_bound = self.coeff_ma * torch.tensor(epo_reg_loss) lower_bound += (1-self.coeff_ma) * torch.tensor(self.setpoint4R) lower_bound = lower_bound.tolist() self.setpoint4R = lower_bound - logger.info("set point updated!") + logger.info("!!!!!set point updated to {lower_bound}!") From ae347479227cc4f812c9cb4ff61fdeb9d7ff6555 Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 09:40:45 +0200 Subject: [PATCH 156/762] specify values for gamma_y in fbopt benchmark fixes #440 --- examples/benchmark/benchmark_fbopt_pacs_full.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index 8a3457bfe..b270f6c24 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -69,6 +69,13 @@ Shared params: - 1 - 5 + gamma_y: + min: 1e4 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + # Test fbopt with different hyperparameter configurations From 584476aa769acab1b01b84a590ba236296b4bd54 Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 09:47:47 +0200 Subject: [PATCH 157/762] added torch and tensorboard dependencies for #412 --- README.md | 15 +++++++-------- requirements.txt | 4 ++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f322a83f5..9b0c3a5e2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![pages-build-deployment](https://github.com/marrlab/DomainLab/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/marrlab/DomainLab/actions/workflows/pages/pages-build-deployment) ## Domain Generalization and DomainLab -Domain Generalization aims at learning domain invariant features by utilizing data from multiple domains (data sites, corhorts, batches, vendors) so the learned feature can generalize to new unseen domains. +Domain Generalization aims at learning domain invariant features by utilizing data from multiple domains (data sites, corhorts, batches, vendors) so the learned feature can generalize to new unseen domains. DomainLab is a software platform with state-of-the-art domain generalization algorithms implemented, designed by maximal decoupling of different software componets thus enhances maximal code reuse. @@ -19,21 +19,20 @@ DomainLab is a software platform with state-of-the-art domain generalization alg `conda create --name domainlab_py39 python=3.9` -then +then `conda activate domainlab_py39` #### Install Development version (recommended) Suppose you have cloned the repository and have changed directory to the cloned repository. +After creating a virtual environment (see above), run ```shell -conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge -conda install torchmetric==0.10.3 -pip install -r requirements.txt +pip install -r requirements.txt conda install tensorboard ``` -then +then `python setup.py install` @@ -44,7 +43,7 @@ Benchmarking is currently not supported on Windows due to the dependency on Snak #### Dependencies management - [python-poetry](https://python-poetry.org/) and use the configuration file `pyproject.toml` in this repository. - + #### Release - Install via `pip install domainlab` @@ -56,7 +55,7 @@ Suppose you have cloned the repository and have the dependencies ready, change d To train a domain invariant model on the vlcs_mini task ```shell -python main_out.py --te_d=caltech --tpath=examples/tasks/task_vlcs.py --config=examples/yaml/demo_config_single_run_diva.yaml +python main_out.py --te_d=caltech --tpath=examples/tasks/task_vlcs.py --config=examples/yaml/demo_config_single_run_diva.yaml ``` where `--tpath` specifies the path of a user specified python file which defines the domain generalization task [see here](./examples/tasks/task_vlcs.py), `--te_d` specifies the test domain name (or index starting from 0), `--config` specifies the configurations of the domain generalization algorithms, [see here](./examples/yaml/demo_config_single_run_diva.yaml) diff --git a/requirements.txt b/requirements.txt index 05c90d628..ef70b5567 100644 --- a/requirements.txt +++ b/requirements.txt @@ -70,6 +70,10 @@ throttler==1.2.2 ; python_version >= "3.9" and python_version < "4.0" tomli==2.0.1 ; python_version >= "3.9" and python_version < "3.11" toposort==1.10 ; python_version >= "3.9" and python_version < "4.0" tqdm==4.66.1 ; python_version >= "3.9" and python_version < "4.0" +torch==1.12.1 ; python_version >= "3.9" and python_version < "4.0" +torchmetrics==0.10.3 ; python_version >= "3.9" and python_version < "4.0" +torchvision==0.13.1 ; python_version >= "3.9" and python_version < "4.0" +tensorboard==2.14.0 ; python_version >= "3.9" and python_version < "4.0" traitlets==5.9.0 ; python_version >= "3.9" and python_version < "4.0" typing-extensions==4.7.1 ; python_version >= "3.9" and python_version < "4.0" urllib3==2.0.4 ; python_version >= "3.9" and python_version < "4.0" From ea2a3d98eb461b86ec9f56ac178ef8107c0c5e44 Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 09:50:09 +0200 Subject: [PATCH 158/762] removed tensorboard from readme as its in the requirements already --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9b0c3a5e2..29cb62c28 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ After creating a virtual environment (see above), run ```shell pip install -r requirements.txt -conda install tensorboard ``` then From 6c922a7888399dc990e36704c0ddeb0652398410 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 23 Sep 2023 10:00:27 +0200 Subject: [PATCH 159/762] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 29cb62c28..68614287f 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,14 @@ then `python setup.py install` +#### Guide for Helmholtz GPU cluster +``` +conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge +conda install torchmetric==0.10.3 +pip install -r requirements.txt +conda install tensorboard +``` + #### Windows installation details To install DomainLab on Windows, please remove the `snakemake` dependency from the `requirements.txt` file. From cb3f877dce5eb4870b15fd5b44e0602049c80210 Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 10:05:22 +0200 Subject: [PATCH 160/762] saving gamma_d in diva fixes #438 --- domainlab/models/model_diva.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 60c7e4457..00d23f64e 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -68,6 +68,7 @@ def __init__(self, chain_node_builder, zd_dim, zy_dim, zx_dim, list_str_y, list_d_tr) self.dim_d_tr = len(self.list_d_tr) + self.gamma_d = gamma_d if self.zd_dim > 0: self.add_module( "net_p_zd", From 355409d547539761e78c4c9b396aa911f846065f Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 10:18:24 +0200 Subject: [PATCH 161/762] added gamma_d as hyperparameter --- domainlab/models/model_diva.py | 2 +- examples/benchmark/benchmark_fbopt_pacs_full.yaml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 00d23f64e..51d85ba1e 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -68,7 +68,6 @@ def __init__(self, chain_node_builder, zd_dim, zy_dim, zx_dim, list_str_y, list_d_tr) self.dim_d_tr = len(self.list_d_tr) - self.gamma_d = gamma_d if self.zd_dim > 0: self.add_module( "net_p_zd", @@ -136,4 +135,5 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): return [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ [1.0, -self.beta_d, -self.beta_x, -self.beta_y, -self.gamma_d] + return ModelDIVA diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index b270f6c24..a6416369e 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -76,6 +76,12 @@ Shared params: num: 3 distribution: loguniform + gamma_d: + min: 1e4 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform # Test fbopt with different hyperparameter configurations @@ -100,6 +106,7 @@ diva_fbopt: - msel_tr_loss - msel - es + - gamma_d hduva_fbopt: aname: hduva From 567453bab484e054282c1789c084b244a0f41260 Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 10:20:24 +0200 Subject: [PATCH 162/762] dynamically adjusting gamma_d --- domainlab/models/model_diva.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 51d85ba1e..91ddac000 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -55,6 +55,7 @@ class ModelDIVA(parent_class): """ DIVA """ + @store_args def __init__(self, chain_node_builder, zd_dim, zy_dim, zx_dim, @@ -88,6 +89,7 @@ def hyper_update(self, epoch, fun_scheduler): self.beta_d = dict_rst["beta_d"] self.beta_y = dict_rst["beta_y"] self.beta_x = dict_rst["beta_x"] + self.gamma_d = dict_rst["gamma_d"] def hyper_init(self, functor_scheduler, trainer=None): """ @@ -97,7 +99,11 @@ def hyper_init(self, functor_scheduler, trainer=None): """ return functor_scheduler( trainer=trainer, - beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x) + beta_d=self.beta_d, + beta_y=self.beta_y, + beta_x=self.beta_x, + gamma_d=self.gamma_d, + ) def get_list_str_y(self): """get_list_str_y.""" From fed7b0eee3ac50bc9403fec566de4db650092dfd Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 10:27:00 +0200 Subject: [PATCH 163/762] using gamma_y in hduva --- examples/benchmark/benchmark_fbopt_pacs_full.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index a6416369e..80f91588c 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -117,6 +117,7 @@ hduva_fbopt: - msel_tr_loss - msel - es + - gamma_y dann_fbopt: aname: dann From 105f7a4f333967e988177350d0d0b1dd4483207e Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 11:20:06 +0200 Subject: [PATCH 164/762] update script --- run_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index fede457f9..df30d4447 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=2000 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 From 8ed78f89ccaac74e3b547b30e2633af32620068c Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 11:20:32 +0200 Subject: [PATCH 165/762] update script --- run_fbopt_diva.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_diva.sh b/run_fbopt_diva.sh index e882663f2..668b6a828 100644 --- a/run_fbopt_diva.sh +++ b/run_fbopt_diva.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=8 --aname=diva --trainer=fbopt --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=2000 --beta_mu=3 --budget_theta_update_per_mu=20 --init_mu4beta=0.01 --myoptic_pareto +python main_out.py --te_d=caltech --task=mini_vlcs --bs=8 --aname=diva --trainer=fbopt --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=200 From 845ce0376a05ac114b7a7f2fbce00430cd902826 Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 12:29:40 +0200 Subject: [PATCH 166/762] fixed wrong setting for msel_tr_loss --- examples/benchmark/benchmark_fbopt_pacs_full.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index 80f91588c..50228e6b8 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -60,7 +60,7 @@ Shared params: values: - reg - task - - ploss + - p_loss es: distribution: categorical From 8533b5bbfe93c56919ac71f24c9ef32dc16db0af Mon Sep 17 00:00:00 2001 From: e-dorigatti Date: Sat, 23 Sep 2023 12:38:26 +0200 Subject: [PATCH 167/762] printing actual values of all parameters before running experiment --- domainlab/exp_protocol/run_experiment.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/domainlab/exp_protocol/run_experiment.py b/domainlab/exp_protocol/run_experiment.py index c66ce0f46..ed475eecc 100644 --- a/domainlab/exp_protocol/run_experiment.py +++ b/domainlab/exp_protocol/run_experiment.py @@ -103,6 +103,11 @@ def run_experiment( gpu_ind = param_index % num_gpus args.device = str(gpu_ind) + logger.info('*** begin args') + for k, v in vars(args).items(): + logger.info(f'{k} : {v}') + logger.info('*** end args') + if torch.cuda.is_available(): torch.cuda.init() logger.info("before experiment loop: ") From 2203a339017a140eb73da38c6f93cc2bb7ffcea3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 14:36:42 +0200 Subject: [PATCH 168/762] separate controller for setpoint --- .../trainers/fbopt_setpoint_controller.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 domainlab/algos/trainers/fbopt_setpoint_controller.py diff --git a/domainlab/algos/trainers/fbopt_setpoint_controller.py b/domainlab/algos/trainers/fbopt_setpoint_controller.py new file mode 100644 index 000000000..ece92937e --- /dev/null +++ b/domainlab/algos/trainers/fbopt_setpoint_controller.py @@ -0,0 +1,33 @@ +""" +update hyper-parameters during training +""" +import copy +import numpy as np +from domainlab.utils.logger import Logger + + +class FbOptSetpointController(): + """ + design $\\mu$$ sequence based on state of penalized loss + """ + def __init__(self, trainer, **kwargs): + """ + kwargs is a dictionary with key the hyper-parameter name and its value + """ + self.ma_epo_reg_loss = None + + + + def observe(self, epo_reg_loss): + """ + FIXME: setpoint should also be able to be eliviated + """ + # FIXME: what does smaller than mean for a list? + # FIXME: use pareto-reg-descent operator to decide if set point should be adjusted + if epo_reg_loss < self.setpoint4R: + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + lower_bound = self.coeff_ma * torch.tensor(epo_reg_loss) + lower_bound += (1-self.coeff_ma) * torch.tensor(self.setpoint4R) + lower_bound = lower_bound.tolist() + self.setpoint4R = lower_bound + logger.info("!!!!!set point updated to {lower_bound}!") From a8bf0cd674e6678dcdb50d66ca06feaecf1f41e6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 14:37:25 +0200 Subject: [PATCH 169/762] . --- .../{fbopt_setpoint_controller.py => fbopt_setpoint_ada.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename domainlab/algos/trainers/{fbopt_setpoint_controller.py => fbopt_setpoint_ada.py} (100%) diff --git a/domainlab/algos/trainers/fbopt_setpoint_controller.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py similarity index 100% rename from domainlab/algos/trainers/fbopt_setpoint_controller.py rename to domainlab/algos/trainers/fbopt_setpoint_ada.py From acd7c0ceb2cc0a512f2b38bc3f2f7942cbca9393 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 15:03:48 +0200 Subject: [PATCH 170/762] structure --- .../algos/trainers/fbopt_setpoint_ada.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index ece92937e..cb5a9acbb 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -6,6 +6,24 @@ from domainlab.utils.logger import Logger +def is_less_list_any(list1, list2): + """ + judge if one list is less than the other + """ + list_comparison = [a < b for a, b in zip(list1, list2)] + return any(list_comparison) + + +def is_less_list_all(list1, list2): + """ + judge if one list is less than the other + """ + list_comparison = [a < b for a, b in zip(list1, list2)] + return all(list_comparison) + + + + class FbOptSetpointController(): """ design $\\mu$$ sequence based on state of penalized loss @@ -15,7 +33,7 @@ def __init__(self, trainer, **kwargs): kwargs is a dictionary with key the hyper-parameter name and its value """ self.ma_epo_reg_loss = None - + self.state_epo_reg_loss = None def observe(self, epo_reg_loss): @@ -31,3 +49,9 @@ def observe(self, epo_reg_loss): lower_bound = lower_bound.tolist() self.setpoint4R = lower_bound logger.info("!!!!!set point updated to {lower_bound}!") + + +class FbOptSetpointAdaRAllComponent(FbOptSetpointController): + def update_setpoint(self): + if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): + self.setpoint4R = self.state_epo_reg_loss From 8d2fc9b34dd5dfe9ed4e36e73090c09db6443333 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 15:18:44 +0200 Subject: [PATCH 171/762] more --- .../algos/trainers/fbopt_setpoint_ada.py | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index cb5a9acbb..70d966ed4 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -3,6 +3,8 @@ """ import copy import numpy as np +import torch + from domainlab.utils.logger import Logger @@ -22,8 +24,6 @@ def is_less_list_all(list1, list2): return all(list_comparison) - - class FbOptSetpointController(): """ design $\\mu$$ sequence based on state of penalized loss @@ -34,24 +34,37 @@ def __init__(self, trainer, **kwargs): """ self.ma_epo_reg_loss = None self.state_epo_reg_loss = None + self.coeff_ma = None + def update_setpoint_ma(self, target): + temp_ma = self.coeff_ma * torch.tensor(target) + temp_ma += (1 - self.coeff_ma) * torch.tensor(self.setpoint4R) + temp_ma = temp_ma.tolist() + self.setpoint4R = temp_ma def observe(self, epo_reg_loss): """ + read current epo_reg_loss continuously FIXME: setpoint should also be able to be eliviated """ - # FIXME: what does smaller than mean for a list? - # FIXME: use pareto-reg-descent operator to decide if set point should be adjusted - if epo_reg_loss < self.setpoint4R: + self.state_epo_reg_loss = epo_reg_loss + self.state_updater.update_setpoint() + if self.state_updater.update_setpoint(): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - lower_bound = self.coeff_ma * torch.tensor(epo_reg_loss) - lower_bound += (1-self.coeff_ma) * torch.tensor(self.setpoint4R) - lower_bound = lower_bound.tolist() - self.setpoint4R = lower_bound - logger.info("!!!!!set point updated to {lower_bound}!") + logger.info("!!!!!set point updated to {self.setpoint4R}!") + + +class RComponentAll(FbOptSetpointController): + def update_setpoint(self): + if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): + self.setpoint4R = self.state_epo_reg_loss + return True + return False -class FbOptSetpointAdaRAllComponent(FbOptSetpointController): +class RComponentAny(FbOptSetpointController): def update_setpoint(self): if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): self.setpoint4R = self.state_epo_reg_loss + return True + return False From 740823ed3d34febc13fc4abf5f0864ceeb431d93 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 15:29:16 +0200 Subject: [PATCH 172/762] . --- .../algos/trainers/fbopt_setpoint_ada.py | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 70d966ed4..e38fc7045 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -28,13 +28,16 @@ class FbOptSetpointController(): """ design $\\mu$$ sequence based on state of penalized loss """ - def __init__(self, trainer, **kwargs): + def __init__(self): """ kwargs is a dictionary with key the hyper-parameter name and its value """ self.ma_epo_reg_loss = None self.state_epo_reg_loss = None self.coeff_ma = None + self.state_updater = None + self.setpoint4R = None + self.setpoint4ell = None def update_setpoint_ma(self, target): temp_ma = self.coeff_ma * torch.tensor(target) @@ -54,7 +57,7 @@ def observe(self, epo_reg_loss): logger.info("!!!!!set point updated to {self.setpoint4R}!") -class RComponentAll(FbOptSetpointController): +class SliderAll(FbOptSetpointController): def update_setpoint(self): if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): self.setpoint4R = self.state_epo_reg_loss @@ -62,7 +65,21 @@ def update_setpoint(self): return False -class RComponentAny(FbOptSetpointController): +class SliderAny(FbOptSetpointController): + def update_setpoint(self): + if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): + self.setpoint4R = self.state_epo_reg_loss + return True + return False + +class DominateAny(FbOptSetpointController): + def update_setpoint(self): + flag1 = is_less_list_any(self.state_epo_reg_loss, self.setpoint4R) + flag2 = self.state_task_loss < self.setpoint4_ell + return flag1 & flag2 + return False + +class DominateAll(FbOptSetpointController): def update_setpoint(self): if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): self.setpoint4R = self.state_epo_reg_loss From d22749e7728d2fe97d40612b1f25f6392649f3d6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 15:52:57 +0200 Subject: [PATCH 173/762] ".2 --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index e38fc7045..1f6d18b5b 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -75,13 +75,11 @@ def update_setpoint(self): class DominateAny(FbOptSetpointController): def update_setpoint(self): flag1 = is_less_list_any(self.state_epo_reg_loss, self.setpoint4R) - flag2 = self.state_task_loss < self.setpoint4_ell + flag2 = self.state_task_loss < self.setpoint4ell return flag1 & flag2 - return False class DominateAll(FbOptSetpointController): def update_setpoint(self): - if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): - self.setpoint4R = self.state_epo_reg_loss - return True - return False + flag1 = is_less_list_all(self.state_epo_reg_loss, self.setpoint4R) + flag2 = self.state_task_loss < self.setpoint4ell + return flag1 & flag2 From 9b47eef81faa8c369f1513a8ee4be786282f7011 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 15:55:01 +0200 Subject: [PATCH 174/762] . --- .../benchmark_fbopt_pacs_full_felix.yaml | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 examples/benchmark/benchmark_fbopt_pacs_full_felix.yaml diff --git a/examples/benchmark/benchmark_fbopt_pacs_full_felix.yaml b/examples/benchmark/benchmark_fbopt_pacs_full_felix.yaml new file mode 100644 index 000000000..50228e6b8 --- /dev/null +++ b/examples/benchmark/benchmark_fbopt_pacs_full_felix.yaml @@ -0,0 +1,130 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + bs: 64 + san_check: True + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + + + +Shared params: + ini_setpoint_ratio: + min: 0.5 + max: 0.99 + num: 3 + step: 0.05 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.1 + num: 3 + step: 0.0001 + distribution: uniform + + msel: + distribution: categorical + datatype: str + values: + - last + - val + - loss_tr + + msel_tr_loss: + distribution: categorical + datatype: str + values: + - reg + - task + - p_loss + + es: + distribution: categorical + datatype: int + values: + - 1 + - 5 + + gamma_y: + min: 1e4 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1e4 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + +# Test fbopt with different hyperparameter configurations + +jigen_fbopt: + aname: jigen + trainer: fbopt + + shared: + - ini_setpoint_ratio + - k_i_gain + - msel_tr_loss + - msel + - es + + +diva_fbopt: + aname: diva + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain + - msel_tr_loss + - msel + - es + - gamma_d + +hduva_fbopt: + aname: hduva + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain + - msel_tr_loss + - msel + - es + - gamma_y + +dann_fbopt: + aname: dann + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain + - msel_tr_loss + - msel + - es From 1f249821dc5ac43755cf67c95f68ec64f28b1ae1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 16:23:13 +0200 Subject: [PATCH 175/762] update yaml --- examples/benchmark/benchmark_fbopt_pacs_full.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index 50228e6b8..042585e05 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -106,6 +106,7 @@ diva_fbopt: - msel_tr_loss - msel - es + - gamma_y - gamma_d hduva_fbopt: From 78d586c1638e2f9df0c80a641493b1c76c3ae7aa Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 16:23:44 +0200 Subject: [PATCH 176/762] . --- .../benchmark_fbopt_pacs_full_felix.yaml | 130 ------------------ 1 file changed, 130 deletions(-) delete mode 100644 examples/benchmark/benchmark_fbopt_pacs_full_felix.yaml diff --git a/examples/benchmark/benchmark_fbopt_pacs_full_felix.yaml b/examples/benchmark/benchmark_fbopt_pacs_full_felix.yaml deleted file mode 100644 index 50228e6b8..000000000 --- a/examples/benchmark/benchmark_fbopt_pacs_full_felix.yaml +++ /dev/null @@ -1,130 +0,0 @@ -mode: grid - -output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full - -sampling_seed: 0 - -startseed: 0 -endseed: 2 - -test_domains: - - sketch - -domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py - dmem: False - lr: 5e-5 - epos: 200 - bs: 64 - san_check: True - npath: examples/nets/resnet50domainbed.py - npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - exp_shoulder_clip: 10 - mu_clip: 10_000 - coeff_ma: 0.5 - zx_dim: 0 - zy_dim: 64 - zd_dim: 64 - - - - -Shared params: - ini_setpoint_ratio: - min: 0.5 - max: 0.99 - num: 3 - step: 0.05 - distribution: uniform - - k_i_gain: - min: 0.0001 - max: 0.1 - num: 3 - step: 0.0001 - distribution: uniform - - msel: - distribution: categorical - datatype: str - values: - - last - - val - - loss_tr - - msel_tr_loss: - distribution: categorical - datatype: str - values: - - reg - - task - - p_loss - - es: - distribution: categorical - datatype: int - values: - - 1 - - 5 - - gamma_y: - min: 1e4 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - gamma_d: - min: 1e4 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - -# Test fbopt with different hyperparameter configurations - -jigen_fbopt: - aname: jigen - trainer: fbopt - - shared: - - ini_setpoint_ratio - - k_i_gain - - msel_tr_loss - - msel - - es - - -diva_fbopt: - aname: diva - trainer: fbopt - shared: - - ini_setpoint_ratio - - k_i_gain - - msel_tr_loss - - msel - - es - - gamma_d - -hduva_fbopt: - aname: hduva - trainer: fbopt - shared: - - ini_setpoint_ratio - - k_i_gain - - msel_tr_loss - - msel - - es - - gamma_y - -dann_fbopt: - aname: dann - trainer: fbopt - shared: - - ini_setpoint_ratio - - k_i_gain - - msel_tr_loss - - msel - - es From 7d45139fa879ca4c2af56063c2788ad04f425057 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 20:16:42 +0200 Subject: [PATCH 177/762] . --- run_fbopt_diva_cpu.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 run_fbopt_diva_cpu.sh diff --git a/run_fbopt_diva_cpu.sh b/run_fbopt_diva_cpu.sh new file mode 100644 index 000000000..4ba3776b7 --- /dev/null +++ b/run_fbopt_diva_cpu.sh @@ -0,0 +1,6 @@ +#!/bin/bash +export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py +python main_out.py --te_d=caltech --task=mini_vlcs --bs=8 --aname=diva --trainer=fbopt --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=200 From 45512dd2250acc02fa6d5a9f755fc4c3c4ab8f37 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 20:19:28 +0200 Subject: [PATCH 178/762] add register --- domainlab/models/model_diva.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index bad36e76e..d59924e2e 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -99,6 +99,7 @@ def hyper_init(self, functor_scheduler, trainer=None): """ return functor_scheduler( trainer=trainer, + mu_recon=self.self.multiplier_recon beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, From 11ab7851cd39ca8a7f9154ef2f1db9419adad123 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 20:21:46 +0200 Subject: [PATCH 179/762] add register mu component --- domainlab/models/model_diva.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index d59924e2e..d250b75ab 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -99,7 +99,7 @@ def hyper_init(self, functor_scheduler, trainer=None): """ return functor_scheduler( trainer=trainer, - mu_recon=self.self.multiplier_recon + mu_recon=self.multiplier_recon, beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, From 1921f51721a38d985e31b09943ae769fef3cfdd0 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 20:26:35 +0200 Subject: [PATCH 180/762] hduva --- domainlab/models/model_hduva.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index a65d67fc9..f4405501f 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -38,6 +38,7 @@ def hyper_init(self, functor_scheduler, trainer=None): # constructor signature is def __init__(self, **kwargs): return functor_scheduler( trainer=trainer, + mu_recon=self.multiplier_recon, beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, beta_t=self.beta_t) From 0a274d9971cfd8b1ba9eb34698a9c3c6918ef14e Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 23 Sep 2023 20:27:18 +0200 Subject: [PATCH 181/762] cpu --- run_fbopt_hduva_cpu.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 run_fbopt_hduva_cpu.sh diff --git a/run_fbopt_hduva_cpu.sh b/run_fbopt_hduva_cpu.sh new file mode 100644 index 000000000..772a3793e --- /dev/null +++ b/run_fbopt_hduva_cpu.sh @@ -0,0 +1,2 @@ +export CUDA_VISIBLE_DEVICES="" +python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --bs=8 --aname=hduva --trainer=fbopt --nname=conv_bn_pool_2 --gamma_y=7e5 --nname_topic_distrib_img2topic=conv_bn_pool_2 --nname_encoder_sandwich_layer_img2h4zd=conv_bn_pool_2 --gamma_y=3 --epos=2 From a58c880790a290e1b4bc45257b8f348eed615fc7 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 23 Sep 2023 21:37:15 +0200 Subject: [PATCH 182/762] Update benchmark_fbopt_pacs_full.yaml --- examples/benchmark/benchmark_fbopt_pacs_full.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index 042585e05..6732e3d25 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -107,7 +107,6 @@ diva_fbopt: - msel - es - gamma_y - - gamma_d hduva_fbopt: aname: hduva From a99a0039a9292d7b0531107d44f99d2f4ab76e1d Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 24 Sep 2023 00:31:10 +0200 Subject: [PATCH 183/762] Update model_dann.py --- domainlab/models/model_dann.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/models/model_dann.py b/domainlab/models/model_dann.py index 2dd14e381..a98c399ef 100644 --- a/domainlab/models/model_dann.py +++ b/domainlab/models/model_dann.py @@ -84,5 +84,5 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): AutoGradFunReverseMultiply.apply(feat, self.alpha)) _, d_target = tensor_d.max(dim=1) lc_d = F.cross_entropy(logit_d, d_target, reduction="none") - return [lc_d], [self.alpha] + return [-lc_d], [self.alpha] return ModelDAN From 435a4fa9d5afc20de2ad97eff34a84508b65adc2 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 24 Sep 2023 10:16:30 +0200 Subject: [PATCH 184/762] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0884a38c2..dc5996d14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push: branches: master pull_request: - branches: master + branches: fbopt workflow_dispatch: jobs: From 240fb9a0cab868c749ffc350365170065f7b5c86 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 24 Sep 2023 10:16:49 +0200 Subject: [PATCH 185/762] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc5996d14..44ff9721a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: master + branches: fbopt pull_request: branches: fbopt workflow_dispatch: From 327beb7ecf730b7704f8447f5a77c95c2979772f Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 25 Sep 2023 10:23:13 +0200 Subject: [PATCH 186/762] delete non-necessary model selection --- .../benchmark/benchmark_fbopt_pacs_full.yaml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index 042585e05..6c9ae777d 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -46,22 +46,6 @@ Shared params: step: 0.0001 distribution: uniform - msel: - distribution: categorical - datatype: str - values: - - last - - val - - loss_tr - - msel_tr_loss: - distribution: categorical - datatype: str - values: - - reg - - task - - p_loss - es: distribution: categorical datatype: int From 1807df17af7bfe0016496321b4f0a13df8fd24db Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 25 Sep 2023 10:31:28 +0200 Subject: [PATCH 187/762] fix yaml --- examples/benchmark/benchmark_fbopt_pacs_full.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml index f7778ae79..f0484765a 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_full.yaml @@ -76,8 +76,6 @@ jigen_fbopt: shared: - ini_setpoint_ratio - k_i_gain - - msel_tr_loss - - msel - es @@ -87,8 +85,6 @@ diva_fbopt: shared: - ini_setpoint_ratio - k_i_gain - - msel_tr_loss - - msel - es - gamma_y @@ -98,8 +94,6 @@ hduva_fbopt: shared: - ini_setpoint_ratio - k_i_gain - - msel_tr_loss - - msel - es - gamma_y @@ -109,6 +103,4 @@ dann_fbopt: shared: - ini_setpoint_ratio - k_i_gain - - msel_tr_loss - - msel - es From 45ba1f9e59f2d69d5c0e2c69fd91d8f22d5dc3b8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 25 Sep 2023 10:52:37 +0200 Subject: [PATCH 188/762] yam for dann --- examples/benchmark/benchmark_fbopt_pacs.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs.yaml b/examples/benchmark/benchmark_fbopt_pacs.yaml index 14d4d8d62..f7d3aaeaa 100644 --- a/examples/benchmark/benchmark_fbopt_pacs.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs.yaml @@ -44,10 +44,10 @@ Shared params: # Test fbopt with different hyperparameter configurations -jigen_fbopt: - aname: jigen +dann_fbopt: + aname: dann trainer: fbopt - shared: - ini_setpoint_ratio - k_i_gain + - es From ca8df25efb67292e0b1e20cb0294d994eac2ec3d Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 25 Sep 2023 10:52:58 +0200 Subject: [PATCH 189/762] . --- .../{benchmark_fbopt_pacs.yaml => benchmark_fbopt_dann.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{benchmark_fbopt_pacs.yaml => benchmark_fbopt_dann.yaml} (100%) diff --git a/examples/benchmark/benchmark_fbopt_pacs.yaml b/examples/benchmark/benchmark_fbopt_dann.yaml similarity index 100% rename from examples/benchmark/benchmark_fbopt_pacs.yaml rename to examples/benchmark/benchmark_fbopt_dann.yaml From 3341d2b5a37dff9580459aba960194c85ed445d0 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 25 Sep 2023 10:57:57 +0200 Subject: [PATCH 190/762] . --- examples/benchmark/benchmark_fbopt.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/benchmark/benchmark_fbopt.yaml b/examples/benchmark/benchmark_fbopt.yaml index 0158c7edc..3f4f11d04 100644 --- a/examples/benchmark/benchmark_fbopt.yaml +++ b/examples/benchmark/benchmark_fbopt.yaml @@ -52,3 +52,12 @@ jigen_fbopt: shared: - ini_setpoint_ratio - k_i_gain + - es + +dann_fbopt: + aname: dann + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain + - es From f2d2ed0c0127a1f806cfa294f0ba3a4eea771485 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 25 Sep 2023 10:58:33 +0200 Subject: [PATCH 191/762] . --- .../{benchmark_fbopt.yaml => benchmark_fbopt_mnist.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{benchmark_fbopt.yaml => benchmark_fbopt_mnist.yaml} (100%) diff --git a/examples/benchmark/benchmark_fbopt.yaml b/examples/benchmark/benchmark_fbopt_mnist.yaml similarity index 100% rename from examples/benchmark/benchmark_fbopt.yaml rename to examples/benchmark/benchmark_fbopt_mnist.yaml From b5ca3ee5fa04abdbeea8dcc85e5681795c3945e8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 25 Sep 2023 11:44:50 +0200 Subject: [PATCH 192/762] add tensorboard acc --- domainlab/algos/observers/c_obvisitor_cleanup.py | 10 +++++++--- domainlab/algos/trainers/fbopt_alternate.py | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/observers/c_obvisitor_cleanup.py b/domainlab/algos/observers/c_obvisitor_cleanup.py index 07d1d1871..9b39dbd51 100644 --- a/domainlab/algos/observers/c_obvisitor_cleanup.py +++ b/domainlab/algos/observers/c_obvisitor_cleanup.py @@ -10,7 +10,7 @@ def __init__(self, observer): def after_all(self): self.observer.after_all() - self.observer.clean_up() # FIXME should be self.clean_up??? + self.observer.clean_up() # FIXME should be self.clean_up??? def accept(self, trainer): self.observer.accept(trainer) @@ -20,11 +20,15 @@ def update(self, epoch): def clean_up(self): self.observer.clean_up() - + @property def model_sel(self): return self.observer.model_sel - + @model_sel.setter def model_sel(self, model_sel): self.observer.model_sel = model_sel + + @property + def metric_te(self): + return self.observer.metric_te diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 927ed4891..9743ae40b 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -129,7 +129,12 @@ def search_mu(self, dict_theta=None, miter=None): loss_penalized = epos_task_loss + torch.inner(torch.Tensor(list(self.mmu.values())), torch.Tensor(epo_reg_loss)) self.writer.add_scalar('loss_penalized', loss_penalized, miter) - self.writer.add_scalar(f'task', epos_task_loss, miter) + self.writer.add_scalar('task', epos_task_loss, miter) + if miter == 1: + acc = 0 + else: + acc = self.trainer.observer.metric_te["acc"] + self.writer.add_scalar("acc", acc, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True From 32c1fde10932b34d9faa965f0fc4c1d9b8b7ee7a Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 27 Sep 2023 10:23:56 +0200 Subject: [PATCH 193/762] structure ready --- .../algos/trainers/fbopt_setpoint_ada.py | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 1f6d18b5b..5fccd4f68 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -1,10 +1,7 @@ """ update hyper-parameters during training """ -import copy -import numpy as np import torch - from domainlab.utils.logger import Logger @@ -36,8 +33,10 @@ def __init__(self): self.state_epo_reg_loss = None self.coeff_ma = None self.state_updater = None + self.state_task_loss = None self.setpoint4R = None self.setpoint4ell = None + self.host = None def update_setpoint_ma(self, target): temp_ma = self.coeff_ma * torch.tensor(target) @@ -54,32 +53,68 @@ def observe(self, epo_reg_loss): self.state_updater.update_setpoint() if self.state_updater.update_setpoint(): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + self.setpoint4R = self.state_epo_reg_loss logger.info("!!!!!set point updated to {self.setpoint4R}!") -class SliderAll(FbOptSetpointController): +class FbOptSetpointControllerState(FbOptSetpointController): + """ + abstract state pattern + """ + def accept(self, controller): + """ + set host for state + """ + self.host = controller + + +class SliderAllComponent(FbOptSetpointControllerState): + """ + concrete state pattern + """ def update_setpoint(self): - if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): - self.setpoint4R = self.state_epo_reg_loss + """ + all components of R descreases regardless if ell decreases or not + """ + if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R): return True return False -class SliderAny(FbOptSetpointController): +class SliderAnyComponent(FbOptSetpointControllerState): + """ + concrete state pattern + """ def update_setpoint(self): - if is_less_list_all(self.state_epo_reg_loss, self.setpoint4R): - self.setpoint4R = self.state_epo_reg_loss + """ + if any component of R has decreased regardless if ell decreases + """ + if is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R): return True return False -class DominateAny(FbOptSetpointController): + +class DominateAnyComponent(FbOptSetpointControllerState): + """ + concrete state pattern + """ def update_setpoint(self): - flag1 = is_less_list_any(self.state_epo_reg_loss, self.setpoint4R) - flag2 = self.state_task_loss < self.setpoint4ell + """ + if any of the component of R loss has decreased together with ell loss + """ + flag1 = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) + flag2 = self.host.state_task_loss < self.host.setpoint4ell return flag1 & flag2 -class DominateAll(FbOptSetpointController): + +class DominateAllComponent(FbOptSetpointControllerState): + """ + concrete state pattern + """ def update_setpoint(self): - flag1 = is_less_list_all(self.state_epo_reg_loss, self.setpoint4R) - flag2 = self.state_task_loss < self.setpoint4ell + """ + if each component of R loss has decreased and ell loss also decreased + """ + flag1 = is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R) + flag2 = self.host.state_task_loss < self.host.setpoint4ell return flag1 & flag2 From bc64f637f913d667ba94e3652bb52d4b9b8a6bcb Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 27 Sep 2023 15:50:58 +0200 Subject: [PATCH 194/762] to do coeff ma --- domainlab/algos/trainers/fbopt_alternate.py | 11 +++-------- .../algos/trainers/fbopt_setpoint_ada.py | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 9743ae40b..5d5a46a72 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -9,6 +9,7 @@ import numpy as np from domainlab.utils.logger import Logger +from domainlab.algos.trainers.fbopt_setpoint_ada import FbOptSetpointController class StubSummaryWriter(): @@ -50,6 +51,7 @@ def __init__(self, trainer, **kwargs): self.count_found_operator = 0 self.count_search_mu = 0 ######################################## + self.set_point_controller = FbOptSetpointController() self.k_i_control = trainer.aconf.k_i_gain self.delta_epsilon_r = False # False here just used to decide if value first use or not self.setpoint4R = None @@ -167,11 +169,4 @@ def update_setpoint(self, epo_reg_loss): """ FIXME: setpoint should also be able to be eliviated """ - # FIXME: use pareto-reg-descent operator to decide if set point should be adjusted - if epo_reg_loss < self.setpoint4R: - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - lower_bound = self.coeff_ma * torch.tensor(epo_reg_loss) - lower_bound += (1-self.coeff_ma) * torch.tensor(self.setpoint4R) - lower_bound = lower_bound.tolist() - self.setpoint4R = lower_bound - logger.info("!!!!!set point updated to {lower_bound}!") + self.set_point_controller.observe(epo_reg_loss) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 5fccd4f68..72e018266 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -23,22 +23,34 @@ def is_less_list_all(list1, list2): class FbOptSetpointController(): """ - design $\\mu$$ sequence based on state of penalized loss + update setpoint for mu """ - def __init__(self): + def __init__(self, state=None): """ kwargs is a dictionary with key the hyper-parameter name and its value """ + if state is None: + state = SliderAnyComponent() + self.transition_to(state) self.ma_epo_reg_loss = None self.state_epo_reg_loss = None self.coeff_ma = None - self.state_updater = None self.state_task_loss = None self.setpoint4R = None self.setpoint4ell = None self.host = None + def transition_to(self, state): + """ + change internal state + """ + self.state_updater = state + self.state_updater.accept(self) + def update_setpoint_ma(self, target): + """ + using moving average + """ temp_ma = self.coeff_ma * torch.tensor(target) temp_ma += (1 - self.coeff_ma) * torch.tensor(self.setpoint4R) temp_ma = temp_ma.tolist() @@ -50,7 +62,6 @@ def observe(self, epo_reg_loss): FIXME: setpoint should also be able to be eliviated """ self.state_epo_reg_loss = epo_reg_loss - self.state_updater.update_setpoint() if self.state_updater.update_setpoint(): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") self.setpoint4R = self.state_epo_reg_loss From c99010005e672f75a2ba9879b2ee58fe8d5c3a14 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 28 Sep 2023 10:36:05 +0200 Subject: [PATCH 195/762] maybe it works --- domainlab/algos/trainers/fbopt_alternate.py | 7 +++++++ domainlab/algos/trainers/fbopt_setpoint_ada.py | 10 ++++++++-- domainlab/algos/trainers/train_fbopt.py | 6 +++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 5d5a46a72..2eb315cf7 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -65,6 +65,13 @@ def __init__(self, trainer, **kwargs): self.coeff_ma = trainer.aconf.coeff_ma self.epsilon_r = False + def set_setpoint(self, list_setpoint4R, setpoint4ell): + """ + set the setpoint + """ + self.set_point_controller.setpoint4R = list_setpoint4R + self.set_point_controller.setpoint4ell = setpoint4ell + def update_anchor(self, dict_par): """ update the last ensured value of theta^{(k)} diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 72e018266..076315850 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -34,8 +34,9 @@ def __init__(self, state=None): self.transition_to(state) self.ma_epo_reg_loss = None self.state_epo_reg_loss = None - self.coeff_ma = None + self.coeff_ma = 0.5 # FIXME self.state_task_loss = None + # initial value will be set via trainer self.setpoint4R = None self.setpoint4ell = None self.host = None @@ -56,12 +57,13 @@ def update_setpoint_ma(self, target): temp_ma = temp_ma.tolist() self.setpoint4R = temp_ma - def observe(self, epo_reg_loss): + def observe(self, epo_reg_loss, epo_task_loss): """ read current epo_reg_loss continuously FIXME: setpoint should also be able to be eliviated """ self.state_epo_reg_loss = epo_reg_loss + self.state_task_loss = epo_task_loss if self.state_updater.update_setpoint(): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") self.setpoint4R = self.state_epo_reg_loss @@ -115,6 +117,8 @@ def update_setpoint(self): """ flag1 = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) flag2 = self.host.state_task_loss < self.host.setpoint4ell + if flag2: + self.host.setpoint4ell = self.host.state_task_loss return flag1 & flag2 @@ -128,4 +132,6 @@ def update_setpoint(self): """ flag1 = is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R) flag2 = self.host.state_task_loss < self.host.setpoint4ell + if flag2: + self.host.setpoint4ell = self.host.state_task_loss return flag1 & flag2 diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 16f8fd3b2..561a7dc43 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -56,9 +56,9 @@ def before_tr(self): copy.deepcopy(self.model), self.task, self.observer, self.device, self.aconf, flag_accept=False) - epo_reg_loss, _ = self.eval_r_loss() - self.hyper_scheduler.setpoint4R = \ - [ele * self.aconf.ini_setpoint_ratio for ele in epo_reg_loss] + epo_reg_loss, epo_task_loss = self.eval_r_loss() + self.hyper_scheduler.set_setpoint( + [ele * self.aconf.ini_setpoint_ratio for ele in epo_reg_loss], epo_task_loss) def opt_theta(self, dict4mu, dict_theta0): """ From 145d79afe33fe66020d07751c73563b09bd4b67b Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 28 Sep 2023 10:51:28 +0200 Subject: [PATCH 196/762] runs through --- domainlab/algos/trainers/fbopt_alternate.py | 12 +++++++----- domainlab/algos/trainers/fbopt_setpoint_ada.py | 7 ++++++- domainlab/algos/trainers/train_fbopt.py | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 2eb315cf7..6dc6621c1 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -54,7 +54,6 @@ def __init__(self, trainer, **kwargs): self.set_point_controller = FbOptSetpointController() self.k_i_control = trainer.aconf.k_i_gain self.delta_epsilon_r = False # False here just used to decide if value first use or not - self.setpoint4R = None # NOTE: this value will be set according to initial evaluation of neural network self.mu_clip = trainer.aconf.mu_clip self.activation_clip = trainer.aconf.exp_shoulder_clip @@ -65,6 +64,9 @@ def __init__(self, trainer, **kwargs): self.coeff_ma = trainer.aconf.coeff_ma self.epsilon_r = False + def get_setpoint4R(self): + return self.set_point_controller.setpoint4R + def set_setpoint(self, list_setpoint4R, setpoint4ell): """ set the setpoint @@ -104,7 +106,7 @@ def search_mu(self, dict_theta=None, miter=None): epo_reg_loss, epos_task_loss = self.trainer.eval_r_loss() # FIXME: use dictionary to replace scalar representation # delta_epsilon_r = epo_reg_loss - self.setpoint4R - delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.setpoint4R) + delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.get_setpoint4R()) # TODO: can be replaced by a controller if self.delta_epsilon_r is False: self.delta_epsilon_r = delta_epsilon_r @@ -126,7 +128,7 @@ def search_mu(self, dict_theta=None, miter=None): for key, val in self.mmu.items(): self.writer.add_scalar(f'mmu/{key}', val, miter) - for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.setpoint4R)): + for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoint4R())): self.writer.add_scalar(f'reg/dyn{i}', reg_dyn, miter) self.writer.add_scalar(f'reg/setpoint{i}', reg_set, miter) @@ -172,8 +174,8 @@ def dict_multiply(self, dict_base, list_multiplier): # NOTE: allow multipler be bigger than 1 return {key: val*dict_multiplier[key] for key, val in dict_base.items()} - def update_setpoint(self, epo_reg_loss): + def update_setpoint(self, epo_reg_loss, epo_task_loss): """ FIXME: setpoint should also be able to be eliviated """ - self.set_point_controller.observe(epo_reg_loss) + self.set_point_controller.observe(epo_reg_loss, epo_task_loss) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 076315850..6ade47ef6 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -70,10 +70,15 @@ def observe(self, epo_reg_loss, epo_task_loss): logger.info("!!!!!set point updated to {self.setpoint4R}!") -class FbOptSetpointControllerState(FbOptSetpointController): +class FbOptSetpointControllerState(): """ abstract state pattern """ + def __init__(self): + """ + """ + self.host = None + def accept(self, controller): """ set host for state diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 561a7dc43..e5bd37599 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -179,7 +179,7 @@ def tr_epoch(self, epoch): logger.info( f"at epoch {epoch}, after shooting: epo_reg_loss={epo_reg_loss}, \ epo_task_loss={epo_task_loss}") - self.hyper_scheduler.update_setpoint(epo_reg_loss) + self.hyper_scheduler.update_setpoint(epo_reg_loss, epo_task_loss) #if self.aconf.myoptic_pareto: # self.hyper_scheduler.update_anchor(dict_par) flag_early_stop_observer = self.observer.update(epoch) From aac6969cf50a654bb9371b57ae7e7127d17cbbd7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 28 Sep 2023 12:36:56 +0200 Subject: [PATCH 197/762] longer runs --- run_fbopt.sh | 2 +- run_fbopt_diva_cpu.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index df30d4447..c56f209cc 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=100 diff --git a/run_fbopt_diva_cpu.sh b/run_fbopt_diva_cpu.sh index 4ba3776b7..4db80360f 100644 --- a/run_fbopt_diva_cpu.sh +++ b/run_fbopt_diva_cpu.sh @@ -3,4 +3,4 @@ export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=8 --aname=diva --trainer=fbopt --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=200 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=8 --aname=diva --trainer=fbopt --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=200 --es=100 From aeac492e66ee66d78a66faefb59439592ce985dc Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 28 Sep 2023 13:34:08 +0200 Subject: [PATCH 198/762] works --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 1 + run_fbopt_dann.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 6ade47ef6..900a0264e 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -108,6 +108,7 @@ def update_setpoint(self): if any component of R has decreased regardless if ell decreases """ if is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R): + self.host.transition_to(SliderAllComponent()) return True return False diff --git a/run_fbopt_dann.sh b/run_fbopt_dann.sh index 4bb5e1374..9382eab50 100644 --- a/run_fbopt_dann.sh +++ b/run_fbopt_dann.sh @@ -1 +1 @@ -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=2 --msel=loss_tr --msel_tr_loss=task +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --msel=loss_tr --msel_tr_loss=task From 33ae40732d7182f0770af9078b0720b11a38ba3d Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 2 Oct 2023 10:56:25 +0200 Subject: [PATCH 199/762] add validation acc to tensorboard #482 --- domainlab/algos/observers/c_obvisitor_cleanup.py | 4 ++++ domainlab/algos/trainers/fbopt_alternate.py | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/observers/c_obvisitor_cleanup.py b/domainlab/algos/observers/c_obvisitor_cleanup.py index 9b39dbd51..a05c914cd 100644 --- a/domainlab/algos/observers/c_obvisitor_cleanup.py +++ b/domainlab/algos/observers/c_obvisitor_cleanup.py @@ -32,3 +32,7 @@ def model_sel(self, model_sel): @property def metric_te(self): return self.observer.metric_te + + @property + def metric_val(self): + return self.observer.metric_val diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 6dc6621c1..eecfafa88 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -141,11 +141,14 @@ def search_mu(self, dict_theta=None, miter=None): loss_penalized = epos_task_loss + torch.inner(torch.Tensor(list(self.mmu.values())), torch.Tensor(epo_reg_loss)) self.writer.add_scalar('loss_penalized', loss_penalized, miter) self.writer.add_scalar('task', epos_task_loss, miter) - if miter == 1: - acc = 0 - else: - acc = self.trainer.observer.metric_te["acc"] - self.writer.add_scalar("acc", acc, miter) + acc_te = 0 + acc_val = 0 + + if miter > 1: + acc_te = self.trainer.observer.metric_te["acc"] + acc_val = self.trainer.observer.metric_val["acc"] + self.writer.add_scalar("acc_te", acc_te, miter) + self.writer.add_scalar("acc_val", acc_val, miter) self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True From e51210f3ef01b978605bb8ee41b9422575d06ce4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 2 Oct 2023 11:11:54 +0200 Subject: [PATCH 200/762] fix #475 --- domainlab/algos/trainers/fbopt_alternate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index eecfafa88..e043cdb93 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -60,7 +60,7 @@ def __init__(self, trainer, **kwargs): if trainer.aconf.no_tensorboard: self.writer = StubSummaryWriter() else: - self.writer = SummaryWriter(comment=os.environ.get('SLURM_JOB_ID', '')) + self.writer = SummaryWriter(log_dir="zoutput/runs", comment=os.environ.get('SLURM_JOB_ID', '')) self.coeff_ma = trainer.aconf.coeff_ma self.epsilon_r = False From 2cbe2b3ac1e69d7bb145ac3499f320a8b7788a40 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 2 Oct 2023 11:55:34 +0200 Subject: [PATCH 201/762] fix #442, disable setpoint update --- domainlab/algos/trainers/args_fbopt.py | 2 ++ domainlab/algos/trainers/fbopt_alternate.py | 2 +- domainlab/algos/trainers/fbopt_setpoint_ada.py | 12 ++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 8b1626a4d..b43a71ce2 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -27,6 +27,8 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_tensorboard', action='store_true', default=False, help='disable tensorboard') + parser.add_argument('--no_setpoint_update', action='store_true', default=False, + help='disable setpoint update') # the following hyperparamters do not need to be tuned parser.add_argument('--init_mu4beta', type=float, default=0.001, diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index e043cdb93..92192fe3e 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -51,7 +51,7 @@ def __init__(self, trainer, **kwargs): self.count_found_operator = 0 self.count_search_mu = 0 ######################################## - self.set_point_controller = FbOptSetpointController() + self.set_point_controller = FbOptSetpointController(args=self.trainer.aconf) self.k_i_control = trainer.aconf.k_i_gain self.delta_epsilon_r = False # False here just used to decide if value first use or not # NOTE: this value will be set according to initial evaluation of neural network diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 900a0264e..a8f8b6bd5 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -25,12 +25,15 @@ class FbOptSetpointController(): """ update setpoint for mu """ - def __init__(self, state=None): + def __init__(self, state=None, args=None): """ kwargs is a dictionary with key the hyper-parameter name and its value """ if state is None: - state = SliderAnyComponent() + if args is not None and args.no_setpoint_update: + state = FixedSetpoint() + else: + state = SliderAnyComponent() self.transition_to(state) self.ma_epo_reg_loss = None self.state_epo_reg_loss = None @@ -86,6 +89,11 @@ def accept(self, controller): self.host = controller +class FixedSetpoint(FbOptSetpointControllerState): + def update_setpoint(self): + return False + + class SliderAllComponent(FbOptSetpointControllerState): """ concrete state pattern From a9f1fc8887d621d2d245cbe204e5552f7fe5b23e Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 2 Oct 2023 12:18:25 +0200 Subject: [PATCH 202/762] fix bug --- domainlab/algos/observers/b_obvisitor.py | 2 +- run_fbopt_dann.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index 497c71b85..75ec43b60 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -43,7 +43,7 @@ def update(self, epoch): if epoch % self.epo_te == 0: logger.debug("---- Training Domain: ") self.host_trainer.model.cal_perf_metric(self.loader_tr, self.device) - if self.loader_val is not None and self.str_msel == "val": + if self.loader_val is not None: logger.debug("---- Validation: ") self.metric_val = self.host_trainer.model.cal_perf_metric( self.loader_val, self.device) diff --git a/run_fbopt_dann.sh b/run_fbopt_dann.sh index 9382eab50..508d84a1e 100644 --- a/run_fbopt_dann.sh +++ b/run_fbopt_dann.sh @@ -1 +1 @@ -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --msel=loss_tr --msel_tr_loss=task +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --msel=loss_tr --msel_tr_loss=task --no_setpoint_update From 9042ff1fced82e92bff0df98911743dc5697112f Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 2 Oct 2023 14:50:03 +0200 Subject: [PATCH 203/762] remove ploss for model selection --- domainlab/algos/trainers/train_fbopt.py | 3 --- domainlab/arg_parser.py | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index e5bd37599..2b2d26dbb 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -137,9 +137,6 @@ def tr_epoch(self, epoch): self.epo_loss_tr = epo_reg_loss elif self.aconf.msel_tr_loss =="task": self.epo_loss_tr = epo_task_loss - elif self.aconf.msel_tr_loss == "p_loss": - epo_p_loss = self.eval_p_loss() - self.epo_loss_tr = epo_p_loss else: raise RuntimeError("msel_tr_loss set to be the wrong value") elif self.aconf.msel == "last" or self.aconf.msel == "val": diff --git a/domainlab/arg_parser.py b/domainlab/arg_parser.py index 43512f7cf..6812c0356 100644 --- a/domainlab/arg_parser.py +++ b/domainlab/arg_parser.py @@ -142,8 +142,8 @@ def mk_parser_main(): help='model selection for early stop: val, loss_tr, recon, the \ elbo and recon only make sense for vae models,\ will be ignored by other methods') - - parser.add_argument('--msel_tr_loss', choices=['reg', 'task', 'ploss'], default="task", + + parser.add_argument('--msel_tr_loss', choices=['reg', 'task'], default="task", help='model selection for tr loss') parser.add_argument('--aname', metavar="an", type=str, From 0fc35851af9bff720439a2f01aec6223bf17eae0 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 2 Oct 2023 14:52:07 +0200 Subject: [PATCH 204/762] . --- run_fbopt_pacs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_pacs.sh b/run_fbopt_pacs.sh index 73c1e61ab..81e7a1189 100644 --- a/run_fbopt_pacs.sh +++ b/run_fbopt_pacs.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=20 +python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=100 --es=100 From f063334b8b91178e6c7e66d500523949e5462426 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 2 Oct 2023 15:34:01 +0200 Subject: [PATCH 205/762] fix logger --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index a8f8b6bd5..fe72e4999 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -70,7 +70,7 @@ def observe(self, epo_reg_loss, epo_task_loss): if self.state_updater.update_setpoint(): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") self.setpoint4R = self.state_epo_reg_loss - logger.info("!!!!!set point updated to {self.setpoint4R}!") + logger.info(f"!!!!!set point updated to {self.setpoint4R}!") class FbOptSetpointControllerState(): From 4cec2c5a2377d7390bdc5f72acb2c6846af33698 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 2 Oct 2023 16:41:38 +0200 Subject: [PATCH 206/762] default to no update setpoing --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index fe72e4999..1361708d5 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -33,7 +33,7 @@ def __init__(self, state=None, args=None): if args is not None and args.no_setpoint_update: state = FixedSetpoint() else: - state = SliderAnyComponent() + state = DominateAnyComponent() self.transition_to(state) self.ma_epo_reg_loss = None self.state_epo_reg_loss = None From 12a52b5192f8ded27e6fdda92dea957131fb5154 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 3 Oct 2023 11:43:11 +0200 Subject: [PATCH 207/762] no logdir --- domainlab/algos/trainers/fbopt_alternate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 92192fe3e..4e43946ca 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -60,7 +60,8 @@ def __init__(self, trainer, **kwargs): if trainer.aconf.no_tensorboard: self.writer = StubSummaryWriter() else: - self.writer = SummaryWriter(log_dir="zoutput/runs", comment=os.environ.get('SLURM_JOB_ID', '')) + str_job_id = os.environ.get('SLURM_JOB_ID', '') + self.writer = SummaryWriter(comment=str_job_id) self.coeff_ma = trainer.aconf.coeff_ma self.epsilon_r = False From a8a42a5f2250e0d563fff16cb28d163ef958b1c9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 3 Oct 2023 16:23:29 +0200 Subject: [PATCH 208/762] use average loss as indicator --- domainlab/algos/trainers/train_fbopt.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py index 2b2d26dbb..90949ec53 100644 --- a/domainlab/algos/trainers/train_fbopt.py +++ b/domainlab/algos/trainers/train_fbopt.py @@ -14,6 +14,8 @@ from domainlab.algos.msels.c_msel_bang import MSelBang from domainlab.utils.logger import Logger +def list_divide(list_val, scalar): + return [ele/scalar for ele in list_val] class HyperSetter(): """ @@ -86,6 +88,7 @@ def eval_p_loss(self, dict4mu, dict_theta): temp_model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) temp_model.set_params(dict_theta) epo_p_loss = 0 # penalized loss + counter = 0.0 with torch.no_grad(): for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): tensor_x, vec_y, vec_d = \ @@ -93,7 +96,8 @@ def eval_p_loss(self, dict4mu, dict_theta): # sum will kill the dimension of the mini batch b_p_loss = temp_model.cal_loss(tensor_x, vec_y, vec_d).sum() epo_p_loss += b_p_loss - return epo_p_loss + counter += 1.0 + return epo_p_loss/counter def eval_r_loss(self): """ @@ -106,6 +110,7 @@ def eval_r_loss(self): # mock the model hyper-parameter to be from dict4mu epo_reg_loss = [] epo_task_loss = 0 + counter = 0.0 with torch.no_grad(): for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): tensor_x, vec_y, vec_d = \ @@ -123,7 +128,8 @@ def eval_r_loss(self): b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() # sum will kill the dimension of the mini batch epo_task_loss += b_task_loss - return epo_reg_loss, epo_task_loss + counter += 1.0 + return list_divide(epo_reg_loss, counter), epo_task_loss/counter def tr_epoch(self, epoch): """ From 5548031f001f340dc2eba4d68b33bc83bbe36b89 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 3 Oct 2023 17:02:14 +0200 Subject: [PATCH 209/762] mnist --- examples/benchmark/benchmark_fbopt_mnist.yaml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist.yaml b/examples/benchmark/benchmark_fbopt_mnist.yaml index 3f4f11d04..7bad30529 100644 --- a/examples/benchmark/benchmark_fbopt_mnist.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist.yaml @@ -16,11 +16,11 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 3 - es: 5 + epos: 100 + es: 100 bs: 64 nname: conv_bn_pool_2 - san_check: True + san_check: False exp_shoulder_clip: 10 mu_clip: 10_000 coeff_ma: 0.5 @@ -52,12 +52,3 @@ jigen_fbopt: shared: - ini_setpoint_ratio - k_i_gain - - es - -dann_fbopt: - aname: dann - trainer: fbopt - shared: - - ini_setpoint_ratio - - k_i_gain - - es From 9a6298e5869c05d001cb758761ea60da5384bb3f Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 10:09:12 +0200 Subject: [PATCH 210/762] direct jigen --- .../benchmark_pacs_resnet_grid_jigen.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml diff --git a/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml b/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml new file mode 100644 index 000000000..3c023c88a --- /dev/null +++ b/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml @@ -0,0 +1,58 @@ +# test benchmark config. + +mode: grid + +test_domains: + - sketch + +output_dir: zoutput/benchmarks/pacs_benchmark_grid + +startseed: 0 +endseed: 1 # currently included + + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 500 + es: 1 + bs: 32 + npath: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + san_check: False + + +Shared params: + gamma_reg: + min: 0.01 + max: 10 + step: 0.1 + distribution: loguniform + num: 3 + + +jigen: # name + aname: jigen + shared: + - gamma_reg + + hyperparameters: + # probability of permutating the tiles of an image, pperm = 0 -> pure classification + pperm: + min: 0.1 + max: 0.5 + step: 0.1 + distribution: uniform + num: 3 + + +dann: + aname: dann + shared: + - gamma_reg + + +erm: + aname: deepall From 7c789ff281c7f98fcbf5b82ec2f7dbf2227d9427 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 10:18:28 +0200 Subject: [PATCH 211/762] . --- .../benchmark/benchmark_pacs_resnet_grid_jigen.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml b/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml index 3c023c88a..216b8ef1d 100644 --- a/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml +++ b/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml @@ -41,18 +41,12 @@ jigen: # name hyperparameters: # probability of permutating the tiles of an image, pperm = 0 -> pure classification pperm: - min: 0.1 - max: 0.5 + min: 0.7 + max: 1 step: 0.1 distribution: uniform num: 3 -dann: - aname: dann - shared: - - gamma_reg - - erm: aname: deepall From 2b3cd2a0e4d3fcad54ec325d4b61b75a62566fa4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 13:33:43 +0200 Subject: [PATCH 212/762] init mu as hyperpara --- domainlab/algos/trainers/args_fbopt.py | 3 ++- domainlab/algos/trainers/fbopt_alternate.py | 4 ++-- run_fbopt.sh | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index b43a71ce2..cf962bfb2 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -30,9 +30,10 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') - # the following hyperparamters do not need to be tuned parser.add_argument('--init_mu4beta', type=float, default=0.001, help='initial beta for multiplication') + + # the following hyperparamters do not need to be tuned parser.add_argument('--beta_mu', type=float, default=1.1, help='how much to multiply mu each time') parser.add_argument('--delta_mu', type=float, default=None, diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 4e43946ca..bddee88ea 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -31,14 +31,14 @@ def __init__(self, trainer, **kwargs): kwargs is a dictionary with key the hyper-parameter name and its value """ self.trainer = trainer + self.init_mu = trainer.aconf.init_mu4beta self.mmu = kwargs - self.mmu = {key: 1.0 for key, val in self.mmu.items()} # FIXME: change this from user configuration + self.mmu = {key: self.init_mu for key, val in self.mmu.items()} self.ploss_old_theta_old_mu = None self.ploss_old_theta_new_mu = None self.ploss_new_theta_old_mu = None self.ploss_new_theta_new_mu = None self.delta_mu = trainer.aconf.delta_mu - self.init_mu = trainer.aconf.init_mu4beta # for exponential increase of mu, mu can not be starting from zero self.beta_mu = trainer.aconf.beta_mu self.dict_theta_bar = None diff --git a/run_fbopt.sh b/run_fbopt.sh index c56f209cc..ed7873414 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=100 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=100 --init_mu=1.0 From 3a6409cbd9642a0ab65887a2bbdac48e2ec18bfb Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 14:18:09 +0200 Subject: [PATCH 213/762] . --- run_fbopt_small_pacs.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 run_fbopt_small_pacs.sh diff --git a/run_fbopt_small_pacs.sh b/run_fbopt_small_pacs.sh new file mode 100644 index 000000000..d04656a1f --- /dev/null +++ b/run_fbopt_small_pacs.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py +python main_out.py --te_d=sketch --tpath=examples/tasks/demo_task_path_list_small.py --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=100 --init_mu=0.01 From 998d65330d3e2f3f2746e1ea8f76a34346db1278 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 14:45:38 +0200 Subject: [PATCH 214/762] good perform --- run_fbopt_mnist.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 run_fbopt_mnist.sh diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh new file mode 100644 index 000000000..0f98d2f71 --- /dev/null +++ b/run_fbopt_mnist.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=200 --es=100 --init_mu=0.5 From 89cc836e4bdfee329280f9e47cc9a41952e07223 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 15:09:11 +0200 Subject: [PATCH 215/762] mnist --- examples/benchmark/benchmark_fbopt_mnist.yaml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist.yaml b/examples/benchmark/benchmark_fbopt_mnist.yaml index 7bad30529..8c6c6a9a8 100644 --- a/examples/benchmark/benchmark_fbopt_mnist.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist.yaml @@ -16,7 +16,7 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 100 + epos: 500 es: 100 bs: 64 nname: conv_bn_pool_2 @@ -30,9 +30,9 @@ domainlab_args: Shared params: ini_setpoint_ratio: - min: 0.5 + min: 0.9 max: 0.99 - num: 5 + num: 3 step: 0.05 distribution: uniform @@ -43,6 +43,13 @@ Shared params: step: 0.0001 distribution: uniform + init_mu4beta: + min: 0.5 + max: 1.0 + num: 3 + step: 0.1 + distribution: uniform + # Test fbopt with different hyperparameter configurations jigen_fbopt: @@ -52,3 +59,7 @@ jigen_fbopt: shared: - ini_setpoint_ratio - k_i_gain + - init_mu4beta + +erm: + aname: deepall From 524acd85cc0bac8f047de3b86d30cb0880d37bce Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 15:14:46 +0200 Subject: [PATCH 216/762] . --- run_fbopt_dann.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_dann.sh b/run_fbopt_dann.sh index 508d84a1e..7897a6b74 100644 --- a/run_fbopt_dann.sh +++ b/run_fbopt_dann.sh @@ -1 +1 @@ -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=20 --msel=loss_tr --msel_tr_loss=task --no_setpoint_update +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=dann --trainer=fbopt --nname=alexnet --epos=200 --es=200 --no_setpoint_update From 66875a42ce2ad9d38d87cfad7ff9f511183d5811 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 15:41:34 +0200 Subject: [PATCH 217/762] . --- .../benchmark/benchmark_fbopt_mnist_dann.yaml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 examples/benchmark/benchmark_fbopt_mnist_dann.yaml diff --git a/examples/benchmark/benchmark_fbopt_mnist_dann.yaml b/examples/benchmark/benchmark_fbopt_mnist_dann.yaml new file mode 100644 index 000000000..7a643c751 --- /dev/null +++ b/examples/benchmark/benchmark_fbopt_mnist_dann.yaml @@ -0,0 +1,62 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt + +sampling_seed: 0 +startseed: 0 +endseed: 2 + +test_domains: + - 3 + - 0 + + +domainlab_args: + task: mnistcolor10 + tr_d: [1, 2] + dmem: False + lr: 0.001 + epos: 500 + es: 100 + bs: 64 + nname: conv_bn_pool_2 + san_check: False + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + no_tensorboard: False + + + +Shared params: + ini_setpoint_ratio: + min: 0.9 + max: 0.99 + num: 3 + step: 0.05 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + step: 0.0001 + distribution: uniform + + init_mu4beta: + min: 0.5 + max: 1.0 + num: 3 + step: 0.1 + distribution: uniform + +# Test fbopt with different hyperparameter configurations + +dann_fbopt: + aname: dann + trainer: fbopt + + shared: + - ini_setpoint_ratio + - k_i_gain + - init_mu4beta From 7d3ceff31d7b894cfa746dd2c22379bc50d1ffff Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 16:01:57 +0200 Subject: [PATCH 218/762] . --- examples/benchmark/benchmark_fbopt_mnist_dann.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_dann.yaml b/examples/benchmark/benchmark_fbopt_mnist_dann.yaml index 7a643c751..422586222 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_dann.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_dann.yaml @@ -44,10 +44,10 @@ Shared params: distribution: uniform init_mu4beta: - min: 0.5 - max: 1.0 - num: 3 - step: 0.1 + min: 0.01 + max: 1 + num: 10 + step: 0.01 distribution: uniform # Test fbopt with different hyperparameter configurations From 5d8292cb617e5b96e3b2324d8a99eda4e0a22baf Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 16:13:15 +0200 Subject: [PATCH 219/762] . --- examples/benchmark/benchmark_fbopt_mnist_dann.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_dann.yaml b/examples/benchmark/benchmark_fbopt_mnist_dann.yaml index 422586222..10e3bb6bd 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_dann.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_dann.yaml @@ -7,7 +7,6 @@ startseed: 0 endseed: 2 test_domains: - - 3 - 0 @@ -15,7 +14,7 @@ domainlab_args: task: mnistcolor10 tr_d: [1, 2] dmem: False - lr: 0.001 + lr: 0.0001 epos: 500 es: 100 bs: 64 @@ -45,7 +44,7 @@ Shared params: init_mu4beta: min: 0.01 - max: 1 + max: 1.0 num: 10 step: 0.01 distribution: uniform @@ -60,3 +59,6 @@ dann_fbopt: - ini_setpoint_ratio - k_i_gain - init_mu4beta + +erm: + aname: deepall From 204bfcc3b4102e88efd2b4c1332e6110d08a1ee1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 16:17:00 +0200 Subject: [PATCH 220/762] . --- examples/benchmark/benchmark_fbopt_mnist.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist.yaml b/examples/benchmark/benchmark_fbopt_mnist.yaml index 8c6c6a9a8..f8b5b8c7d 100644 --- a/examples/benchmark/benchmark_fbopt_mnist.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist.yaml @@ -22,7 +22,7 @@ domainlab_args: nname: conv_bn_pool_2 san_check: False exp_shoulder_clip: 10 - mu_clip: 10_000 + mu_clip: 10 coeff_ma: 0.5 no_tensorboard: False From 210af17b537fe29826d18155e6c2333d532f43b4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 4 Oct 2023 16:20:09 +0200 Subject: [PATCH 221/762] . --- examples/benchmark/benchmark_fbopt_mnist.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist.yaml b/examples/benchmark/benchmark_fbopt_mnist.yaml index f8b5b8c7d..aba8df618 100644 --- a/examples/benchmark/benchmark_fbopt_mnist.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist.yaml @@ -44,9 +44,9 @@ Shared params: distribution: uniform init_mu4beta: - min: 0.5 + min: 0.01 max: 1.0 - num: 3 + num: 8 step: 0.1 distribution: uniform From 31450b38cfbcc0639314d0aba0bc07b94554a0f9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 5 Oct 2023 10:31:59 +0200 Subject: [PATCH 222/762] diva benchmark mnist --- .../benchmark/benchmark_fbopt_mnist_diva.yaml | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 examples/benchmark/benchmark_fbopt_mnist_diva.yaml diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml new file mode 100644 index 000000000..5214717f2 --- /dev/null +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -0,0 +1,98 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt + +sampling_seed: 0 +startseed: 0 +endseed: 2 + +test_domains: + - 3 + - 0 + + +domainlab_args: + task: mnistcolor10 + tr_d: [1, 2] + dmem: False + lr: 0.001 + epos: 500 + es: 100 + bs: 64 + zx_dim: 0 + gamma_d: 1.0 + nname: conv_bn_pool_2 + nname_dom: conv_bn_pool_2 + nname_topic_distrib_img2topic: conv_bn_pool_2 + nname_encoder_sandwich_layer_img2h4zd: conv_bn_pool_2 + san_check: False + exp_shoulder_clip: 10 + mu_clip: 10 + coeff_ma: 0.5 + no_tensorboard: False + + + +Shared params: + ini_setpoint_ratio: + min: 0.9 + max: 0.99 + num: 3 + step: 0.05 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + step: 0.0001 + distribution: uniform + + init_mu4beta: + min: 0.01 + max: 1.0 + num: 5 + distribution: uniform + + gamma_y: + min: 1 + max: 1e6 + num: 3 + step: 100 + distribution: loguniform + + zy_dim: + min: 32 + max: 96 + num: 2 + step: 32 + distribution: uniform + datatype: int + + zd_dim: + min: 32 + max: 96 + num: 2 + step: 32 + distribution: uniform + datatype: int + + + +# Test fbopt with different hyperparameter configurations + +diva_fbopt: + aname: diva + trainer: fbopt + + shared: + - ini_setpoint_ratio + - k_i_gain + - init_mu4beta + - gamma_y + - zx_dim + - zy_dim + - zd_dim + +erm: + aname: deepall From 6a80edabe3697ad4c8780b96fb096e64041d36b8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 5 Oct 2023 11:17:20 +0200 Subject: [PATCH 223/762] . --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index 5214717f2..a01245b50 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -27,7 +27,7 @@ domainlab_args: nname_encoder_sandwich_layer_img2h4zd: conv_bn_pool_2 san_check: False exp_shoulder_clip: 10 - mu_clip: 10 + mu_clip: 1000_000 coeff_ma: 0.5 no_tensorboard: False From bd14244c7e123e02834641d21ea4db94ca60945b Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 5 Oct 2023 14:09:57 +0200 Subject: [PATCH 224/762] add mu_recon to adapt --- domainlab/models/model_diva.py | 1 + .../benchmark/benchmark_fbopt_mnist_diva.yaml | 36 +++---------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index d250b75ab..ea8c083d8 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -90,6 +90,7 @@ def hyper_update(self, epoch, fun_scheduler): self.beta_y = dict_rst["beta_y"] self.beta_x = dict_rst["beta_x"] self.gamma_d = dict_rst["gamma_d"] + self.mu_recon = dict_rst["mu_recon"] def hyper_init(self, functor_scheduler, trainer=None): """ diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index a01245b50..c532050a8 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -20,7 +20,10 @@ domainlab_args: es: 100 bs: 64 zx_dim: 0 + zy_dim: 32 + zd_dim: 32 gamma_d: 1.0 + gamma_y: 1.0 nname: conv_bn_pool_2 nname_dom: conv_bn_pool_2 nname_topic_distrib_img2topic: conv_bn_pool_2 @@ -38,45 +41,20 @@ Shared params: min: 0.9 max: 0.99 num: 3 - step: 0.05 distribution: uniform k_i_gain: min: 0.0001 max: 0.01 num: 2 - step: 0.0001 - distribution: uniform + distribution: loguniform init_mu4beta: - min: 0.01 + min: 0.0001 max: 1.0 num: 5 - distribution: uniform - - gamma_y: - min: 1 - max: 1e6 - num: 3 - step: 100 distribution: loguniform - zy_dim: - min: 32 - max: 96 - num: 2 - step: 32 - distribution: uniform - datatype: int - - zd_dim: - min: 32 - max: 96 - num: 2 - step: 32 - distribution: uniform - datatype: int - # Test fbopt with different hyperparameter configurations @@ -89,10 +67,6 @@ diva_fbopt: - ini_setpoint_ratio - k_i_gain - init_mu4beta - - gamma_y - - zx_dim - - zy_dim - - zd_dim erm: aname: deepall From 7711dbbb266e5dca9e0d13e169b14eda2a30acc5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 5 Oct 2023 14:19:01 +0200 Subject: [PATCH 225/762] recon into dynamic tune --- domainlab/models/model_diva.py | 7 +++---- domainlab/models/model_hduva.py | 11 +++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index ea8c083d8..752d5acf2 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -61,7 +61,7 @@ def __init__(self, chain_node_builder, zd_dim, zy_dim, zx_dim, list_str_y, list_d_tr, gamma_d, gamma_y, - beta_d, beta_x, beta_y, multiplier_recon=1.0): + beta_d, beta_x, beta_y, mu_recon=1.0): """ gamma: classification loss coefficient """ @@ -100,7 +100,7 @@ def hyper_init(self, functor_scheduler, trainer=None): """ return functor_scheduler( trainer=trainer, - mu_recon=self.multiplier_recon, + mu_recon=self.mu_recon, beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, @@ -140,7 +140,6 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): _, d_target = tensor_d.max(dim=1) lc_d = F.cross_entropy(logit_d, d_target, reduction="none") - return [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ - [self.multiplier_recon, -self.beta_d, -self.beta_x, -self.beta_y, -self.gamma_d] + [self.mu_recon, -self.beta_d, -self.beta_x, -self.beta_y, -self.gamma_d] return ModelDIVA diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index c57c4331b..6d311bc57 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -68,6 +68,7 @@ def hyper_update(self, epoch, fun_scheduler): self.beta_y = dict_rst["beta_y"] self.beta_x = dict_rst["beta_x"] self.beta_t = dict_rst["beta_t"] + self.mu_recon = dict_rst["mu_recon"] def hyper_init(self, functor_scheduler, trainer=None): """hyper_init. @@ -78,8 +79,10 @@ def hyper_init(self, functor_scheduler, trainer=None): # constructor signature is def __init__(self, **kwargs): return functor_scheduler( trainer=trainer, - mu_recon=self.multiplier_recon, - beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, + mu_recon=self.mu_recon, + beta_d=self.beta_d, + beta_y=self.beta_y, + beta_x=self.beta_x, beta_t=self.beta_t) @store_args @@ -92,7 +95,7 @@ def __init__(self, chain_node_builder, device, zx_dim=0, topic_dim=3, - multiplier_recon=1.0): + mu_recon=1.0): """ """ super().__init__(chain_node_builder, @@ -165,7 +168,7 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): z_concat = self.decoder.concat_ytdx(zy_q, topic_q, zd_q, zx_q) loss_recon_x, _, _ = self.decoder(z_concat, tensor_x) return [loss_recon_x, zx_p_minus_q, zy_p_minus_zy_q, zd_p_minus_q, topic_p_minus_q], \ - [self.multiplier_recon, -self.beta_x, -self.beta_y, -self.beta_d, -self.beta_t] + [self.mu_recon, -self.beta_x, -self.beta_y, -self.beta_d, -self.beta_t] def extract_semantic_features(self, tensor_x): """ From 59584b9d76266224334dea9c0c45258ca1fc05cd Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 5 Oct 2023 15:34:42 +0200 Subject: [PATCH 226/762] small early stop diva --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index c532050a8..8ae3784ac 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -7,7 +7,6 @@ startseed: 0 endseed: 2 test_domains: - - 3 - 0 @@ -17,7 +16,7 @@ domainlab_args: dmem: False lr: 0.001 epos: 500 - es: 100 + es: 5 bs: 64 zx_dim: 0 zy_dim: 32 From 8639fde8b5c7ad9bbf563c48cb04e002a73532d3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 5 Oct 2023 16:17:32 +0200 Subject: [PATCH 227/762] without inner trainer --- domainlab/algos/trainers/a_trainer.py | 3 + domainlab/algos/trainers/fbopt_alternate.py | 2 +- domainlab/algos/trainers/train_basic.py | 48 ++++++++--- .../algos/trainers/train_mu_controller.py | 81 +++++++++++++++++++ domainlab/algos/trainers/zoo_trainer.py | 3 +- domainlab/models/a_model.py | 7 +- 6 files changed, 128 insertions(+), 16 deletions(-) create mode 100644 domainlab/algos/trainers/train_mu_controller.py diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 9a48a742b..b937ff0ee 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -42,6 +42,9 @@ def __init__(self, successor_node=None): self.flag_update_hyper_per_epoch = None self.flag_update_hyper_per_batch = None self.epo_loss_tr = None + self.epo_reg_loss_tr = None + self.epo_task_loss_tr = None + self.counter_batch = None self.hyper_scheduler = None self.optimizer = None self.exp = None diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index bddee88ea..e2374cb4b 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -150,7 +150,7 @@ def search_mu(self, dict_theta=None, miter=None): acc_val = self.trainer.observer.metric_val["acc"] self.writer.add_scalar("acc_te", acc_te, miter) self.writer.add_scalar("acc_val", acc_val, miter) - self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) + # self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) return True def dict_clip(self, dict_base, clip_min=0.0001): # FIXME: set thsi as hyperparameter diff --git a/domainlab/algos/trainers/train_basic.py b/domainlab/algos/trainers/train_basic.py index efb3e2b1e..f63ca79c6 100644 --- a/domainlab/algos/trainers/train_basic.py +++ b/domainlab/algos/trainers/train_basic.py @@ -2,11 +2,16 @@ basic trainer """ import math +from operator import add from domainlab.algos.trainers.a_trainer import AbstractTrainer from domainlab.algos.trainers.a_trainer import mk_opt +def list_divide(list_val, scalar): + return [ele/scalar for ele in list_val] + + class TrainerBasic(AbstractTrainer): """ basic trainer @@ -19,24 +24,45 @@ def before_tr(self): def tr_epoch(self, epoch): self.model.train() + self.counter_batch = 0.0 self.epo_loss_tr = 0 + self.epo_reg_loss_tr = [0.0 for _ in range(10)] + self.epo_task_loss_tr = 0 for ind_batch, (tensor_x, vec_y, vec_d, *others) in enumerate(self.loader_tr): - self.before_batch(epoch, ind_batch) - tensor_x, vec_y, vec_d = \ - tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) - self.optimizer.zero_grad() - loss = self.model.cal_loss(tensor_x, vec_y, vec_d, others) - loss = loss.sum() - loss.backward() - self.optimizer.step() - self.epo_loss_tr += loss.detach().item() - self.after_batch(epoch, ind_batch) + self.tr_batch(tensor_x, vec_y, vec_d, others, ind_batch, epoch) + self.epo_loss_tr /= self.counter_batch + self.epo_task_loss_tr /= self.counter_batch + self.epo_reg_loss_tr = list_divide(self.epo_reg_loss_tr, self.counter_batch) assert self.epo_loss_tr is not None assert not math.isnan(self.epo_loss_tr) flag_stop = self.observer.update(epoch) # notify observer assert flag_stop is not None return flag_stop + def handle_r_loss(self, list_b_reg_loss): + list_b_reg_loss_sumed = [ele.sum().detach().item() for ele in list_b_reg_loss] + self.epo_reg_loss_tr = list(map(add, self.epo_reg_loss_tr, list_b_reg_loss_sumed)) + return list_b_reg_loss_sumed + + def tr_batch(self, tensor_x, vec_y, vec_d, others, ind_batch, epoch): + """ + different from self.train_batch(...), which is used for mldg, the current function + is used inside tr_epoch + """ + self.before_batch(epoch, ind_batch) + tensor_x, vec_y, vec_d = \ + tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) + self.optimizer.zero_grad() + loss, list_loss_reg, loss_task = self.model.cal_loss(tensor_x, vec_y, vec_d, others) + self.handle_r_loss(list_loss_reg) + loss = loss.sum() + loss.backward() + self.optimizer.step() + self.epo_loss_tr += loss.detach().item() + self.epo_task_loss_tr += loss_task.sum().detach().item() + self.after_batch(epoch, ind_batch) + self.counter_batch += 1 + def train_batch(self, tensor_x, vec_y, vec_d, others): """ use a temporary optimizer to update only the model upon a batch of data @@ -46,7 +72,7 @@ def train_batch(self, tensor_x, vec_y, vec_d, others): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) optimizer.zero_grad() - loss = self.model.cal_loss(tensor_x, vec_y, vec_d, others) + loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d, others) loss = loss.sum() loss.backward() optimizer.step() diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py new file mode 100644 index 000000000..dfe1cb2c4 --- /dev/null +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -0,0 +1,81 @@ +""" +update hyper-parameters during training +""" +from operator import add +import torch +from domainlab.algos.trainers.train_basic import TrainerBasic +from domainlab.algos.trainers.fbopt_alternate import HyperSchedulerFeedbackAlternave +from domainlab.utils.logger import Logger + + +def list_divide(list_val, scalar): + return [ele/scalar for ele in list_val] + + +class TrainerFbOpt(TrainerBasic): + """ + TrainerHyperScheduler + """ + def set_scheduler(self, scheduler): + """ + Args: + scheduler: The class name of the scheduler, the object corresponding to + this class name will be created inside model + """ + # model.hyper_init will register the hyper-parameters of the model to scheduler + self.hyper_scheduler = self.model.hyper_init(scheduler, trainer=self) + + def eval_r_loss(self): + """ + evaluate the regularization loss and ERM loss with respect ot parameter dict_theta + ERM loss on all available training data + # TODO: normalize loss via batchsize + """ + self.model.eval() + # mock the model hyper-parameter to be from dict4mu + epo_reg_loss = [] + epo_task_loss = 0 + counter = 0.0 + with torch.no_grad(): + for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): + tensor_x, vec_y, vec_d = \ + tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) + tuple_reg_loss = self.model.cal_reg_loss(tensor_x, vec_y, vec_d) + # NOTE: first [0] extract the loss, second [0] get the list + list_b_reg_loss = tuple_reg_loss[0] + list_b_reg_loss_sumed = [ele.sum().item() for ele in list_b_reg_loss] + if len(epo_reg_loss) == 0: + epo_reg_loss = list_b_reg_loss_sumed + else: + epo_reg_loss = list(map(add, epo_reg_loss, list_b_reg_loss_sumed)) + b_task_loss = self.model.cal_task_loss(tensor_x, vec_y).sum() + # sum will kill the dimension of the mini batch + epo_task_loss += b_task_loss + counter += 1.0 + return list_divide(epo_reg_loss, counter), epo_task_loss/counter + + def before_batch(self, epoch, ind_batch): + """ + if hyper-parameters should be updated per batch, then step + should be set to epoch*self.num_batches + ind_batch + """ + if self.flag_update_hyper_per_batch: + self.model.hyper_update(epoch*self.num_batches + ind_batch, self.hyper_scheduler) + return super().after_batch(epoch, ind_batch) + + def before_tr(self): + self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) + epo_reg_loss, epo_task_loss = self.eval_r_loss() + self.hyper_scheduler.set_setpoint( + [ele * self.aconf.ini_setpoint_ratio for ele in epo_reg_loss], epo_task_loss) + + def tr_epoch(self, epoch): + """ + update hyper-parameters only per epoch + """ + flag = super().tr_epoch(epoch) + self.hyper_scheduler.search_mu( + dict(self.model.named_parameters()), + miter=epoch) + self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) + return flag diff --git a/domainlab/algos/trainers/zoo_trainer.py b/domainlab/algos/trainers/zoo_trainer.py index e825ad75b..f564be0bf 100644 --- a/domainlab/algos/trainers/zoo_trainer.py +++ b/domainlab/algos/trainers/zoo_trainer.py @@ -6,7 +6,8 @@ from domainlab.algos.trainers.train_matchdg import TrainerMatchDG from domainlab.algos.trainers.train_mldg import TrainerMLDG from domainlab.algos.trainers.train_hyper_scheduler import TrainerHyperScheduler -from domainlab.algos.trainers.train_fbopt import TrainerFbOpt +# from domainlab.algos.trainers.train_fbopt import TrainerFbOpt +from domainlab.algos.trainers.train_mu_controller import TrainerFbOpt class TrainerChainNodeGetter(object): diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index 1c7179c3d..588782104 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -19,7 +19,7 @@ def set_params(self, dict_params): # but I dont know another method to set neural network weights without using load_state_dict # FIXME: dict_params lack some keys compared to self.state_dict(), why? self.load_state_dict(dict_params, strict=False) - + @property def metric4msel(self): """ @@ -40,8 +40,9 @@ def cal_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): """ list_loss, list_multiplier = self.cal_reg_loss(tensor_x, tensor_y, tensor_d, others) loss_reg = self.inner_product(list_loss, list_multiplier) - loss_task = self.multiplier4task_loss * self.cal_task_loss(tensor_x, tensor_y) - return loss_task + loss_reg + loss_task_alone = self.cal_task_loss(tensor_x, tensor_y) + loss_task = self.multiplier4task_loss * loss_task_alone + return loss_task + loss_reg, list_loss, loss_task_alone def inner_product(self, list_loss_scalar, list_multiplier): """ From ed2b42f18a577f641e427790d3b6e366fe3fecd3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 10:50:10 +0200 Subject: [PATCH 228/762] refine --- domainlab/algos/trainers/args_fbopt.py | 9 ++++-- domainlab/algos/trainers/fbopt.py | 2 +- domainlab/algos/trainers/fbopt_alternate.py | 31 +++++++++---------- .../algos/trainers/train_mu_controller.py | 7 +++-- examples/benchmark/benchmark_fbopt_mnist.yaml | 4 +-- .../benchmark/benchmark_fbopt_mnist_dann.yaml | 4 +-- .../benchmark/benchmark_fbopt_mnist_diva.yaml | 4 +-- 7 files changed, 33 insertions(+), 28 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index cf962bfb2..a84969efd 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -14,6 +14,12 @@ def add_args2parser_fbopt(parser): parser.add_argument('--mu_clip', type=float, default=1e4, help='maximum value of mu') + parser.add_argument('--mu_min', type=float, default=1e-6, + help='minimum value of mu') + + parser.add_argument('--mu_init', type=float, default=0.001, + help='initial beta for multiplication') + parser.add_argument('--coeff_ma', type=float, default=0.5, help='exponential moving average') @@ -30,9 +36,6 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') - parser.add_argument('--init_mu4beta', type=float, default=0.001, - help='initial beta for multiplication') - # the following hyperparamters do not need to be tuned parser.add_argument('--beta_mu', type=float, default=1.1, help='how much to multiply mu each time') diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py index 221926f11..d5c97b194 100644 --- a/domainlab/algos/trainers/fbopt.py +++ b/domainlab/algos/trainers/fbopt.py @@ -22,7 +22,7 @@ def __init__(self, trainer, **kwargs): self.ploss_new_theta_old_mu = None self.ploss_new_theta_new_mu = None self.delta_mu = trainer.aconf.delta_mu - self.init_mu = trainer.aconf.init_mu4beta + self.init_mu = trainer.aconf.mu_init # for exponential increase of mu, mu can not be starting from zero self.beta_mu = trainer.aconf.beta_mu self.dict_theta_bar = None diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index e2374cb4b..a7d795626 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -31,7 +31,8 @@ def __init__(self, trainer, **kwargs): kwargs is a dictionary with key the hyper-parameter name and its value """ self.trainer = trainer - self.init_mu = trainer.aconf.init_mu4beta + self.init_mu = trainer.aconf.mu_init + self.mu_min = trainer.aconf.mu_min self.mmu = kwargs self.mmu = {key: self.init_mu for key, val in self.mmu.items()} self.ploss_old_theta_old_mu = None @@ -97,16 +98,14 @@ def cal_delta4control(self, list1, list_setpoint): def cal_delta_integration(self, list_old, list_new, coeff): return [(1-coeff)*a + coeff*b for a, b in zip(list_old, list_new)] - def search_mu(self, dict_theta=None, miter=None): + def search_mu(self, epo_reg_loss, epo_task_loss, dict_theta=None, miter=None): """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value to see if the criteria is met $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-epsilon_R])$$ """ - epo_reg_loss, epos_task_loss = self.trainer.eval_r_loss() # FIXME: use dictionary to replace scalar representation - # delta_epsilon_r = epo_reg_loss - self.setpoint4R delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.get_setpoint4R()) # TODO: can be replaced by a controller if self.delta_epsilon_r is False: @@ -115,8 +114,8 @@ def search_mu(self, dict_theta=None, miter=None): # PI control. # self.delta_epsilon_r is the previous time step. # delta_epsilon_r is the current time step - # self.delta_epsilon_r = (1 - self.coeff_ma) * self.delta_epsilon_r + self.coeff_ma * delta_epsilon_r - self.delta_epsilon_r = self.cal_delta_integration(self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) + self.delta_epsilon_r = self.cal_delta_integration( + self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) # FIXME: here we can not sum up selta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary activation = [self.k_i_control * val for val in self.delta_epsilon_r] if self.activation_clip is not None: @@ -137,27 +136,27 @@ def search_mu(self, dict_theta=None, miter=None): f'reg/dyn{i}': reg_dyn, f'reg/setpoint{i}': reg_set, }, miter) - self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{i}', reg_dyn, epos_task_loss) + self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{i}', reg_dyn, epo_task_loss) - loss_penalized = epos_task_loss + torch.inner(torch.Tensor(list(self.mmu.values())), torch.Tensor(epo_reg_loss)) - self.writer.add_scalar('loss_penalized', loss_penalized, miter) - self.writer.add_scalar('task', epos_task_loss, miter) + epo_loss_tr = epo_task_loss + torch.inner( + torch.Tensor(list(self.mmu.values())), torch.Tensor(epo_reg_loss)) + self.writer.add_scalar('loss_penalized', epo_loss_tr, miter) + self.writer.add_scalar('task', epo_task_loss, miter) acc_te = 0 acc_val = 0 if miter > 1: acc_te = self.trainer.observer.metric_te["acc"] acc_val = self.trainer.observer.metric_val["acc"] - self.writer.add_scalar("acc_te", acc_te, miter) - self.writer.add_scalar("acc_val", acc_val, miter) - # self.dict_theta = self.trainer.opt_theta(self.mmu, dict(self.trainer.model.named_parameters())) - return True + self.writer.add_scalar("acc/te", acc_te, miter) + self.writer.add_scalar("acc/val", acc_val, miter) - def dict_clip(self, dict_base, clip_min=0.0001): # FIXME: set thsi as hyperparameter + def dict_clip(self, dict_base): """ clip each entry of the mu according to pre-set self.mu_clip """ - return {key: np.clip(val, a_min=clip_min, a_max=self.mu_clip) for key, val in dict_base.items()} + return {key: np.clip(val, a_min=self.mu_min, a_max=self.mu_clip) + for key, val in dict_base.items()} def dict_is_zero(self, dict_mu): """ diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index dfe1cb2c4..b16d10173 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -65,9 +65,10 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) - epo_reg_loss, epo_task_loss = self.eval_r_loss() + self.epo_reg_loss_tr, self.epo_task_loss_tr = self.eval_r_loss() self.hyper_scheduler.set_setpoint( - [ele * self.aconf.ini_setpoint_ratio for ele in epo_reg_loss], epo_task_loss) + [ele * self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], + self.epo_task_loss_tr) def tr_epoch(self, epoch): """ @@ -75,6 +76,8 @@ def tr_epoch(self, epoch): """ flag = super().tr_epoch(epoch) self.hyper_scheduler.search_mu( + self.epo_reg_loss_tr, + self.epo_task_loss_tr, dict(self.model.named_parameters()), miter=epoch) self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) diff --git a/examples/benchmark/benchmark_fbopt_mnist.yaml b/examples/benchmark/benchmark_fbopt_mnist.yaml index aba8df618..22e48df57 100644 --- a/examples/benchmark/benchmark_fbopt_mnist.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist.yaml @@ -43,7 +43,7 @@ Shared params: step: 0.0001 distribution: uniform - init_mu4beta: + mu_init: min: 0.01 max: 1.0 num: 8 @@ -59,7 +59,7 @@ jigen_fbopt: shared: - ini_setpoint_ratio - k_i_gain - - init_mu4beta + - mu_init erm: aname: deepall diff --git a/examples/benchmark/benchmark_fbopt_mnist_dann.yaml b/examples/benchmark/benchmark_fbopt_mnist_dann.yaml index 10e3bb6bd..d44ff429b 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_dann.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_dann.yaml @@ -42,7 +42,7 @@ Shared params: step: 0.0001 distribution: uniform - init_mu4beta: + mu_init: min: 0.01 max: 1.0 num: 10 @@ -58,7 +58,7 @@ dann_fbopt: shared: - ini_setpoint_ratio - k_i_gain - - init_mu4beta + - mu_init erm: aname: deepall diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index 8ae3784ac..bd040d4e7 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -48,7 +48,7 @@ Shared params: num: 2 distribution: loguniform - init_mu4beta: + mu_init: min: 0.0001 max: 1.0 num: 5 @@ -65,7 +65,7 @@ diva_fbopt: shared: - ini_setpoint_ratio - k_i_gain - - init_mu4beta + - mu_init erm: aname: deepall From c5c76c87782c6ffa3012785f6aa7f840536ccad1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 11:03:42 +0200 Subject: [PATCH 229/762] . --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index bd040d4e7..b8d5b4d4c 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -16,7 +16,7 @@ domainlab_args: dmem: False lr: 0.001 epos: 500 - es: 5 + es: 50 bs: 64 zx_dim: 0 zy_dim: 32 From 630f717e50ba96e4d570f1757ba51064fb45e7f3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 11:08:55 +0200 Subject: [PATCH 230/762] . --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4aaafb41b..46e2d0466 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ tests/__pycache__/ *.pyc .vscode/ .snakemake/ +data/pacs From 4b3e78cf9782ad3c46bfdf5bcdf6774ad2839a73 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 11:13:07 +0200 Subject: [PATCH 231/762] . --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 0f98d2f71..212244e1d 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=200 --es=100 --init_mu=0.5 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=200 --es=100 --mu_init=0.00001 From 10a44d76f6323d0d32720cdfea6c7e83533d7bf9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 11:34:19 +0200 Subject: [PATCH 232/762] fix #496 init mu --- domainlab/algos/trainers/train_mu_controller.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index b16d10173..dbbc49774 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -11,6 +11,16 @@ def list_divide(list_val, scalar): return [ele/scalar for ele in list_val] +class HyperSetter(): + """ + mock object to force hyper-parameter in the model + """ + def __init__(self, dict_hyper): + self.dict_hyper = dict_hyper + + def __call__(self, epoch=None): + return self.dict_hyper + class TrainerFbOpt(TrainerBasic): """ @@ -70,6 +80,8 @@ def before_tr(self): [ele * self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) + self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) + def tr_epoch(self, epoch): """ update hyper-parameters only per epoch From 32f4056f8bbf50ab0c1c6bc9182b03cc77628d22 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 11:58:28 +0200 Subject: [PATCH 233/762] no need for gamma_d --- domainlab/algos/trainers/train_mu_controller.py | 3 +-- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index dbbc49774..2d5825fef 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -75,13 +75,12 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) + self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) self.epo_reg_loss_tr, self.epo_task_loss_tr = self.eval_r_loss() self.hyper_scheduler.set_setpoint( [ele * self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) - self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) - def tr_epoch(self, epoch): """ update hyper-parameters only per epoch diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index b8d5b4d4c..445018669 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -21,7 +21,6 @@ domainlab_args: zx_dim: 0 zy_dim: 32 zd_dim: 32 - gamma_d: 1.0 gamma_y: 1.0 nname: conv_bn_pool_2 nname_dom: conv_bn_pool_2 From ce54f249c7db3ef85ef942d7b31e36efd566338f Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 13:47:35 +0200 Subject: [PATCH 234/762] . --- domainlab/algos/trainers/train_mu_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index 2d5825fef..b0c982e4a 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -70,6 +70,7 @@ def before_batch(self, epoch, ind_batch): should be set to epoch*self.num_batches + ind_batch """ if self.flag_update_hyper_per_batch: + # NOTE: if not update per_batch, then not updated self.model.hyper_update(epoch*self.num_batches + ind_batch, self.hyper_scheduler) return super().after_batch(epoch, ind_batch) From c29d52ca402eb928bcf3cf7e9ca8398ad2ebb7c7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 15:20:50 +0200 Subject: [PATCH 235/762] add pacs jigen --- .../benchmark/benchmark_fbopt_pacs_jigen.yaml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 examples/benchmark/benchmark_fbopt_pacs_jigen.yaml diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml new file mode 100644 index 000000000..00bf6db71 --- /dev/null +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -0,0 +1,62 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full + +sampling_seed: 0 + +startseed: 0 +endseed: 1 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 20 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + + + +Shared params: + ini_setpoint_ratio: + min: 0.9 + max: 1.0 + num: 3 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: loguniform + + mu_init: + min: 0.001 + max: 1.0 + num: 3 + distribution: loguniform + +# Test fbopt with different hyperparameter configurations + +jigen_fbopt: + aname: jigen + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain + - mu_init From 1def90c228ad3098a304161b192ecdcbd978b471 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 15:32:38 +0200 Subject: [PATCH 236/762] . --- examples/benchmark/benchmark_fbopt_pacs_jigen.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml index 00bf6db71..164eef1ea 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -46,9 +46,9 @@ Shared params: distribution: loguniform mu_init: - min: 0.001 + min: 0.00001 max: 1.0 - num: 3 + num: 4 distribution: loguniform # Test fbopt with different hyperparameter configurations From c7d07d5e6b55a57532b71af0529d272bc128545e Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 15:41:46 +0200 Subject: [PATCH 237/762] . --- .../benchmark/benchmark_fbopt_pacs_jigen.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml index 164eef1ea..2caaf3241 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 20 + es: 5 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py @@ -28,17 +28,11 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 - + init_setpoint_ratio: 0.99 Shared params: - ini_setpoint_ratio: - min: 0.9 - max: 1.0 - num: 3 - distribution: uniform - k_i_gain: min: 0.0001 max: 0.01 @@ -51,12 +45,18 @@ Shared params: num: 4 distribution: loguniform + pperm: + min: 0.1 + max: 0.9 + num: 3 + distribution: uniform + # Test fbopt with different hyperparameter configurations jigen_fbopt: aname: jigen trainer: fbopt shared: - - ini_setpoint_ratio - k_i_gain - mu_init + - pperm From 73a666998b0fa4771eec1eaea4ab8bed23416851 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 15:46:07 +0200 Subject: [PATCH 238/762] working --- examples/benchmark/benchmark_fbopt_pacs_jigen.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml index 2caaf3241..2ee334078 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -28,15 +28,13 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 - init_setpoint_ratio: 0.99 - Shared params: k_i_gain: min: 0.0001 max: 0.01 - num: 2 + num: 3 distribution: loguniform mu_init: @@ -55,6 +53,7 @@ Shared params: jigen_fbopt: aname: jigen + init_setpoint_ratio: 0.99 trainer: fbopt shared: - k_i_gain From a07a16216a7e3c705be667d83cfbef406a6ec1d9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 16:19:14 +0200 Subject: [PATCH 239/762] jigen mnist --- ...nchmark_fbopt_mnist.yaml => benchmark_fbopt_mnist_jigen.yaml} | 1 - 1 file changed, 1 deletion(-) rename examples/benchmark/{benchmark_fbopt_mnist.yaml => benchmark_fbopt_mnist_jigen.yaml} (99%) diff --git a/examples/benchmark/benchmark_fbopt_mnist.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml similarity index 99% rename from examples/benchmark/benchmark_fbopt_mnist.yaml rename to examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index 22e48df57..ede8fd4ca 100644 --- a/examples/benchmark/benchmark_fbopt_mnist.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -7,7 +7,6 @@ startseed: 0 endseed: 2 test_domains: - - 3 - 0 From 1b7d941399bc5ca5fccd7151e41e758008ddf6d6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 16:24:58 +0200 Subject: [PATCH 240/762] no torch requirents --- requirements_notorch.txt | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 requirements_notorch.txt diff --git a/requirements_notorch.txt b/requirements_notorch.txt new file mode 100644 index 000000000..ba23911a7 --- /dev/null +++ b/requirements_notorch.txt @@ -0,0 +1,79 @@ +appdirs==1.4.4 ; python_version >= "3.9" and python_version < "4.0" +attrs==23.1.0 ; python_version >= "3.9" and python_version < "4.0" +beautifulsoup4==4.12.2 ; python_version >= "3.9" and python_version < "4.0" +certifi==2023.7.22 ; python_version >= "3.9" and python_version < "4.0" +charset-normalizer==3.2.0 ; python_version >= "3.9" and python_version < "4.0" +colorama==0.4.6 ; python_version >= "3.9" and python_version < "4.0" and platform_system == "Windows" +configargparse==1.7 ; python_version >= "3.9" and python_version < "4.0" +connection-pool==0.0.3 ; python_version >= "3.9" and python_version < "4.0" +contourpy==1.1.0 ; python_version >= "3.9" and python_version < "4.0" +cycler==0.11.0 ; python_version >= "3.9" and python_version < "4.0" +datrie==0.8.2 ; python_version >= "3.9" and python_version < "4.0" +docutils==0.20.1 ; python_version >= "3.9" and python_version < "4.0" +dpath==2.1.6 ; python_version >= "3.9" and python_version < "4.0" +fastjsonschema==2.18.0 ; python_version >= "3.9" and python_version < "4.0" +filelock==3.12.2 ; python_version >= "3.9" and python_version < "4.0" +fonttools==4.42.0 ; python_version >= "3.9" and python_version < "4.0" +gdown==4.7.1 ; python_version >= "3.9" and python_version < "4.0" +gitdb==4.0.10 ; python_version >= "3.9" and python_version < "4.0" +gitpython==3.1.32 ; python_version >= "3.9" and python_version < "4.0" +humanfriendly==10.0 ; python_version >= "3.9" and python_version < "4.0" +idna==3.4 ; python_version >= "3.9" and python_version < "4.0" +importlib-resources==6.0.1 ; python_version >= "3.9" and python_version < "3.10" +jinja2==3.1.2 ; python_version >= "3.9" and python_version < "4.0" +joblib==1.3.2 ; python_version >= "3.9" and python_version < "4.0" +jsonschema-specifications==2023.7.1 ; python_version >= "3.9" and python_version < "4.0" +jsonschema==4.19.0 ; python_version >= "3.9" and python_version < "4.0" +jupyter-core==5.3.1 ; python_version >= "3.9" and python_version < "4.0" +kiwisolver==1.4.4 ; python_version >= "3.9" and python_version < "4.0" +markdown-it-py==3.0.0 ; python_version >= "3.9" and python_version < "4.0" +markupsafe==2.1.3 ; python_version >= "3.9" and python_version < "4.0" +matplotlib==3.7.2 ; python_version >= "3.9" and python_version < "4.0" +mdurl==0.1.2 ; python_version >= "3.9" and python_version < "4.0" +nbformat==5.9.2 ; python_version >= "3.9" and python_version < "4.0" +numpy==1.25.2 ; python_version < "4.0" and python_version >= "3.9" +packaging==23.1 ; python_version >= "3.9" and python_version < "4.0" +pandas==1.5.3 ; python_version >= "3.9" and python_version < "4.0" +pillow==9.5.0 ; python_version >= "3.9" and python_version < "4.0" +plac==1.3.5 ; python_version >= "3.9" and python_version < "4.0" +platformdirs==3.10.0 ; python_version >= "3.9" and python_version < "4.0" +psutil==5.9.5 ; python_version >= "3.9" and python_version < "4.0" +pulp==2.7.0 ; python_version >= "3.9" and python_version < "4.0" +pygments==2.16.1 ; python_version >= "3.9" and python_version < "4.0" +pyparsing==3.0.9 ; python_version >= "3.9" and python_version < "4.0" +pyreadline3==3.4.1 ; sys_platform == "win32" and python_version >= "3.9" and python_version < "4.0" +pysocks==1.7.1 ; python_version >= "3.9" and python_version < "4.0" +python-dateutil==2.8.2 ; python_version >= "3.9" and python_version < "4.0" +pytz==2023.3 ; python_version >= "3.9" and python_version < "4.0" +pywin32==306 ; sys_platform == "win32" and platform_python_implementation != "PyPy" and python_version >= "3.9" and python_version < "4.0" +pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "4.0" +referencing==0.30.2 ; python_version >= "3.9" and python_version < "4.0" +requests==2.31.0 ; python_version >= "3.9" and python_version < "4.0" +requests[socks]==2.31.0 ; python_version >= "3.9" and python_version < "4.0" +reretry==0.11.8 ; python_version >= "3.9" and python_version < "4.0" +rich==13.5.2 ; python_version >= "3.9" and python_version < "4.0" +rpds-py==0.9.2 ; python_version >= "3.9" and python_version < "4.0" +scikit-learn==1.3.0 ; python_version >= "3.9" and python_version < "4.0" +scipy==1.9.3 ; python_version >= "3.9" and python_version < "4.0" +seaborn==0.12.2 ; python_version >= "3.9" and python_version < "4.0" +setuptools-scm==7.1.0 ; python_version >= "3.9" and python_version < "4.0" +setuptools==68.0.0 ; python_version >= "3.9" and python_version < "4.0" +six==1.16.0 ; python_version >= "3.9" and python_version < "4.0" +smart-open==6.3.0 ; python_version >= "3.9" and python_version < "4.0" +smmap==5.0.0 ; python_version >= "3.9" and python_version < "4.0" +snakemake==7.21.0 ; python_version >= "3.9" and python_version < "4.0" +soupsieve==2.4.1 ; python_version >= "3.9" and python_version < "4.0" +stopit==1.1.2 ; python_version >= "3.9" and python_version < "4.0" +tabulate==0.9.0 ; python_version >= "3.9" and python_version < "4.0" +threadpoolctl==3.2.0 ; python_version >= "3.9" and python_version < "4.0" +throttler==1.2.2 ; python_version >= "3.9" and python_version < "4.0" +tomli==2.0.1 ; python_version >= "3.9" and python_version < "3.11" +toposort==1.10 ; python_version >= "3.9" and python_version < "4.0" +tqdm==4.66.1 ; python_version >= "3.9" and python_version < "4.0" +tensorboard==2.14.0 ; python_version >= "3.9" and python_version < "4.0" +traitlets==5.9.0 ; python_version >= "3.9" and python_version < "4.0" +typing-extensions==4.7.1 ; python_version >= "3.9" and python_version < "4.0" +urllib3==2.0.4 ; python_version >= "3.9" and python_version < "4.0" +wrapt==1.15.0 ; python_version >= "3.9" and python_version < "4.0" +yte==1.5.1 ; python_version >= "3.9" and python_version < "4.0" +zipp==3.16.2 ; python_version >= "3.9" and python_version < "3.10" From c572c8e914ae02adccce5844bff6ab3801906a72 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 16:52:24 +0200 Subject: [PATCH 241/762] diva adapt mu_init range --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index 445018669..bb8344c51 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -48,7 +48,7 @@ Shared params: distribution: loguniform mu_init: - min: 0.0001 + min: 0.01 max: 1.0 num: 5 distribution: loguniform From c81165f854f1c8568816f6a845415fb24e2a2141 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 6 Oct 2023 17:05:29 +0200 Subject: [PATCH 242/762] pacs diva --- .../benchmark/benchmark_fbopt_pacs_diva.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 examples/benchmark/benchmark_fbopt_pacs_diva.yaml diff --git a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml new file mode 100644 index 000000000..23b5d425a --- /dev/null +++ b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml @@ -0,0 +1,64 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 10 + bs: 64 + san_check: True + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + + + +Shared params: + ini_setpoint_ratio: + min: 0.9 + max: 0.99 + num: 3 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.1 + num: 3 + distribution: uniform + + mu_init: + min: 0.0001 + max: 1.0 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations + +diva_fbopt: + aname: diva + trainer: fbopt + shared: + - ini_setpoint_ratio + - k_i_gain + - mu_init From 4572d328f0f538749633e94ac60b88c051881fbc Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 7 Oct 2023 09:18:42 +0200 Subject: [PATCH 243/762] Update benchmark_fbopt_mnist_diva.yaml --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index bb8344c51..f705f4da1 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -49,7 +49,7 @@ Shared params: mu_init: min: 0.01 - max: 1.0 + max: 0.05 num: 5 distribution: loguniform From 9491f8dfbd7f8f6888ad10c71d34d0316b8d44a4 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 7 Oct 2023 09:25:28 +0200 Subject: [PATCH 244/762] Update benchmark_fbopt_mnist_jigen.yaml --- examples/benchmark/benchmark_fbopt_mnist_jigen.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index ede8fd4ca..3df4dd619 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -43,8 +43,8 @@ Shared params: distribution: uniform mu_init: - min: 0.01 - max: 1.0 + min: 0.5 + max: 0.7 num: 8 step: 0.1 distribution: uniform From 4144aa1444fdb508627b389394ee9cc27dc6dccc Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 7 Oct 2023 12:38:17 +0200 Subject: [PATCH 245/762] Update benchmark_fbopt_pacs_diva.yaml --- examples/benchmark/benchmark_fbopt_pacs_diva.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml index 23b5d425a..68d9d55e2 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml @@ -58,6 +58,7 @@ Shared params: diva_fbopt: aname: diva trainer: fbopt + gamma_y: 1.0 shared: - ini_setpoint_ratio - k_i_gain From 997633dadeefa9eaac244c29c4bda5ac8c2eda2e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 7 Oct 2023 12:45:48 +0200 Subject: [PATCH 246/762] Update a_model_classif.py --- domainlab/models/a_model_classif.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/models/a_model_classif.py b/domainlab/models/a_model_classif.py index a21d79bdb..9daacfa02 100644 --- a/domainlab/models/a_model_classif.py +++ b/domainlab/models/a_model_classif.py @@ -197,4 +197,4 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): """ for ERM to adapt to the interface of other regularized learners """ - return torch.Tensor([0]), torch.Tensor([0]) + return [torch.Tensor([0])], [0] From 2c5309e0f918617c2317ab4d2618039eeddfaeeb Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 7 Oct 2023 12:46:57 +0200 Subject: [PATCH 247/762] Update demo_custom_model.py --- examples/models/demo_custom_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/models/demo_custom_model.py b/examples/models/demo_custom_model.py index 4d545c517..515d9457b 100644 --- a/examples/models/demo_custom_model.py +++ b/examples/models/demo_custom_model.py @@ -42,7 +42,7 @@ def cal_loss(self, tensor_x, tensor_y, tensor_d, others=None): _, y_target = tensor_y.max(dim=1) lc_y = F.cross_entropy(logit_y, y_target, reduction="none") # regularization loss is zero - return lc_y, torch.Tensor([0]), lc_y + return lc_y, [torch.Tensor([0])], lc_y def get_node_na(): From 060b2689fb79af9724cc8a6a9eedcfb703ecaea6 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 8 Oct 2023 15:06:03 +0200 Subject: [PATCH 248/762] Update benchmark_fbopt_mnist_jigen.yaml --- .../benchmark_fbopt_mnist_jigen.yaml | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index 3df4dd619..26f814c90 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -29,10 +29,9 @@ domainlab_args: Shared params: ini_setpoint_ratio: - min: 0.9 + min: 0.95 max: 0.99 - num: 3 - step: 0.05 + num: 2 distribution: uniform k_i_gain: @@ -43,15 +42,14 @@ Shared params: distribution: uniform mu_init: - min: 0.5 - max: 0.7 - num: 8 - step: 0.1 - distribution: uniform + min: 0.001 + max: 0.1 + num: 3 + distribution: loguniform # Test fbopt with different hyperparameter configurations -jigen_fbopt: +jigen_feedback: aname: jigen trainer: fbopt @@ -59,6 +57,10 @@ jigen_fbopt: - ini_setpoint_ratio - k_i_gain - mu_init - + +jigen_feedforward: + aname: jigen + trainer: fbopt + erm: aname: deepall From 775b20a56dbb47c3dec324130acfec6bf78cd296 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 8 Oct 2023 15:07:00 +0200 Subject: [PATCH 249/762] Update benchmark_fbopt_mnist_jigen.yaml --- examples/benchmark/benchmark_fbopt_mnist_jigen.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index 26f814c90..c0f3e25e5 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -47,6 +47,12 @@ Shared params: num: 3 distribution: loguniform + pperm: + min: 0.1 + max: 0.9 + num: 3 + distribution: uniform + # Test fbopt with different hyperparameter configurations jigen_feedback: @@ -57,10 +63,13 @@ jigen_feedback: - ini_setpoint_ratio - k_i_gain - mu_init + - pperm jigen_feedforward: aname: jigen trainer: fbopt + shared: + - pperm erm: aname: deepall From 609cc8377363db4b6fa1a76fcc455525a3a17efb Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 8 Oct 2023 15:27:48 +0200 Subject: [PATCH 250/762] update snamkemak --- requirements_notorch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_notorch.txt b/requirements_notorch.txt index ba23911a7..5aec65167 100644 --- a/requirements_notorch.txt +++ b/requirements_notorch.txt @@ -61,7 +61,7 @@ setuptools==68.0.0 ; python_version >= "3.9" and python_version < "4.0" six==1.16.0 ; python_version >= "3.9" and python_version < "4.0" smart-open==6.3.0 ; python_version >= "3.9" and python_version < "4.0" smmap==5.0.0 ; python_version >= "3.9" and python_version < "4.0" -snakemake==7.21.0 ; python_version >= "3.9" and python_version < "4.0" +snakemake==7.32.4 ; python_version >= "3.9" and python_version < "4.0" soupsieve==2.4.1 ; python_version >= "3.9" and python_version < "4.0" stopit==1.1.2 ; python_version >= "3.9" and python_version < "4.0" tabulate==0.9.0 ; python_version >= "3.9" and python_version < "4.0" From e755663b17daa04655783b85c1164c70d49fbfd3 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 8 Oct 2023 15:33:10 +0200 Subject: [PATCH 251/762] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4e0d4d0d..2c5b88c92 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ then ``` conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge conda install torchmetric==0.10.3 -pip install -r requirements.txt +pip install -r requirements_notorch.txt conda install tensorboard ``` From 3f448102e5dd33d5cace41c8609d6e42eb8a248c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 8 Oct 2023 16:06:25 +0200 Subject: [PATCH 252/762] Update fbopt_setpoint_ada.py --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 1361708d5..bc9e43cb8 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -4,7 +4,12 @@ import torch from domainlab.utils.logger import Logger +def list_add(list1, list2): + return [a + b for a, b in zip(list1, list2)] +def list_multiply(list1, coeff): + return [ele * coeff for ele in list1] + def is_less_list_any(list1, list2): """ judge if one list is less than the other @@ -36,9 +41,10 @@ def __init__(self, state=None, args=None): state = DominateAnyComponent() self.transition_to(state) self.ma_epo_reg_loss = None - self.state_epo_reg_loss = None self.coeff_ma = 0.5 # FIXME - self.state_task_loss = None + self.state_task_loss = 0.0 + self.state_epo_reg_loss = 0.0 + self.coeff_ma_output = 0.9 # FIXME # initial value will be set via trainer self.setpoint4R = None self.setpoint4ell = None @@ -65,7 +71,7 @@ def observe(self, epo_reg_loss, epo_task_loss): read current epo_reg_loss continuously FIXME: setpoint should also be able to be eliviated """ - self.state_epo_reg_loss = epo_reg_loss + self.state_epo_reg_loss = list_add(list_multiply(epo_reg_loss, self.coeff_ma_output), list_multiply(self.state_epo_reg_loss, 1 - self.coeff_ma_output)) self.state_task_loss = epo_task_loss if self.state_updater.update_setpoint(): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") From 1276cd92cc7c74cebf83e358f3ba871c8f588982 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 8 Oct 2023 17:15:00 +0200 Subject: [PATCH 253/762] Update fbopt_setpoint_ada.py --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index bc9e43cb8..6660e9a1d 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -43,7 +43,7 @@ def __init__(self, state=None, args=None): self.ma_epo_reg_loss = None self.coeff_ma = 0.5 # FIXME self.state_task_loss = 0.0 - self.state_epo_reg_loss = 0.0 + self.state_epo_reg_loss = [0.0 for _ in range(10)] # FIXME self.coeff_ma_output = 0.9 # FIXME # initial value will be set via trainer self.setpoint4R = None From 3d08ba3b09259e44b92ea73817a8e069fb9e46f4 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 8 Oct 2023 19:12:41 +0200 Subject: [PATCH 254/762] Update fbopt_setpoint_ada.py --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 6660e9a1d..e7dede900 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -44,7 +44,7 @@ def __init__(self, state=None, args=None): self.coeff_ma = 0.5 # FIXME self.state_task_loss = 0.0 self.state_epo_reg_loss = [0.0 for _ in range(10)] # FIXME - self.coeff_ma_output = 0.9 # FIXME + self.coeff_ma_output = args.coeff_ma_output_state # initial value will be set via trainer self.setpoint4R = None self.setpoint4ell = None From 6d11c7b16b5d117bea256398d953cf40510c4604 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 8 Oct 2023 19:14:04 +0200 Subject: [PATCH 255/762] Update args_fbopt.py --- domainlab/algos/trainers/args_fbopt.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index a84969efd..2d05159a6 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -22,6 +22,10 @@ def add_args2parser_fbopt(parser): parser.add_argument('--coeff_ma', type=float, default=0.5, help='exponential moving average') + + parser.add_argument('--coeff_ma_output_state', type=float, default=0.9, + help='setpoint output as state exponential moving average') + parser.add_argument('--exp_shoulder_clip', type=float, default=10, help='clip before exponential operation') From 33b34e2337f8ff9caa7aa697b1158892abf80338 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 10:11:20 +0200 Subject: [PATCH 256/762] pacs mu_init for diva --- examples/benchmark/benchmark_fbopt_pacs_diva.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml index 68d9d55e2..8c128206e 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml @@ -47,7 +47,7 @@ Shared params: mu_init: min: 0.0001 - max: 1.0 + max: 0.001 num: 3 distribution: loguniform From 72074dce6a539ab28d6ef244d7ab46d1ecb6d404 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 10:29:43 +0200 Subject: [PATCH 257/762] jigen 3 algo --- .../benchmark/benchmark_fbopt_pacs_jigen.yaml | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml index 2ee334078..c96d1704b 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full sampling_seed: 0 startseed: 0 -endseed: 1 +endseed: 2 test_domains: - sketch @@ -28,6 +28,7 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 + pperm: 0.5 Shared params: @@ -39,7 +40,7 @@ Shared params: mu_init: min: 0.00001 - max: 1.0 + max: 0.001 num: 4 distribution: loguniform @@ -49,6 +50,12 @@ Shared params: num: 3 distribution: uniform + gamma_reg: + min: 0.01 + max: 1000 + num: 10 + distribution: loguniform + # Test fbopt with different hyperparameter configurations jigen_fbopt: @@ -58,4 +65,15 @@ jigen_fbopt: shared: - k_i_gain - mu_init - - pperm + +jigen_feedforward: + aname: jigen + trainer: hyperscheduler + shared: + - gamma_reg + +jigen_fixed_penalty: + aname: jigen + trainer: basic + shared: + - gamma_reg From 9253f8c373e6c2c2aa14e324e6a94a610be6e0d4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 10:32:57 +0200 Subject: [PATCH 258/762] . --- .../benchmark_fbopt_mnist_jigen.yaml | 20 ++++++++++++++++--- .../benchmark/benchmark_fbopt_pacs_jigen.yaml | 3 +++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index c0f3e25e5..d371a8129 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -53,6 +53,14 @@ Shared params: num: 3 distribution: uniform + gamma_reg: + min: 0.01 + max: 1000 + num: 10 + distribution: loguniform + + + # Test fbopt with different hyperparameter configurations jigen_feedback: @@ -67,9 +75,15 @@ jigen_feedback: jigen_feedforward: aname: jigen - trainer: fbopt + trainer: hyperscheduler shared: - - pperm - + - gamma_reg + +jigen_fixed_penalty: + aname: jigen + trainer: basic + shared: + - gamma_reg + erm: aname: deepall diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml index c96d1704b..953d47427 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -77,3 +77,6 @@ jigen_fixed_penalty: trainer: basic shared: - gamma_reg + +erm: + aname: deepall From 2400fed42f5ee84fa026dc9c493fa0c85d33597c Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 10:51:39 +0200 Subject: [PATCH 259/762] mnist jigen ready --- examples/benchmark/benchmark_fbopt_mnist_jigen.yaml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index d371a8129..7157270b9 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -24,6 +24,7 @@ domainlab_args: mu_clip: 10 coeff_ma: 0.5 no_tensorboard: False + pperm: 0.5 @@ -42,17 +43,11 @@ Shared params: distribution: uniform mu_init: - min: 0.001 - max: 0.1 + min: 0.00001 + max: 0.0001 num: 3 distribution: loguniform - pperm: - min: 0.1 - max: 0.9 - num: 3 - distribution: uniform - gamma_reg: min: 0.01 max: 1000 From 26c365884c94b7ca47e5bd591729bee4673f0ffa Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 11:31:35 +0200 Subject: [PATCH 260/762] . --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 212244e1d..86940605f 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=200 --es=100 --mu_init=0.00001 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=500 --es=50 --mu_init=0.00001 From c496add52e3e257f083591820158406f194d48e9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 11:33:19 +0200 Subject: [PATCH 261/762] . --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 212244e1d..86940605f 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=200 --es=100 --mu_init=0.00001 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=500 --es=50 --mu_init=0.00001 From 643abde7d0463a5f82571d8b9942231c575b444c Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 13:56:41 +0200 Subject: [PATCH 262/762] ma 0.5 --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 86940605f..53325386b 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=500 --es=50 --mu_init=0.00001 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=500 --es=50 --mu_init=0.00001 --coeff_ma_output_state=0.5 From 688f5de23eae6e90c633487deab7768c2fc59ad3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 13:59:00 +0200 Subject: [PATCH 263/762] . --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 53325386b..ea43bf77e 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=500 --es=50 --mu_init=0.00001 --coeff_ma_output_state=0.5 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_output_state=0.5 From ce7a9c74102ca85690c1d073a7731f6e1717aa63 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 14:00:19 +0200 Subject: [PATCH 264/762] . --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 86940605f..55434f380 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=500 --es=50 --mu_init=0.00001 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 From bd65d15f3c54cec68801209f3618da5fa9c90225 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 14:40:06 +0200 Subject: [PATCH 265/762] different diva --- domainlab/algos/builder_diva.py | 2 +- domainlab/algos/trainers/args_fbopt.py | 3 + domainlab/algos/trainers/fbopt_alternate.py | 5 +- .../algos/trainers/train_mu_controller.py | 12 ++- domainlab/models/model_diva.py | 75 +++++++++++++++++-- 5 files changed, 82 insertions(+), 15 deletions(-) diff --git a/domainlab/algos/builder_diva.py b/domainlab/algos/builder_diva.py index d13de99d8..e3e5256cd 100644 --- a/domainlab/algos/builder_diva.py +++ b/domainlab/algos/builder_diva.py @@ -35,7 +35,7 @@ def init_business(self, exp): request = RequestVAEBuilderCHW( task.isize.c, task.isize.h, task.isize.w, args) node = VAEChainNodeGetter(request)() - model = mk_diva()(node, + model = mk_diva(str_mu=args.str_mu)(node, zd_dim=args.zd_dim, zy_dim=args.zy_dim, zx_dim=args.zx_dim, diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index a84969efd..c144f3d58 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -36,6 +36,9 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') + parser.add_argument('--str_mu', type=str, default="default", help='which penalty to tune') + + # the following hyperparamters do not need to be tuned parser.add_argument('--beta_mu', type=float, default=1.1, help='how much to multiply mu each time') diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index a7d795626..67fecec23 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -98,7 +98,7 @@ def cal_delta4control(self, list1, list_setpoint): def cal_delta_integration(self, list_old, list_new, coeff): return [(1-coeff)*a + coeff*b for a, b in zip(list_old, list_new)] - def search_mu(self, epo_reg_loss, epo_task_loss, dict_theta=None, miter=None): + def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, dict_theta=None, miter=None): """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value @@ -137,9 +137,6 @@ def search_mu(self, epo_reg_loss, epo_task_loss, dict_theta=None, miter=None): f'reg/setpoint{i}': reg_set, }, miter) self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{i}', reg_dyn, epo_task_loss) - - epo_loss_tr = epo_task_loss + torch.inner( - torch.Tensor(list(self.mmu.values())), torch.Tensor(epo_reg_loss)) self.writer.add_scalar('loss_penalized', epo_loss_tr, miter) self.writer.add_scalar('task', epo_task_loss, miter) acc_te = 0 diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index b0c982e4a..c015930c4 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -45,24 +45,27 @@ def eval_r_loss(self): # mock the model hyper-parameter to be from dict4mu epo_reg_loss = [] epo_task_loss = 0 + epo_p_loss = 0 counter = 0.0 with torch.no_grad(): for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) tuple_reg_loss = self.model.cal_reg_loss(tensor_x, vec_y, vec_d) + p_loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d) # NOTE: first [0] extract the loss, second [0] get the list list_b_reg_loss = tuple_reg_loss[0] - list_b_reg_loss_sumed = [ele.sum().item() for ele in list_b_reg_loss] + list_b_reg_loss_sumed = [ele.sum().detach().item() for ele in list_b_reg_loss] if len(epo_reg_loss) == 0: epo_reg_loss = list_b_reg_loss_sumed else: epo_reg_loss = list(map(add, epo_reg_loss, list_b_reg_loss_sumed)) - b_task_loss = self.model.cal_task_loss(tensor_x, vec_y).sum() + b_task_loss = self.model.cal_task_loss(tensor_x, vec_y).sum().detach().item() # sum will kill the dimension of the mini batch epo_task_loss += b_task_loss + epo_p_loss += p_loss.sum().detach().item() counter += 1.0 - return list_divide(epo_reg_loss, counter), epo_task_loss/counter + return list_divide(epo_reg_loss, counter), epo_task_loss/counter, epo_p_loss / counter def before_batch(self, epoch, ind_batch): """ @@ -77,7 +80,7 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) - self.epo_reg_loss_tr, self.epo_task_loss_tr = self.eval_r_loss() + self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() self.hyper_scheduler.set_setpoint( [ele * self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) @@ -90,6 +93,7 @@ def tr_epoch(self, epoch): self.hyper_scheduler.search_mu( self.epo_reg_loss_tr, self.epo_task_loss_tr, + self.epo_loss_tr, dict(self.model.named_parameters()), miter=epoch) self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 752d5acf2..305be1162 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -9,7 +9,7 @@ from domainlab.utils.utils_class import store_args -def mk_diva(parent_class=VAEXYDClassif): +def mk_diva(parent_class=VAEXYDClassif, str_mu="default"): """ Instantiate a domain invariant variational autoencoder (DIVA) with arbitrary task loss. @@ -89,8 +89,6 @@ def hyper_update(self, epoch, fun_scheduler): self.beta_d = dict_rst["beta_d"] self.beta_y = dict_rst["beta_y"] self.beta_x = dict_rst["beta_x"] - self.gamma_d = dict_rst["gamma_d"] - self.mu_recon = dict_rst["mu_recon"] def hyper_init(self, functor_scheduler, trainer=None): """ @@ -100,11 +98,9 @@ def hyper_init(self, functor_scheduler, trainer=None): """ return functor_scheduler( trainer=trainer, - mu_recon=self.mu_recon, beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, - gamma_d=self.gamma_d, ) def get_list_str_y(self): @@ -142,4 +138,71 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): lc_d = F.cross_entropy(logit_d, d_target, reduction="none") return [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ [self.mu_recon, -self.beta_d, -self.beta_x, -self.beta_y, -self.gamma_d] - return ModelDIVA + + class ModelDIVAGammadRecon(ModelDIVA): + def hyper_update(self, epoch, fun_scheduler): + """hyper_update. + + :param epoch: + :param fun_scheduler: + """ + dict_rst = fun_scheduler(epoch) + self.beta_d = dict_rst["beta_d"] + self.beta_y = dict_rst["beta_y"] + self.beta_x = dict_rst["beta_x"] + self.gamma_d = dict_rst["gamma_d"] + self.mu_recon = dict_rst["mu_recon"] + + def hyper_init(self, functor_scheduler, trainer=None): + """ + initiate a scheduler object via class name and things inside this model + + :param functor_scheduler: the class name of the scheduler + """ + return functor_scheduler( + trainer=trainer, + mu_recon=self.mu_recon, + beta_d=self.beta_d, + beta_y=self.beta_y, + beta_x=self.beta_x, + gamma_d=self.gamma_d, + ) + + + class ModelDIVAGammad(ModelDIVA): + def hyper_update(self, epoch, fun_scheduler): + """hyper_update. + + :param epoch: + :param fun_scheduler: + """ + dict_rst = fun_scheduler(epoch) + self.beta_d = dict_rst["beta_d"] + self.beta_y = dict_rst["beta_y"] + self.beta_x = dict_rst["beta_x"] + self.gamma_d = dict_rst["gamma_d"] + + def hyper_init(self, functor_scheduler, trainer=None): + """ + initiate a scheduler object via class name and things inside this model + + :param functor_scheduler: the class name of the scheduler + """ + return functor_scheduler( + trainer=trainer, + beta_d=self.beta_d, + beta_y=self.beta_y, + beta_x=self.beta_x, + gamma_d=self.gamma_d, + ) + + class ModelDIVADefault(ModelDIVA): + """ + """ + if str_mu == "gammad_recon": + return ModelDIVAGammadRecon + if str_mu == "gammad": + return ModelDIVAGammad + if str_mu == "default": + return ModelDIVADefault + raise RuntimeError("not support argument candiates for str_mu: allowed: default, gammad_recon, gammad") From eb952394a324158024f9189fab67f96bc64b7fa1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 15:13:45 +0200 Subject: [PATCH 266/762] diva yaml mnist --- .../benchmark/benchmark_fbopt_mnist_diva.yaml | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index f705f4da1..b8832eae7 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -53,18 +53,52 @@ Shared params: num: 5 distribution: loguniform + gamma_y: + min: 1e4 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + gamma_d: + min: 1e4 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform # Test fbopt with different hyperparameter configurations -diva_fbopt: +diva_fbopt_full: aname: diva trainer: fbopt + str_mu: gammad_recon shared: - ini_setpoint_ratio - k_i_gain - mu_init +diva_feedforward_full: + aname: diva + trainer: hyperscheduler + str_mu: gammad_recon + +diva_default: + aname: diva + trainer: hyperscheduler + str_mu: default + shared: + - gamma_d + - gamma_y + +diva_fixed_penalty: + aname: diva + trainer: basic + str_mu: default + shared: + - gamma_d + - gamma_y + erm: aname: deepall From 58cd65d091e54cc3fca7b44189274745647fd035 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 15:59:38 +0200 Subject: [PATCH 267/762] . --- run_erm.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 run_erm.sh diff --git a/run_erm.sh b/run_erm.sh new file mode 100644 index 000000000..e5d44a151 --- /dev/null +++ b/run_erm.sh @@ -0,0 +1 @@ +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=deepall --nname=conv_bn_pool_2 --epos=10 From c689fbb84904b7e4f1e51982d07d70e73083c983 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 16:10:10 +0200 Subject: [PATCH 268/762] add gamm_d to yaml --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index b8832eae7..604dda0f6 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -83,6 +83,8 @@ diva_feedforward_full: aname: diva trainer: hyperscheduler str_mu: gammad_recon + shared: + - gamma_d diva_default: aname: diva From aed3081b196506fc223854cfd7c963e376bc0bd8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 16:13:07 +0200 Subject: [PATCH 269/762] . --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index 604dda0f6..29c97b4d1 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -21,7 +21,6 @@ domainlab_args: zx_dim: 0 zy_dim: 32 zd_dim: 32 - gamma_y: 1.0 nname: conv_bn_pool_2 nname_dom: conv_bn_pool_2 nname_topic_distrib_img2topic: conv_bn_pool_2 @@ -73,6 +72,7 @@ diva_fbopt_full: aname: diva trainer: fbopt str_mu: gammad_recon + gamma_y: 1.0 shared: - ini_setpoint_ratio @@ -83,6 +83,7 @@ diva_feedforward_full: aname: diva trainer: hyperscheduler str_mu: gammad_recon + gamma_y: 1.0 shared: - gamma_d From 6ee3c6b0fea8c6a66a8ab0c61a257538c5baa2e6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 16:27:22 +0200 Subject: [PATCH 270/762] new yaml --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 2 +- examples/benchmark/benchmark_fbopt_mnist_jigen.yaml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index 29c97b4d1..31322e808 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -4,7 +4,7 @@ output_dir: zoutput/benchmarks/benchmark_fbopt sampling_seed: 0 startseed: 0 -endseed: 2 +endseed: 4 test_domains: - 0 diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index 7157270b9..02aac7b03 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -4,7 +4,7 @@ output_dir: zoutput/benchmarks/benchmark_fbopt sampling_seed: 0 startseed: 0 -endseed: 2 +endseed: 4 test_domains: - 0 @@ -50,7 +50,7 @@ Shared params: gamma_reg: min: 0.01 - max: 1000 + max: 10 num: 10 distribution: loguniform @@ -61,12 +61,10 @@ Shared params: jigen_feedback: aname: jigen trainer: fbopt - + ini_setpoint_ratio: 0.99 shared: - - ini_setpoint_ratio - k_i_gain - mu_init - - pperm jigen_feedforward: aname: jigen From d9e47ea373f78b98e6b5a68ca3e6b55766aca2b4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 16:50:18 +0200 Subject: [PATCH 271/762] jigen pacs --- examples/benchmark/benchmark_fbopt_pacs_jigen.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml index 953d47427..d1e5f80b7 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full sampling_seed: 0 startseed: 0 -endseed: 2 +endseed: 4 test_domains: - sketch @@ -40,8 +40,8 @@ Shared params: mu_init: min: 0.00001 - max: 0.001 - num: 4 + max: 0.0001 + num: 3 distribution: loguniform pperm: @@ -52,20 +52,20 @@ Shared params: gamma_reg: min: 0.01 - max: 1000 + max: 10 num: 10 distribution: loguniform # Test fbopt with different hyperparameter configurations -jigen_fbopt: +jigen_feedback: aname: jigen - init_setpoint_ratio: 0.99 trainer: fbopt + ini_setpoint_ratio: 0.99 shared: - k_i_gain - mu_init - + jigen_feedforward: aname: jigen trainer: hyperscheduler From 47a6fff144da93af6b3c10476de85170a82350a8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 9 Oct 2023 16:59:44 +0200 Subject: [PATCH 272/762] diva pacs --- .../benchmark/benchmark_fbopt_pacs_diva.yaml | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml index 8c128206e..677af9eeb 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml @@ -46,20 +46,62 @@ Shared params: distribution: uniform mu_init: - min: 0.0001 + min: 0.00001 max: 0.001 num: 3 distribution: loguniform + gamma_y: + min: 1e4 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1e4 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + # Test fbopt with different hyperparameter configurations -diva_fbopt: +diva_fbopt_full: aname: diva trainer: fbopt + str_mu: gammad_recon gamma_y: 1.0 + ini_setpoint_ratio: 0.95 shared: - - ini_setpoint_ratio - k_i_gain - mu_init + +diva_feedforward_full: + aname: diva + trainer: hyperscheduler + str_mu: gammad_recon + gamma_y: 1.0 + shared: + - gamma_d + +diva_default: + aname: diva + trainer: hyperscheduler + str_mu: default + shared: + - gamma_d + - gamma_y + +diva_fixed_penalty: + aname: diva + trainer: basic + str_mu: default + shared: + - gamma_d + - gamma_y + +erm: + aname: deepall From 03a67201e29cf85d26a24353b0d2635be907b8d2 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 9 Oct 2023 17:55:34 +0200 Subject: [PATCH 273/762] Update args_fbopt.py --- domainlab/algos/trainers/args_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index b26123612..bc1d5aac8 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -23,7 +23,7 @@ def add_args2parser_fbopt(parser): parser.add_argument('--coeff_ma', type=float, default=0.5, help='exponential moving average') - parser.add_argument('--coeff_ma_output_state', type=float, default=0.9, + parser.add_argument('--coeff_ma_output_state', type=float, default=0.5, help='setpoint output as state exponential moving average') From 7629d98e39e2a86e2afeb9fb177a5dfcc9bb8eb2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 10:41:44 +0200 Subject: [PATCH 274/762] update yaml --- examples/benchmark/benchmark_fbopt_mnist_jigen.yaml | 7 ------- examples/benchmark/benchmark_fbopt_pacs_jigen.yaml | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index 02aac7b03..ad36ac6d7 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -29,17 +29,10 @@ domainlab_args: Shared params: - ini_setpoint_ratio: - min: 0.95 - max: 0.99 - num: 2 - distribution: uniform - k_i_gain: min: 0.0001 max: 0.01 num: 2 - step: 0.0001 distribution: uniform mu_init: diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml index d1e5f80b7..a4e7aa64e 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -39,8 +39,8 @@ Shared params: distribution: loguniform mu_init: - min: 0.00001 - max: 0.0001 + min: 0.000001 + max: 0.00005 num: 3 distribution: loguniform From 50dbfa6ebee5e349e79f5dda05889c20df73ebe1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 10:52:54 +0200 Subject: [PATCH 275/762] . --- examples/benchmark/benchmark_fbopt_pacs_jigen.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml index a4e7aa64e..aa9d56696 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml @@ -52,7 +52,7 @@ Shared params: gamma_reg: min: 0.01 - max: 10 + max: 10_000 num: 10 distribution: loguniform From 0669d54ff4b5676d2572dd9e3aa454b4e5349ead Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 10:56:34 +0200 Subject: [PATCH 276/762] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2c5b88c92..f7c859d66 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ then #### Guide for Helmholtz GPU cluster ``` +conda create --name domainlab_py39 python=3.9 +conda activate domainlab_py39 conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge conda install torchmetric==0.10.3 pip install -r requirements_notorch.txt From 682811e6c67baadf2c778ca37588b7ea8eaf6e13 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 11:00:45 +0200 Subject: [PATCH 277/762] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f7c859d66..cff6a3692 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ conda create --name domainlab_py39 python=3.9 conda activate domainlab_py39 conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge conda install torchmetric==0.10.3 +git checkout fbopt pip install -r requirements_notorch.txt conda install tensorboard ``` From 9e5b4af94a6aabbd7dd29d256701588886d01c62 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 11:17:18 +0200 Subject: [PATCH 278/762] . --- run_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt.sh b/run_fbopt.sh index ed7873414..33226f290 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=100 --init_mu=1.0 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=5 --mu_init=1.0 From ee7895269d0e7f2c5d7f524ee91cd636b4b47e54 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 11:27:20 +0200 Subject: [PATCH 279/762] ma setpiont update --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 1361708d5..08fa06fef 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -51,14 +51,12 @@ def transition_to(self, state): self.state_updater = state self.state_updater.accept(self) - def update_setpoint_ma(self, target): + def update_setpoint_ma(self, list_target): """ using moving average """ - temp_ma = self.coeff_ma * torch.tensor(target) - temp_ma += (1 - self.coeff_ma) * torch.tensor(self.setpoint4R) - temp_ma = temp_ma.tolist() - self.setpoint4R = temp_ma + target_ma = [self.coeff_ma * a + (1 - self.coeff_ma) *b for a, b in zip(self.setpoint4R, list_target)] + self.setpoint4R = target_ma def observe(self, epo_reg_loss, epo_task_loss): """ @@ -69,7 +67,7 @@ def observe(self, epo_reg_loss, epo_task_loss): self.state_task_loss = epo_task_loss if self.state_updater.update_setpoint(): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - self.setpoint4R = self.state_epo_reg_loss + self.update_setpoint_ma(self.state_epo_reg_loss) logger.info(f"!!!!!set point updated to {self.setpoint4R}!") From 70c228137888ea96b9ff56243cc0014c48607554 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 11:38:16 +0200 Subject: [PATCH 280/762] . --- examples/benchmark/benchmark_fbopt_mnist_jigen.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index ad36ac6d7..d0a8ed753 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -43,7 +43,7 @@ Shared params: gamma_reg: min: 0.01 - max: 10 + max: 10_000 num: 10 distribution: loguniform From bdb572cd1e231d53882a3d81d79880cbc32d7f73 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 11:47:11 +0200 Subject: [PATCH 281/762] Update benchmark_fbopt_mnist_jigen.yaml --- examples/benchmark/benchmark_fbopt_mnist_jigen.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml index d0a8ed753..c58868965 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml @@ -36,8 +36,8 @@ Shared params: distribution: uniform mu_init: - min: 0.00001 - max: 0.0001 + min: 0.000001 + max: 0.00001 num: 3 distribution: loguniform From 2f6df907311e6f96c2171081d3f304334c751457 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 12:00:14 +0200 Subject: [PATCH 282/762] fix bug 0 drag state down --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index e7dede900..a789a1ccc 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -9,7 +9,7 @@ def list_add(list1, list2): def list_multiply(list1, coeff): return [ele * coeff for ele in list1] - + def is_less_list_any(list1, list2): """ judge if one list is less than the other @@ -71,8 +71,10 @@ def observe(self, epo_reg_loss, epo_task_loss): read current epo_reg_loss continuously FIXME: setpoint should also be able to be eliviated """ - self.state_epo_reg_loss = list_add(list_multiply(epo_reg_loss, self.coeff_ma_output), list_multiply(self.state_epo_reg_loss, 1 - self.coeff_ma_output)) - self.state_task_loss = epo_task_loss + self.state_epo_reg_loss = [self.coeff_ma_output*a + ( 1-self.coeff_ma_output )*b if a != 0.0 else b for a, b in zip(self.state_epo_reg_loss, epo_reg_loss)] + if self.state_task_loss == 0.0: + self.state_task_loss = epo_task_loss + self.state_task_loss = self.coeff_ma_output * self.state_task_loss + (1-self.coeff_ma_output) * epo_task_loss if self.state_updater.update_setpoint(): logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") self.setpoint4R = self.state_epo_reg_loss From 13d32b307363b3cf808e891049f6b8a08df93c33 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 12:16:49 +0200 Subject: [PATCH 283/762] Update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index cff6a3692..23ed163d6 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,23 @@ pip install -r requirements_notorch.txt conda install tensorboard ``` +#### Download PACS + +step 1: + +use the following script to download PACS to your local laptop and upload it to your cluster + +https://github.com/marrlab/DomainLab/blob/fbopt/data/script/download_pacs.py + +step 2: +make a symbolic link following the example script in https://github.com/marrlab/DomainLab/blob/master/sh_pacs.sh + +where `mkdir -p data/pacs` is executed under the repository directory, + +`ln -s /dir/to/yourdata/pacs/raw ./data/pacs/PACS` +will create a symbolic link under the repository directory + + #### Windows installation details To install DomainLab on Windows, please remove the `snakemake` dependency from the `requirements.txt` file. From 613cbd536b109391fe309b5cc38aa5b44ac04c3b Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 13:16:34 +0200 Subject: [PATCH 284/762] update diva --- .../benchmark/benchmark_fbopt_mnist_diva.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index 31322e808..12878acb0 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -47,20 +47,19 @@ Shared params: distribution: loguniform mu_init: - min: 0.01 - max: 0.05 + min: 0.000001 + max: 0.00001 num: 5 distribution: loguniform gamma_y: - min: 1e4 + min: 1.0 max: 1e6 - step: 100 num: 3 distribution: loguniform gamma_d: - min: 1e4 + min: 1.0 max: 1e6 step: 100 num: 3 @@ -68,18 +67,18 @@ Shared params: # Test fbopt with different hyperparameter configurations -diva_fbopt_full: +diva_fbopt_a: aname: diva trainer: fbopt str_mu: gammad_recon gamma_y: 1.0 + init_setpoint_ratio: 0.99 shared: - - ini_setpoint_ratio - k_i_gain - mu_init -diva_feedforward_full: +diva_feedforward_a: aname: diva trainer: hyperscheduler str_mu: gammad_recon From 76a351101bf501a8dc3488847ce64389ec3509c6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 13:20:45 +0200 Subject: [PATCH 285/762] . --- examples/benchmark/benchmark_fbopt_pacs_diva.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml index 677af9eeb..81a6a4e9a 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml @@ -23,7 +23,7 @@ domainlab_args: npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py exp_shoulder_clip: 10 - mu_clip: 10_000 + mu_clip: 1000_000 coeff_ma: 0.5 zx_dim: 0 zy_dim: 64 @@ -41,25 +41,25 @@ Shared params: k_i_gain: min: 0.0001 - max: 0.1 + max: 0.01 num: 3 distribution: uniform mu_init: - min: 0.00001 - max: 0.001 + min: 0.000001 + max: 0.00001 num: 3 distribution: loguniform gamma_y: - min: 1e4 + min: 1.0 max: 1e6 step: 100 num: 3 distribution: loguniform gamma_d: - min: 1e4 + min: 1.0 max: 1e6 step: 100 num: 3 @@ -74,7 +74,7 @@ diva_fbopt_full: trainer: fbopt str_mu: gammad_recon gamma_y: 1.0 - ini_setpoint_ratio: 0.95 + ini_setpoint_ratio: 0.99 shared: - k_i_gain - mu_init From 4e49f89f204013d9705459f443ffcae442f7a451 Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:49:44 -0400 Subject: [PATCH 286/762] phase portrait type plots for fbopt --- .../utils/generate_fbopt_phase_portrait.py | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 domainlab/utils/generate_fbopt_phase_portrait.py diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py new file mode 100644 index 000000000..88b2bd97a --- /dev/null +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -0,0 +1,63 @@ +import glob +import os + +import matplotlib.pyplot as plt +from tensorboard.backend.event_processing.event_accumulator import EventAccumulator + + +# FIXME: maybe adjust the output path where the png is saved +output_dir = "../.." + +def get_xy_from_event_file(event_file, tf_size_guidance=None): + if tf_size_guidance is None: + # settings for which/how much data is loaded from the tensorboard event files + tf_size_guidance = { + 'compressedHistograms': 0, + 'images': 0, + 'scalars': 1e10, # keep unlimited number + 'histograms': 0 + } + # load event file + event = EventAccumulator(event_file, tf_size_guidance) + event.Reload() + # extract the reg/dyn0 values + y_event = event.Scalars('x-axis=task vs y-axis=reg/dyn0') + y = [s.value for s in y_event] + x_int = [s.step for s in y_event] # the .step data are saved as ints in tensorboard, so we will re-extact from 'task' + # extract the corresponding 'task' values + x_event = event.Scalars('task') + x = [s.value for s in x_event] + # sanity check: + for i in range(len(x)): + assert int(x[i]) == x_int[i] + return x, y + +def phase_portrain_combined(event_files, colors): + plt.figure() + + for event_i in range(len(event_files)): + x, y = get_xy_from_event_file(event_files[event_i]) + + assert len(x) == len(y) + for i in range(len(x)-1): + plt.arrow(x[i], y[i], (x[i+1]-x[i]), (y[i+1]-y[i]), + head_width=0.2, head_length=0.2, length_includes_head=True, + fc=colors[event_i], ec=colors[event_i], alpha=0.4) + + plt.plot(x[0], y[0], 'ko') + plt.scatter(x, y, s=1, c='black') + + plt.xlabel("task") + plt.ylabel("reg/dyn0") + plt.title("x-axis=task vs y-axis=reg/dyn0") + + plt.savefig(os.path.join(output_dir, 'phase_portrain_combined.png'), dpi=300) + + +if __name__ == "__main__": + event_files = glob.glob("../../runs/*/events*") + print("Using the following tensorboard event files:\n{}".format("\n".join(event_files))) + cmap = plt.get_cmap('tab10') # Choose a colormap + colors = [cmap(i) for i in range(len(event_files))] # Different colors for the different runs + phase_portrain_combined(event_files, colors) + From 75fae5442792a3a865ac4a79f0ef3b8a7fc1be30 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 19:48:46 +0200 Subject: [PATCH 287/762] Update args_fbopt.py --- domainlab/algos/trainers/args_fbopt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index bc1d5aac8..b86d32a2a 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -25,6 +25,9 @@ def add_args2parser_fbopt(parser): parser.add_argument('--coeff_ma_output_state', type=float, default=0.5, help='setpoint output as state exponential moving average') + + parser.add_argument('--coeff_ma_setpoint', type=float, default=0.5, + help='setpoint average') parser.add_argument('--exp_shoulder_clip', type=float, default=10, From bff815b41cc8fbe0532352202db20326f3cb9059 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 19:53:36 +0200 Subject: [PATCH 288/762] Update fbopt_setpoint_ada.py --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 521cab3ff..3fb4e4616 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -41,7 +41,7 @@ def __init__(self, state=None, args=None): state = DominateAnyComponent() self.transition_to(state) self.ma_epo_reg_loss = None - self.coeff_ma = 0.5 # FIXME + self.coeff_ma = args.coeff_ma_setpoint self.state_task_loss = 0.0 self.state_epo_reg_loss = [0.0 for _ in range(10)] # FIXME self.coeff_ma_output = args.coeff_ma_output_state From 803f218ef70610cedab2d58f099ff02197920a22 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 20:22:59 +0200 Subject: [PATCH 289/762] smaller exp shoulder for mnist diva --- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index 12878acb0..35ecb3b20 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -26,7 +26,7 @@ domainlab_args: nname_topic_distrib_img2topic: conv_bn_pool_2 nname_encoder_sandwich_layer_img2h4zd: conv_bn_pool_2 san_check: False - exp_shoulder_clip: 10 + exp_shoulder_clip: 5.0 mu_clip: 1000_000 coeff_ma: 0.5 no_tensorboard: False @@ -49,12 +49,13 @@ Shared params: mu_init: min: 0.000001 max: 0.00001 - num: 5 + num: 3 distribution: loguniform gamma_y: min: 1.0 max: 1e6 + step: 100 num: 3 distribution: loguniform From b89d83432949efd84706082abc5cfb36799e3351 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 22:11:49 +0200 Subject: [PATCH 290/762] overshoot handling Update fbopt_alternate.py --- domainlab/algos/trainers/fbopt_alternate.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 67fecec23..cb09392ee 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -121,6 +121,10 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, dict_theta=None, m if self.activation_clip is not None: activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) for val in activation] + # overshoot handling + list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] + for ind in list_overshoot: + activation[ind] = 0.0 list_gain = np.exp(activation) target = self.dict_multiply(self.mmu, list_gain) self.mmu = self.dict_clip(target) From 0fab5895f38bde7799b2d724a4a9ca534344aac8 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 22:23:23 +0200 Subject: [PATCH 291/762] Update fbopt_alternate.py --- domainlab/algos/trainers/fbopt_alternate.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index cb09392ee..5a6fc62a4 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -122,9 +122,10 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, dict_theta=None, m activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) for val in activation] # overshoot handling - list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] + list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b else None for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] for ind in list_overshoot: - activation[ind] = 0.0 + if ind is not None: + activation[ind] = 0.0 list_gain = np.exp(activation) target = self.dict_multiply(self.mmu, list_gain) self.mmu = self.dict_clip(target) From ee682e8fa847e48d79c08e566efd785f262eb334 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 22:31:20 +0200 Subject: [PATCH 292/762] Update fbopt_alternate.py --- domainlab/algos/trainers/fbopt_alternate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 5a6fc62a4..c5cfc4498 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -125,6 +125,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, dict_theta=None, m list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b else None for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] for ind in list_overshoot: if ind is not None: + print(f"overshooting at pos {ind}, PID controller set to zero now") activation[ind] = 0.0 list_gain = np.exp(activation) target = self.dict_multiply(self.mmu, list_gain) From 874baf14acf3573f2c5b4a80ffa65be95f5982be Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 10 Oct 2023 22:34:30 +0200 Subject: [PATCH 293/762] . --- run_fbopt_mnist_diva.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 run_fbopt_mnist_diva.sh diff --git a/run_fbopt_mnist_diva.sh b/run_fbopt_mnist_diva.sh new file mode 100644 index 000000000..59c4e148d --- /dev/null +++ b/run_fbopt_mnist_diva.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py + +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_output_state=0.5 --qaqj From 4b163829502edc0fcac6ea972d2f3fd9fd047077 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 22:35:04 +0200 Subject: [PATCH 294/762] Update run_fbopt_mnist_diva.sh --- run_fbopt_mnist_diva.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist_diva.sh b/run_fbopt_mnist_diva.sh index 59c4e148d..4ed25b720 100644 --- a/run_fbopt_mnist_diva.sh +++ b/run_fbopt_mnist_diva.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_output_state=0.5 --qaqj +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_output_state=0.5 --gamma_y=1.0 From 75e8132f8694097717effa023c29a19bee5b041e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 22:38:14 +0200 Subject: [PATCH 295/762] Update args_fbopt.py --- domainlab/algos/trainers/args_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index b86d32a2a..eac6ba19c 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -43,7 +43,7 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') - parser.add_argument('--str_mu', type=str, default="default", help='which penalty to tune') + parser.add_argument('--str_mu', type=str, default="gammad_recon", help='which penalty to tune') # the following hyperparamters do not need to be tuned From a748e23b162e2c0f5967f150359bc07c3f6224fe Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 10 Oct 2023 22:40:29 +0200 Subject: [PATCH 296/762] Update args_fbopt.py --- domainlab/algos/trainers/args_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index b86d32a2a..eac6ba19c 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -43,7 +43,7 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') - parser.add_argument('--str_mu', type=str, default="default", help='which penalty to tune') + parser.add_argument('--str_mu', type=str, default="gammad_recon", help='which penalty to tune') # the following hyperparamters do not need to be tuned From a8c6d1f5179858ed14707b20220b300f4aeecb01 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 09:46:33 +0200 Subject: [PATCH 297/762] rewind setpoing if ma is bigger than setpoing --- .../algos/trainers/fbopt_setpoint_ada.py | 67 +++++++++++++++++-- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 3fb4e4616..8312b5b3e 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -1,15 +1,23 @@ """ update hyper-parameters during training """ -import torch from domainlab.utils.logger import Logger + def list_add(list1, list2): + """ + add two lists + """ return [a + b for a, b in zip(list1, list2)] + def list_multiply(list1, coeff): + """ + multiply a scalar to a list + """ return [ele * coeff for ele in list1] + def is_less_list_any(list1, list2): """ judge if one list is less than the other @@ -26,6 +34,39 @@ def is_less_list_all(list1, list2): return all(list_comparison) +def list_ma(list_state, list_input, coeff): + """ + moving average of list + """ + return [a * coeff + b * (1-coeff) for a, b in zip(list_state, list_input)] + + +class SetpointRewinder(): + """ + rewind setpoint if current loss exponential moving average is bigger than setpoint + """ + def __init__(self, host): + self.counter = 0 + self.epo_ma = None + self.host = host + + def reset(self): + """ + when setpoint is adjusted + """ + self.counter = 0 + self.epo_ma = 0.0 + + def observe(self, epo_reg_loss): + """ + update moving average + """ + self.epo_ma = list_ma(self.epo_ma, epo_reg_loss, self.host.coeff_ma_output) + list_comparison = [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] + if any(list_comparison): + raise RuntimeError("setpoint too low!") + + class FbOptSetpointController(): """ update setpoint for mu @@ -40,10 +81,10 @@ def __init__(self, state=None, args=None): else: state = DominateAnyComponent() self.transition_to(state) - self.ma_epo_reg_loss = None - self.coeff_ma = args.coeff_ma_setpoint + self.setpoint_rewinder = SetpointRewinder(self) self.state_task_loss = 0.0 - self.state_epo_reg_loss = [0.0 for _ in range(10)] # FIXME + self.state_epo_reg_loss = [0.0 for _ in range(10)] # FIXME: 10 is the maximum number losses here + self.coeff_ma_setpoint = args.coeff_ma_setpoint self.coeff_ma_output = args.coeff_ma_output_state # initial value will be set via trainer self.setpoint4R = None @@ -61,7 +102,8 @@ def update_setpoint_ma(self, list_target): """ using moving average """ - target_ma = [self.coeff_ma * a + (1 - self.coeff_ma) *b for a, b in zip(self.setpoint4R, list_target)] + target_ma = [self.coeff_ma_setpoint * a + (1 - self.coeff_ma_setpoint) * b + for a, b in zip(self.setpoint4R, list_target)] self.setpoint4R = target_ma def observe(self, epo_reg_loss, epo_task_loss): @@ -69,11 +111,16 @@ def observe(self, epo_reg_loss, epo_task_loss): read current epo_reg_loss continuously FIXME: setpoint should also be able to be eliviated """ - self.state_epo_reg_loss = [self.coeff_ma_output*a + ( 1-self.coeff_ma_output )*b if a != 0.0 else b for a, b in zip(self.state_epo_reg_loss, epo_reg_loss)] + self.state_epo_reg_loss = [self.coeff_ma_output*a + (1-self.coeff_ma_output)*b + if a != 0.0 else b + for a, b in zip(self.state_epo_reg_loss, epo_reg_loss)] if self.state_task_loss == 0.0: self.state_task_loss = epo_task_loss - self.state_task_loss = self.coeff_ma_output * self.state_task_loss + (1-self.coeff_ma_output) * epo_task_loss + self.state_task_loss = self.coeff_ma_output * self.state_task_loss + \ + (1-self.coeff_ma_output) * epo_task_loss + self.setpoint_rewinder.observe(epo_reg_loss) if self.state_updater.update_setpoint(): + self.setpoint_rewinder.reset() logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") self.update_setpoint_ma(self.state_epo_reg_loss) logger.info(f"!!!!!set point updated to {self.setpoint4R}!") @@ -96,7 +143,13 @@ def accept(self, controller): class FixedSetpoint(FbOptSetpointControllerState): + """ + do not update setpoint + """ def update_setpoint(self): + """ + always return False so setpoint no update + """ return False From f32316d10aa921cd37f03d1736697f8700e26e79 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 09:58:02 +0200 Subject: [PATCH 298/762] . --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 7 ++++--- run_fbopt.sh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 8312b5b3e..a40636090 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -47,8 +47,9 @@ class SetpointRewinder(): """ def __init__(self, host): self.counter = 0 - self.epo_ma = None + self.epo_ma = [0.0 for _ in range(10)] # FIXME self.host = host + self.coeff_ma = 0.5 def reset(self): """ @@ -61,10 +62,10 @@ def observe(self, epo_reg_loss): """ update moving average """ - self.epo_ma = list_ma(self.epo_ma, epo_reg_loss, self.host.coeff_ma_output) + self.epo_ma = list_ma(self.epo_ma, epo_reg_loss, self.coeff_ma) list_comparison = [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] if any(list_comparison): - raise RuntimeError("setpoint too low!") + print("setpoint too low!") # FIXME: rewind setpoing class FbOptSetpointController(): diff --git a/run_fbopt.sh b/run_fbopt.sh index 33226f290..9bfffd427 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=5 --mu_init=1.0 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=5 --mu_init=1.0 --coeff_ma_output=0 --coeff_ma_setpoint=0 From 7166db340a39e1e0eabe4931e48af1e5f51f48b1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 10:01:38 +0200 Subject: [PATCH 299/762] codacy --- domainlab/algos/trainers/fbopt_alternate.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 67fecec23..0a369f345 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -3,7 +3,6 @@ """ import copy import os -import torch from torch.utils.tensorboard import SummaryWriter @@ -13,13 +12,19 @@ class StubSummaryWriter(): + """ # stub writer for tensorboard that ignores all messages + """ def add_scalar(self, *args, **kwargs): - pass + """ + stub, pass do nothing + """ def add_scalars(self, *args, **kwargs): - pass + """ + stub, pass, do nothing + """ class HyperSchedulerFeedbackAlternave(): @@ -67,6 +72,9 @@ def __init__(self, trainer, **kwargs): self.epsilon_r = False def get_setpoint4R(self): + """ + get setpoint list + """ return self.set_point_controller.setpoint4R def set_setpoint(self, list_setpoint4R, setpoint4ell): @@ -93,9 +101,15 @@ def set_theta_ref(self): self.dict_theta_ref = copy.deepcopy(self.dict_theta) def cal_delta4control(self, list1, list_setpoint): + """ + list difference + """ return [a - b for a, b in zip(list1, list_setpoint)] def cal_delta_integration(self, list_old, list_new, coeff): + """ + ma of delta + """ return [(1-coeff)*a + coeff*b for a, b in zip(list_old, list_new)] def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, dict_theta=None, miter=None): From c219302785d39ce941f79e775a73a3b34ee7c454 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 10:06:00 +0200 Subject: [PATCH 300/762] check if loss is decreasing --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 10 +++++++--- run_fbopt.sh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index a40636090..7b3bc62d4 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -50,20 +50,24 @@ def __init__(self, host): self.epo_ma = [0.0 for _ in range(10)] # FIXME self.host = host self.coeff_ma = 0.5 + self.ref = None - def reset(self): + def reset(self, epo_reg_loss): """ when setpoint is adjusted """ self.counter = 0 self.epo_ma = 0.0 + self.ref = epo_reg_loss def observe(self, epo_reg_loss): """ update moving average """ + if self.ref is None: + self.ref = epo_reg_loss self.epo_ma = list_ma(self.epo_ma, epo_reg_loss, self.coeff_ma) - list_comparison = [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] + list_comparison = [a < b for a, b in zip(self.ref, self.epo_ma)] if any(list_comparison): print("setpoint too low!") # FIXME: rewind setpoing @@ -121,7 +125,7 @@ def observe(self, epo_reg_loss, epo_task_loss): (1-self.coeff_ma_output) * epo_task_loss self.setpoint_rewinder.observe(epo_reg_loss) if self.state_updater.update_setpoint(): - self.setpoint_rewinder.reset() + self.setpoint_rewinder.reset(epo_reg_loss) logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") self.update_setpoint_ma(self.state_epo_reg_loss) logger.info(f"!!!!!set point updated to {self.setpoint4R}!") diff --git a/run_fbopt.sh b/run_fbopt.sh index 9bfffd427..130f32bea 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=5 --mu_init=1.0 --coeff_ma_output=0 --coeff_ma_setpoint=0 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=50 --mu_init=1.0 --coeff_ma_output=0 --coeff_ma_setpoint=0 --coeff_ma_output=0 From 366ef7066322573a6e615f47531cabba89152441 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 10:14:43 +0200 Subject: [PATCH 301/762] if setpoing too low --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 7b3bc62d4..aae8b81c0 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -67,9 +67,12 @@ def observe(self, epo_reg_loss): if self.ref is None: self.ref = epo_reg_loss self.epo_ma = list_ma(self.epo_ma, epo_reg_loss, self.coeff_ma) - list_comparison = [a < b for a, b in zip(self.ref, self.epo_ma)] - if any(list_comparison): - print("setpoint too low!") # FIXME: rewind setpoing + list_comparison_increase = [a < b for a, b in zip(self.ref, self.epo_ma)] + list_comparison_above_setpoint = [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] + flag_increase = any(list_comparison_increase) + flag_above_setpoint = any(list_comparison_above_setpoint) + if flag_increase and flag_above_setpoint: + print("\n\n\n!!!!!!!setpoint too low!\n\n\n") # FIXME: rewind setpoing class FbOptSetpointController(): From bdb2aeaaf23ecb9200a2cf66b53652de1ef7bdd8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 10:35:53 +0200 Subject: [PATCH 302/762] sepoint rewind --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 15 ++++++++++++++- run_fbopt.sh | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index aae8b81c0..ee569944d 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -1,9 +1,18 @@ """ update hyper-parameters during training """ +import numpy as np from domainlab.utils.logger import Logger +def list_true(list1): + """ + find out position of a list which has element True + """ + arr_pos = np.arange(len(list1))[list1] + return list(arr_pos) + + def list_add(list1, list2): """ add two lists @@ -71,8 +80,12 @@ def observe(self, epo_reg_loss): list_comparison_above_setpoint = [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] flag_increase = any(list_comparison_increase) flag_above_setpoint = any(list_comparison_above_setpoint) - if flag_increase and flag_above_setpoint: + if flag_increase or flag_above_setpoint: print("\n\n\n!!!!!!!setpoint too low!\n\n\n") # FIXME: rewind setpoing + list_pos = list_true(list_comparison_above_setpoint) + for pos in list_pos: + self.host.setpoint4R[pos] = self.epo_ma[pos] + self.host.transition_to(FixedSetpoint()) class FbOptSetpointController(): diff --git a/run_fbopt.sh b/run_fbopt.sh index 130f32bea..25ebda76e 100644 --- a/run_fbopt.sh +++ b/run_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=50 --mu_init=1.0 --coeff_ma_output=0 --coeff_ma_setpoint=0 --coeff_ma_output=0 +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=200 --mu_init=1.0 --coeff_ma_output=0 --coeff_ma_setpoint=0 --coeff_ma_output=0 From 6bbb8074396c11099013b85397fab52f1b5e329a Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 11:06:24 +0200 Subject: [PATCH 303/762] . --- .../algos/trainers/fbopt_setpoint_ada.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index ee569944d..8d6f88e93 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -55,18 +55,18 @@ class SetpointRewinder(): rewind setpoint if current loss exponential moving average is bigger than setpoint """ def __init__(self, host): - self.counter = 0 - self.epo_ma = [0.0 for _ in range(10)] # FIXME self.host = host - self.coeff_ma = 0.5 + self.counter = None + self.epo_ma = None self.ref = None + self.coeff_ma = 0.5 def reset(self, epo_reg_loss): """ when setpoint is adjusted """ self.counter = 0 - self.epo_ma = 0.0 + self.epo_ma = [0.0 for _ in range(10)] # FIXME self.ref = epo_reg_loss def observe(self, epo_reg_loss): @@ -74,16 +74,23 @@ def observe(self, epo_reg_loss): update moving average """ if self.ref is None: - self.ref = epo_reg_loss + self.reset(epo_reg_loss) self.epo_ma = list_ma(self.epo_ma, epo_reg_loss, self.coeff_ma) list_comparison_increase = [a < b for a, b in zip(self.ref, self.epo_ma)] list_comparison_above_setpoint = [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] flag_increase = any(list_comparison_increase) flag_above_setpoint = any(list_comparison_above_setpoint) - if flag_increase or flag_above_setpoint: - print("\n\n\n!!!!!!!setpoint too low!\n\n\n") # FIXME: rewind setpoing + if flag_increase and flag_above_setpoint: + self.counter += 1 + + else: + self.counter = 0 + + if self.counter > 3: list_pos = list_true(list_comparison_above_setpoint) + print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") # FIXME: rewind setpoing for pos in list_pos: + self.reset() self.host.setpoint4R[pos] = self.epo_ma[pos] self.host.transition_to(FixedSetpoint()) From 8408cf8d193a9c839914a16967a5fbcabf75783e Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 11:10:59 +0200 Subject: [PATCH 304/762] . --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 8d6f88e93..ce4d0ea4e 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -85,8 +85,9 @@ def observe(self, epo_reg_loss): else: self.counter = 0 + self.reset(epo_reg_loss) - if self.counter > 3: + if self.counter > 10: list_pos = list_true(list_comparison_above_setpoint) print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") # FIXME: rewind setpoing for pos in list_pos: From 1d3dd7a8a1b2d65a3b3d6a775071af26646368b0 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 11:17:37 +0200 Subject: [PATCH 305/762] tensorboard --- domainlab/algos/trainers/fbopt_alternate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 0a369f345..9db848f38 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -143,10 +143,10 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, dict_theta=None, m self.writer.add_scalar(f'mmu/{key}', val, miter) for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoint4R())): - self.writer.add_scalar(f'reg/dyn{i}', reg_dyn, miter) - self.writer.add_scalar(f'reg/setpoint{i}', reg_set, miter) + self.writer.add_scalar(f'regd/dyn{i}', reg_dyn, miter) + self.writer.add_scalar(f'regs/setpoint{i}', reg_set, miter) - self.writer.add_scalars(f'reg/dyn{i} & reg/setpoint{i}', { + self.writer.add_scalars(f'regds/dyn{i} & reg/setpoint{i}', { f'reg/dyn{i}': reg_dyn, f'reg/setpoint{i}': reg_set, }, miter) From d759a702636a37c0ed04261b0d7f5d96299f53b9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 11:25:34 +0200 Subject: [PATCH 306/762] . --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index ce4d0ea4e..313df7389 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -87,12 +87,13 @@ def observe(self, epo_reg_loss): self.counter = 0 self.reset(epo_reg_loss) - if self.counter > 10: + if self.counter > 100: list_pos = list_true(list_comparison_above_setpoint) print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") # FIXME: rewind setpoing for pos in list_pos: - self.reset() + self.reset(epo_reg_loss) self.host.setpoint4R[pos] = self.epo_ma[pos] + print(f"\n\n\n!!!!!!!updating setpoint at pos {pos} to {self.epo_ma[pos]}!\n\n\n") self.host.transition_to(FixedSetpoint()) From dd498ed9e5a6239a63cb9bed150cb79fd65a02f8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 11:43:09 +0200 Subject: [PATCH 307/762] never reset setpoing --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 313df7389..a8432b183 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -87,9 +87,9 @@ def observe(self, epo_reg_loss): self.counter = 0 self.reset(epo_reg_loss) - if self.counter > 100: + if self.counter > np.inf: # FIXME list_pos = list_true(list_comparison_above_setpoint) - print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") # FIXME: rewind setpoing + print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") # FIXME: rewind setpoint for pos in list_pos: self.reset(epo_reg_loss) self.host.setpoint4R[pos] = self.epo_ma[pos] From 9c947e4ae8f72532beeb2cd7d2bb65288c6408e1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 12:11:58 +0200 Subject: [PATCH 308/762] . --- domainlab/algos/trainers/args_fbopt.py | 9 ++++----- domainlab/algos/trainers/fbopt_setpoint_ada.py | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index eac6ba19c..059fb32fc 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -22,13 +22,12 @@ def add_args2parser_fbopt(parser): parser.add_argument('--coeff_ma', type=float, default=0.5, help='exponential moving average') - - parser.add_argument('--coeff_ma_output_state', type=float, default=0.5, + + parser.add_argument('--coeff_ma_output_state', type=float, default=0.0, help='setpoint output as state exponential moving average') - - parser.add_argument('--coeff_ma_setpoint', type=float, default=0.5, + + parser.add_argument('--coeff_ma_setpoint', type=float, default=0.0, help='setpoint average') - parser.add_argument('--exp_shoulder_clip', type=float, default=10, help='clip before exponential operation') diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index a8432b183..2e70c1ed5 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -152,6 +152,7 @@ def observe(self, epo_reg_loss, epo_task_loss): if self.state_updater.update_setpoint(): self.setpoint_rewinder.reset(epo_reg_loss) logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"!!!!!set point old value {self.setpoint4R}!") self.update_setpoint_ma(self.state_epo_reg_loss) logger.info(f"!!!!!set point updated to {self.setpoint4R}!") From e121c7e34b80d1e2fc45eb82b1fbd3bc143e5d20 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 12:27:39 +0200 Subject: [PATCH 309/762] fix bug of updating all setpoings --- domainlab/algos/trainers/fbopt_alternate.py | 2 +- .../algos/trainers/fbopt_setpoint_ada.py | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 9db848f38..c47626fc3 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -190,6 +190,6 @@ def dict_multiply(self, dict_base, list_multiplier): def update_setpoint(self, epo_reg_loss, epo_task_loss): """ - FIXME: setpoint should also be able to be eliviated + update setpoint """ self.set_point_controller.observe(epo_reg_loss, epo_task_loss) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 2e70c1ed5..39bff5121 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -32,7 +32,7 @@ def is_less_list_any(list1, list2): judge if one list is less than the other """ list_comparison = [a < b for a, b in zip(list1, list2)] - return any(list_comparison) + return any(list_comparison), list_true(list_comparison) def is_less_list_all(list1, list2): @@ -128,18 +128,17 @@ def transition_to(self, state): self.state_updater = state self.state_updater.accept(self) - def update_setpoint_ma(self, list_target): + def update_setpoint_ma(self, list_target, list_pos): """ using moving average """ target_ma = [self.coeff_ma_setpoint * a + (1 - self.coeff_ma_setpoint) * b for a, b in zip(self.setpoint4R, list_target)] - self.setpoint4R = target_ma + self.setpoint4R = [target_ma[i] for i in list_pos] def observe(self, epo_reg_loss, epo_task_loss): """ read current epo_reg_loss continuously - FIXME: setpoint should also be able to be eliviated """ self.state_epo_reg_loss = [self.coeff_ma_output*a + (1-self.coeff_ma_output)*b if a != 0.0 else b @@ -149,11 +148,12 @@ def observe(self, epo_reg_loss, epo_task_loss): self.state_task_loss = self.coeff_ma_output * self.state_task_loss + \ (1-self.coeff_ma_output) * epo_task_loss self.setpoint_rewinder.observe(epo_reg_loss) - if self.state_updater.update_setpoint(): + flag_update, list_pos = self.state_updater.update_setpoint() + if flag_update: self.setpoint_rewinder.reset(epo_reg_loss) logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"!!!!!set point old value {self.setpoint4R}!") - self.update_setpoint_ma(self.state_epo_reg_loss) + self.update_setpoint_ma(self.state_epo_reg_loss, list_pos) logger.info(f"!!!!!set point updated to {self.setpoint4R}!") @@ -205,10 +205,11 @@ def update_setpoint(self): """ if any component of R has decreased regardless if ell decreases """ - if is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R): + flag, list_pos = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) + if flag: self.host.transition_to(SliderAllComponent()) - return True - return False + return True, list_pos + return False, list_pos class DominateAnyComponent(FbOptSetpointControllerState): @@ -219,11 +220,11 @@ def update_setpoint(self): """ if any of the component of R loss has decreased together with ell loss """ - flag1 = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) + flag1, list_pos = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: self.host.setpoint4ell = self.host.state_task_loss - return flag1 & flag2 + return flag1 & flag2, list_pos class DominateAllComponent(FbOptSetpointControllerState): From b7bce15b0ea5a70108f00cee784f32fb39fb57a2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 12:30:21 +0200 Subject: [PATCH 310/762] fix bug --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 39bff5121..1e0482710 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -134,7 +134,7 @@ def update_setpoint_ma(self, list_target, list_pos): """ target_ma = [self.coeff_ma_setpoint * a + (1 - self.coeff_ma_setpoint) * b for a, b in zip(self.setpoint4R, list_target)] - self.setpoint4R = [target_ma[i] for i in list_pos] + self.setpoint4R = [target_ma[i] if i in list_pos else self.setpoint4R[i] for i in len(target_ma)] def observe(self, epo_reg_loss, epo_task_loss): """ From afa45fe29692e3680d83a3f969265de12c4c70ee Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 12:32:56 +0200 Subject: [PATCH 311/762] fix --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 1e0482710..adf5117a3 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -134,7 +134,7 @@ def update_setpoint_ma(self, list_target, list_pos): """ target_ma = [self.coeff_ma_setpoint * a + (1 - self.coeff_ma_setpoint) * b for a, b in zip(self.setpoint4R, list_target)] - self.setpoint4R = [target_ma[i] if i in list_pos else self.setpoint4R[i] for i in len(target_ma)] + self.setpoint4R = [target_ma[i] if i in list_pos else self.setpoint4R[i] for i in range(len(target_ma))] def observe(self, epo_reg_loss, epo_task_loss): """ From 0a2bdca9850a2e46acc1616577b7c55a3b39f7e7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 12:43:33 +0200 Subject: [PATCH 312/762] . --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index adf5117a3..8666479f0 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -87,16 +87,17 @@ def observe(self, epo_reg_loss): self.counter = 0 self.reset(epo_reg_loss) - if self.counter > np.inf: # FIXME + if self.counter > 1: # FIXME list_pos = list_true(list_comparison_above_setpoint) - print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") # FIXME: rewind setpoint + print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") for pos in list_pos: - self.reset(epo_reg_loss) self.host.setpoint4R[pos] = self.epo_ma[pos] print(f"\n\n\n!!!!!!!updating setpoint at pos {pos} to {self.epo_ma[pos]}!\n\n\n") + self.reset(epo_reg_loss) self.host.transition_to(FixedSetpoint()) + class FbOptSetpointController(): """ update setpoint for mu From 53b103a38c3a0b59ae872bd8f1e5f70fd6fbd0c4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 12:51:39 +0200 Subject: [PATCH 313/762] coverage --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 8666479f0..6c89b2ab8 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -182,7 +182,7 @@ def update_setpoint(self): """ always return False so setpoint no update """ - return False + return False, None class SliderAllComponent(FbOptSetpointControllerState): @@ -194,8 +194,8 @@ def update_setpoint(self): all components of R descreases regardless if ell decreases or not """ if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R): - return True - return False + return True, list(range(len(self.host.setpoint4R))) + return False, None class SliderAnyComponent(FbOptSetpointControllerState): @@ -240,4 +240,4 @@ def update_setpoint(self): flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: self.host.setpoint4ell = self.host.state_task_loss - return flag1 & flag2 + return flag1 & flag2, list(range(len(self.host.setpoint4R))) From 59504760fa9f99080a0419623b438a7a78026dcc Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 12:53:44 +0200 Subject: [PATCH 314/762] . --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 6c89b2ab8..5ea07ee50 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -91,8 +91,9 @@ def observe(self, epo_reg_loss): list_pos = list_true(list_comparison_above_setpoint) print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") for pos in list_pos: + print(f"\n\n\n!!!!!!!rewinding setpoint at pos {pos} \ + from {self.host.setpoint4R[pos]} to {self.epo_ma[pos]}!\n\n\n") self.host.setpoint4R[pos] = self.epo_ma[pos] - print(f"\n\n\n!!!!!!!updating setpoint at pos {pos} to {self.epo_ma[pos]}!\n\n\n") self.reset(epo_reg_loss) self.host.transition_to(FixedSetpoint()) From 43b89111194f1ad3d9af3f0e837f4c5c3b0ff386 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 13:01:09 +0200 Subject: [PATCH 315/762] . --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 5ea07ee50..99265d23f 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -87,14 +87,15 @@ def observe(self, epo_reg_loss): self.counter = 0 self.reset(epo_reg_loss) - if self.counter > 1: # FIXME + if self.counter > 1 and self.counter < 10: # FIXME list_pos = list_true(list_comparison_above_setpoint) print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") for pos in list_pos: print(f"\n\n\n!!!!!!!rewinding setpoint at pos {pos} \ from {self.host.setpoint4R[pos]} to {self.epo_ma[pos]}!\n\n\n") self.host.setpoint4R[pos] = self.epo_ma[pos] - self.reset(epo_reg_loss) + + if self.counter > 10: self.host.transition_to(FixedSetpoint()) From 7df734afca46280e8099af7db2244ed928258e81 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 15:09:16 +0200 Subject: [PATCH 316/762] better tensorboard --- domainlab/algos/trainers/fbopt_alternate.py | 19 ++++++++++--------- .../algos/trainers/train_mu_controller.py | 2 ++ domainlab/models/model_diva.py | 7 +++++++ domainlab/models/model_jigen.py | 4 ++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index c47626fc3..6010c0ea2 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -112,7 +112,7 @@ def cal_delta_integration(self, list_old, list_new, coeff): """ return [(1-coeff)*a + coeff*b for a, b in zip(list_old, list_new)] - def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, dict_theta=None, miter=None): + def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, dict_theta=None, miter=None): """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value @@ -143,14 +143,15 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, dict_theta=None, m self.writer.add_scalar(f'mmu/{key}', val, miter) for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoint4R())): - self.writer.add_scalar(f'regd/dyn{i}', reg_dyn, miter) - self.writer.add_scalar(f'regs/setpoint{i}', reg_set, miter) - - self.writer.add_scalars(f'regds/dyn{i} & reg/setpoint{i}', { - f'reg/dyn{i}': reg_dyn, - f'reg/setpoint{i}': reg_set, - }, miter) - self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{i}', reg_dyn, epo_task_loss) + self.writer.add_scalar(f'regd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) + self.writer.add_scalar(f'regs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) + + self.writer.add_scalars( + f'regds/dyn_{list_str_multiplier_na[i]} with setpoint', + {f'reg/dyn_{list_str_multiplier_na[i]}': reg_dyn, + f'reg/setpoint_{list_str_multiplier_na[i]}': reg_set, + }, miter) + self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{list_str_multiplier_na[i]}', reg_dyn, epo_task_loss) self.writer.add_scalar('loss_penalized', epo_loss_tr, miter) self.writer.add_scalar('task', epo_task_loss, miter) acc_te = 0 diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index c015930c4..488fcfc18 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -84,6 +84,7 @@ def before_tr(self): self.hyper_scheduler.set_setpoint( [ele * self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) + self.list_str_multiplier_na = self.model.list_str_multiplier_na def tr_epoch(self, epoch): """ @@ -94,6 +95,7 @@ def tr_epoch(self, epoch): self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr, + self.list_str_multiplier_na, dict(self.model.named_parameters()), miter=epoch) self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 305be1162..a17a6efa7 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -107,6 +107,13 @@ def get_list_str_y(self): """get_list_str_y.""" return self._list_str_y + @property + def list_str_multiplier_na(self): + """ + list of multipliers name + """ + return ["mu_recon", "beta_d", "beta_y", "beta_x", "beta_y", "gamma_d"] + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): q_zd, zd_q, q_zx, zx_q, q_zy, zy_q = self.encoder(tensor_x) logit_d = self.net_classif_d(zd_q) diff --git a/domainlab/models/model_jigen.py b/domainlab/models/model_jigen.py index 42dba6c92..7c55cf4f0 100644 --- a/domainlab/models/model_jigen.py +++ b/domainlab/models/model_jigen.py @@ -65,6 +65,10 @@ def __init__(self, list_str_y, list_str_d, self.net_classifier_class = net_classifier_class self.net_classifier_permutation = net_classifier_permutation + @property + def list_str_multiplier_na(self): + return ["alpha"] + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): """ JiGen don't need domain label but a pre-defined permutation index From 9a242d0a3ff55d0d099d8682534381a04a59feca Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 15:20:31 +0200 Subject: [PATCH 317/762] rname diva --- domainlab/algos/builder_diva.py | 2 +- domainlab/algos/trainers/args_fbopt.py | 2 +- domainlab/models/model_diva.py | 10 +++++----- examples/benchmark/benchmark_fbopt_mnist_diva.yaml | 8 ++++---- examples/benchmark/benchmark_fbopt_pacs_diva.yaml | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/domainlab/algos/builder_diva.py b/domainlab/algos/builder_diva.py index e3e5256cd..adf59df67 100644 --- a/domainlab/algos/builder_diva.py +++ b/domainlab/algos/builder_diva.py @@ -35,7 +35,7 @@ def init_business(self, exp): request = RequestVAEBuilderCHW( task.isize.c, task.isize.h, task.isize.w, args) node = VAEChainNodeGetter(request)() - model = mk_diva(str_mu=args.str_mu)(node, + model = mk_diva(str_diva_multiplier_type=args.str_diva_multiplier_type)(node, zd_dim=args.zd_dim, zy_dim=args.zy_dim, zx_dim=args.zx_dim, diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 059fb32fc..a500feba3 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -42,7 +42,7 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') - parser.add_argument('--str_mu', type=str, default="gammad_recon", help='which penalty to tune') + parser.add_argument('--str_diva_multiplier_type', type=str, default="gammad_recon", help='which penalty to tune') # the following hyperparamters do not need to be tuned diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index a17a6efa7..636e9943b 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -9,7 +9,7 @@ from domainlab.utils.utils_class import store_args -def mk_diva(parent_class=VAEXYDClassif, str_mu="default"): +def mk_diva(parent_class=VAEXYDClassif, str_diva_multiplier_type="default"): """ Instantiate a domain invariant variational autoencoder (DIVA) with arbitrary task loss. @@ -206,10 +206,10 @@ def hyper_init(self, functor_scheduler, trainer=None): class ModelDIVADefault(ModelDIVA): """ """ - if str_mu == "gammad_recon": + if str_diva_multiplier_type == "gammad_recon": return ModelDIVAGammadRecon - if str_mu == "gammad": + if str_diva_multiplier_type == "gammad": return ModelDIVAGammad - if str_mu == "default": + if str_diva_multiplier_type == "default": return ModelDIVADefault - raise RuntimeError("not support argument candiates for str_mu: allowed: default, gammad_recon, gammad") + raise RuntimeError("not support argument candiates for str_diva_multiplier_type: allowed: default, gammad_recon, gammad") diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml index 35ecb3b20..ef2d48211 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_mnist_diva.yaml @@ -71,7 +71,7 @@ Shared params: diva_fbopt_a: aname: diva trainer: fbopt - str_mu: gammad_recon + str_diva_multiplier_type: gammad_recon gamma_y: 1.0 init_setpoint_ratio: 0.99 @@ -82,7 +82,7 @@ diva_fbopt_a: diva_feedforward_a: aname: diva trainer: hyperscheduler - str_mu: gammad_recon + str_diva_multiplier_type: gammad_recon gamma_y: 1.0 shared: - gamma_d @@ -90,7 +90,7 @@ diva_feedforward_a: diva_default: aname: diva trainer: hyperscheduler - str_mu: default + str_diva_multiplier_type: default shared: - gamma_d - gamma_y @@ -98,7 +98,7 @@ diva_default: diva_fixed_penalty: aname: diva trainer: basic - str_mu: default + str_diva_multiplier_type: default shared: - gamma_d - gamma_y diff --git a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml index 81a6a4e9a..a577c8a62 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml @@ -72,7 +72,7 @@ Shared params: diva_fbopt_full: aname: diva trainer: fbopt - str_mu: gammad_recon + str_diva_multiplier_type: gammad_recon gamma_y: 1.0 ini_setpoint_ratio: 0.99 shared: @@ -82,7 +82,7 @@ diva_fbopt_full: diva_feedforward_full: aname: diva trainer: hyperscheduler - str_mu: gammad_recon + str_diva_multiplier_type: gammad_recon gamma_y: 1.0 shared: - gamma_d @@ -90,7 +90,7 @@ diva_feedforward_full: diva_default: aname: diva trainer: hyperscheduler - str_mu: default + str_diva_multiplier_type: default shared: - gamma_d - gamma_y @@ -98,7 +98,7 @@ diva_default: diva_fixed_penalty: aname: diva trainer: basic - str_mu: default + str_diva_multiplier_type: default shared: - gamma_d - gamma_y From 6008691e293a580bf86b5c93d15b445763e9a19f Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 15:27:55 +0200 Subject: [PATCH 318/762] fix str --- domainlab/algos/trainers/fbopt_alternate.py | 2 +- domainlab/models/model_diva.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 6010c0ea2..213b476cb 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -141,7 +141,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie for key, val in self.mmu.items(): self.writer.add_scalar(f'mmu/{key}', val, miter) - + breakpoint() for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoint4R())): self.writer.add_scalar(f'regd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) self.writer.add_scalar(f'regs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 636e9943b..c4a4a024a 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -9,7 +9,7 @@ from domainlab.utils.utils_class import store_args -def mk_diva(parent_class=VAEXYDClassif, str_diva_multiplier_type="default"): +def mk_diva(parent_class=VAEXYDClassif, str_diva_multiplier_type="default"): # FIXME: should not be default """ Instantiate a domain invariant variational autoencoder (DIVA) with arbitrary task loss. @@ -112,7 +112,7 @@ def list_str_multiplier_na(self): """ list of multipliers name """ - return ["mu_recon", "beta_d", "beta_y", "beta_x", "beta_y", "gamma_d"] + return ["mu_recon", "beta_d", "beta_x", "beta_y", "gamma_d"] def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): q_zd, zd_q, q_zx, zx_q, q_zy, zy_q = self.encoder(tensor_x) @@ -168,11 +168,11 @@ def hyper_init(self, functor_scheduler, trainer=None): """ return functor_scheduler( trainer=trainer, - mu_recon=self.mu_recon, beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, gamma_d=self.gamma_d, + mu_recon=self.mu_recon ) From cfa94f2010456004af1178abe8d1da9fa6cf75bd Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 15:29:48 +0200 Subject: [PATCH 319/762] remove breakpoint --- domainlab/algos/trainers/fbopt_alternate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 213b476cb..8b36bb83a 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -141,7 +141,6 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie for key, val in self.mmu.items(): self.writer.add_scalar(f'mmu/{key}', val, miter) - breakpoint() for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoint4R())): self.writer.add_scalar(f'regd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) self.writer.add_scalar(f'regs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) From 752fdce36b0c297740ed16e5ed13217fdb4d53ab Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 15:46:58 +0200 Subject: [PATCH 320/762] fix issue #515 --- domainlab/algos/trainers/train_mu_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index 488fcfc18..ecc22dc2c 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -82,7 +82,7 @@ def before_tr(self): self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() self.hyper_scheduler.set_setpoint( - [ele * self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], + [ele * self.aconf.ini_setpoint_ratio if ele > 0 else ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) self.list_str_multiplier_na = self.model.list_str_multiplier_na From 55b756225cfb378f0430b300420e19e436f53f87 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 16:02:03 +0200 Subject: [PATCH 321/762] first update than train --- domainlab/algos/trainers/train_mu_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index ecc22dc2c..b34965820 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -90,7 +90,6 @@ def tr_epoch(self, epoch): """ update hyper-parameters only per epoch """ - flag = super().tr_epoch(epoch) self.hyper_scheduler.search_mu( self.epo_reg_loss_tr, self.epo_task_loss_tr, @@ -99,4 +98,5 @@ def tr_epoch(self, epoch): dict(self.model.named_parameters()), miter=epoch) self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) + flag = super().tr_epoch(epoch) return flag From 7d9015755b6609ab0f580d529411cc2baff00dca Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 11 Oct 2023 16:16:47 +0200 Subject: [PATCH 322/762] only increase setpoing once --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 99265d23f..83a22c627 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -87,7 +87,7 @@ def observe(self, epo_reg_loss): self.counter = 0 self.reset(epo_reg_loss) - if self.counter > 1 and self.counter < 10: # FIXME + if self.counter > 1 and self.counter < 10: # FIXME: I use arbitray 10 to say that setpoint can only be alleviated twice list_pos = list_true(list_comparison_above_setpoint) print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") for pos in list_pos: @@ -95,8 +95,9 @@ def observe(self, epo_reg_loss): from {self.host.setpoint4R[pos]} to {self.epo_ma[pos]}!\n\n\n") self.host.setpoint4R[pos] = self.epo_ma[pos] - if self.counter > 10: + if self.counter > 2: self.host.transition_to(FixedSetpoint()) + self.counter = np.inf # FIXME From 5c7f22584ba091975685c3072d572280b1114ca3 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 18:46:23 +0200 Subject: [PATCH 323/762] Update model_dann.py --- domainlab/models/model_dann.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/models/model_dann.py b/domainlab/models/model_dann.py index a98c399ef..be25ab73e 100644 --- a/domainlab/models/model_dann.py +++ b/domainlab/models/model_dann.py @@ -57,6 +57,10 @@ def __init__(self, list_str_y, list_str_d, self.net_encoder = net_encoder self.net_classifier = net_classifier self.net_discriminator = net_discriminator + + @property + def list_str_multiplier_na(self): + return ["alpha"] def hyper_update(self, epoch, fun_scheduler): """hyper_update. From 2ed6616e9bf21cd6a8093e40dbfcdd4255bb78f1 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 21:54:50 +0200 Subject: [PATCH 324/762] Update fbopt_alternate.py --- domainlab/algos/trainers/fbopt_alternate.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 8612c8a5b..a2069b8e3 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -59,6 +59,7 @@ def __init__(self, trainer, **kwargs): ######################################## self.set_point_controller = FbOptSetpointController(args=self.trainer.aconf) self.k_i_control = trainer.aconf.k_i_gain + self.overshoot_rewind = True self.delta_epsilon_r = False # False here just used to decide if value first use or not # NOTE: this value will be set according to initial evaluation of neural network self.mu_clip = trainer.aconf.mu_clip @@ -119,7 +120,6 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie to see if the criteria is met $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-epsilon_R])$$ """ - # FIXME: use dictionary to replace scalar representation delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.get_setpoint4R()) # TODO: can be replaced by a controller if self.delta_epsilon_r is False: @@ -139,8 +139,10 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b else None for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] for ind in list_overshoot: if ind is not None: - print(f"overshooting at pos {ind}, PID controller set to zero now") - activation[ind] = 0.0 + print(f"overshooting at pos {ind} of {activation}) + if self.overshoot_rewind: + activation[ind] = 0.0 + print(f"PID controller set to zero now {activation}") list_gain = np.exp(activation) target = self.dict_multiply(self.mmu, list_gain) self.mmu = self.dict_clip(target) From 509391cb0e0759e2e0e37aa79fbe8ab8f9ab512e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 21:58:54 +0200 Subject: [PATCH 325/762] Update args_fbopt.py --- domainlab/algos/trainers/args_fbopt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index a500feba3..46817476d 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -42,6 +42,9 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') + parser.add_argument('--overshoot_rewind', type='str', default="yes", + help='overshoot_rewind, for benchmark, use yes or no') + parser.add_argument('--str_diva_multiplier_type', type=str, default="gammad_recon", help='which penalty to tune') From 25aa9018c4f4dd2d6a5e41774602cc6c1f06a06e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 21:59:57 +0200 Subject: [PATCH 326/762] Update fbopt_alternate.py --- domainlab/algos/trainers/fbopt_alternate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index a2069b8e3..5f348821f 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -59,7 +59,7 @@ def __init__(self, trainer, **kwargs): ######################################## self.set_point_controller = FbOptSetpointController(args=self.trainer.aconf) self.k_i_control = trainer.aconf.k_i_gain - self.overshoot_rewind = True + self.overshoot_rewind = trainer.aconf.overshoot_rewind == "yes" self.delta_epsilon_r = False # False here just used to decide if value first use or not # NOTE: this value will be set according to initial evaluation of neural network self.mu_clip = trainer.aconf.mu_clip From a84eb3114b1b74f0eb7436502a2be85b2f3705c7 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 22:11:14 +0200 Subject: [PATCH 327/762] Update fbopt_setpoint_ada.py --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 83a22c627..6ef014c2f 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -87,7 +87,7 @@ def observe(self, epo_reg_loss): self.counter = 0 self.reset(epo_reg_loss) - if self.counter > 1 and self.counter < 10: # FIXME: I use arbitray 10 to say that setpoint can only be alleviated twice + if self.counter > 1 and self.counter <= 3: # only allow self.counter = 2, 3 to rewind setpoing twice list_pos = list_true(list_comparison_above_setpoint) print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") for pos in list_pos: From 19e95f7b81e41b11be48482e649d0baa1724e09e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 22:16:00 +0200 Subject: [PATCH 328/762] Update test_fbopt.py --- tests/test_fbopt.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/test_fbopt.py b/tests/test_fbopt.py index bfe9ef3c6..909e125b2 100644 --- a/tests/test_fbopt.py +++ b/tests/test_fbopt.py @@ -4,9 +4,24 @@ from tests.utils_test import utils_test_algo -def test_deepall_fbopt(): +def test_dann_fbopt(): """ - train DeepAll with MLDG + dann """ args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=dann --trainer=fbopt --nname=alexnet --epos=3" utils_test_algo(args) + + +def test_jigen_fbopt(): + """ + jigen + """ + args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=jigen --trainer=fbopt --nname=alexnet --epos=3" + utils_test_algo(args) + +def test_diva_fbopt(): + """ + diva + """ + args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=diva --gamma_y=1.0 --trainer=fbopt --nname=alexnet --epos=3" + utils_test_algo(args) From 1a2655526f59debed86262ac9a2b8bcbe89d7ccd Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 22:42:23 +0200 Subject: [PATCH 329/762] Create fbopt_pacs_jigen_alone --- examples/benchmark/fbopt_pacs_jigen_alone | 67 +++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 examples/benchmark/fbopt_pacs_jigen_alone diff --git a/examples/benchmark/fbopt_pacs_jigen_alone b/examples/benchmark/fbopt_pacs_jigen_alone new file mode 100644 index 000000000..354ce3689 --- /dev/null +++ b/examples/benchmark/fbopt_pacs_jigen_alone @@ -0,0 +1,67 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full + +sampling_seed: 0 + +startseed: 0 +endseed: 4 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 5 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + pperm: 0.5 + + +Shared params: + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: loguniform + + mu_init: + min: 0.000001 + max: 0.00005 + num: 3 + distribution: loguniform + + pperm: + min: 0.1 + max: 0.9 + num: 3 + distribution: uniform + + gamma_reg: + min: 0.01 + max: 10_000 + num: 10 + distribution: loguniform + +# Test fbopt with different hyperparameter configurations + +jigen_feedback: + aname: jigen + trainer: fbopt + ini_setpoint_ratio: 0.99 + shared: + - k_i_gain + - mu_init From 0b1084d01288a92917c85b041d4a0ee352b4f404 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 22:43:52 +0200 Subject: [PATCH 330/762] Create fbopt_pacs_diva_alone --- examples/benchmark/fbopt_pacs_diva_alone | 80 ++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 examples/benchmark/fbopt_pacs_diva_alone diff --git a/examples/benchmark/fbopt_pacs_diva_alone b/examples/benchmark/fbopt_pacs_diva_alone new file mode 100644 index 000000000..5ff7280b5 --- /dev/null +++ b/examples/benchmark/fbopt_pacs_diva_alone @@ -0,0 +1,80 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 10 + bs: 64 + san_check: True + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 1000_000 + coeff_ma: 0.5 + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + + + +Shared params: + ini_setpoint_ratio: + min: 0.9 + max: 0.99 + num: 3 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations + +diva_fbopt_full: + aname: diva + trainer: fbopt + str_diva_multiplier_type: gammad_recon + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + shared: + - k_i_gain + - mu_init From 6e1e7a3cf430c7a31effbc545a28f6b47b248521 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 22:54:33 +0200 Subject: [PATCH 331/762] Update fbopt_alternate.py --- domainlab/algos/trainers/fbopt_alternate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 5f348821f..f035559d3 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -139,7 +139,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b else None for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] for ind in list_overshoot: if ind is not None: - print(f"overshooting at pos {ind} of {activation}) + print(f"overshooting at pos {ind} of {activation}") if self.overshoot_rewind: activation[ind] = 0.0 print(f"PID controller set to zero now {activation}") From 34bc348bb8d79aa12d053506548cea8f43415437 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 23:11:40 +0200 Subject: [PATCH 332/762] Create fbopt_mnist_diva_alone.yaml --- .../benchmark/fbopt_mnist_diva_alone.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 examples/benchmark/fbopt_mnist_diva_alone.yaml diff --git a/examples/benchmark/fbopt_mnist_diva_alone.yaml b/examples/benchmark/fbopt_mnist_diva_alone.yaml new file mode 100644 index 000000000..ef2d48211 --- /dev/null +++ b/examples/benchmark/fbopt_mnist_diva_alone.yaml @@ -0,0 +1,107 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt + +sampling_seed: 0 +startseed: 0 +endseed: 4 + +test_domains: + - 0 + + +domainlab_args: + task: mnistcolor10 + tr_d: [1, 2] + dmem: False + lr: 0.001 + epos: 500 + es: 50 + bs: 64 + zx_dim: 0 + zy_dim: 32 + zd_dim: 32 + nname: conv_bn_pool_2 + nname_dom: conv_bn_pool_2 + nname_topic_distrib_img2topic: conv_bn_pool_2 + nname_encoder_sandwich_layer_img2h4zd: conv_bn_pool_2 + san_check: False + exp_shoulder_clip: 5.0 + mu_clip: 1000_000 + coeff_ma: 0.5 + no_tensorboard: False + + + +Shared params: + ini_setpoint_ratio: + min: 0.9 + max: 0.99 + num: 3 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: loguniform + + mu_init: + min: 0.000001 + max: 0.00001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + +# Test fbopt with different hyperparameter configurations + +diva_fbopt_a: + aname: diva + trainer: fbopt + str_diva_multiplier_type: gammad_recon + gamma_y: 1.0 + init_setpoint_ratio: 0.99 + + shared: + - k_i_gain + - mu_init + +diva_feedforward_a: + aname: diva + trainer: hyperscheduler + str_diva_multiplier_type: gammad_recon + gamma_y: 1.0 + shared: + - gamma_d + +diva_default: + aname: diva + trainer: hyperscheduler + str_diva_multiplier_type: default + shared: + - gamma_d + - gamma_y + +diva_fixed_penalty: + aname: diva + trainer: basic + str_diva_multiplier_type: default + shared: + - gamma_d + - gamma_y + +erm: + aname: deepall From 8be6650141a0d82644ed78cbae4633844f299bb9 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 11 Oct 2023 23:20:10 +0200 Subject: [PATCH 333/762] Update args_fbopt.py --- domainlab/algos/trainers/args_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 46817476d..b80a23524 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -42,7 +42,7 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') - parser.add_argument('--overshoot_rewind', type='str', default="yes", + parser.add_argument('--overshoot_rewind', type=str, default="yes", help='overshoot_rewind, for benchmark, use yes or no') parser.add_argument('--str_diva_multiplier_type', type=str, default="gammad_recon", help='which penalty to tune') From 99ec6f3f955b887a139521ea22bb0b5088d50759 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 08:23:33 +0200 Subject: [PATCH 334/762] Create pacs_diva_others.yaml --- examples/benchmark/pacs_diva_others.yaml | 94 ++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 examples/benchmark/pacs_diva_others.yaml diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml new file mode 100644 index 000000000..2547daf07 --- /dev/null +++ b/examples/benchmark/pacs_diva_others.yaml @@ -0,0 +1,94 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 10 + bs: 64 + san_check: True + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 1000_000 + coeff_ma: 0.5 + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + + + +Shared params: + ini_setpoint_ratio: + min: 0.9 + max: 0.99 + num: 3 + distribution: uniform + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + +diva_feedforward_full: + aname: diva + trainer: hyperscheduler + str_diva_multiplier_type: gammad_recon + gamma_y: 1.0 + shared: + - gamma_d + +diva_default: + aname: diva + trainer: hyperscheduler + str_diva_multiplier_type: default + shared: + - gamma_d + - gamma_y + +diva_fixed_penalty: + aname: diva + trainer: basic + str_diva_multiplier_type: default + shared: + - gamma_d + - gamma_y + +erm: + aname: deepall From 654a375a6d1ebd7c60518decf155f5a2ff81e427 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 10:08:21 +0200 Subject: [PATCH 335/762] logger --- domainlab/algos/trainers/fbopt_alternate.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index f035559d3..8239b6641 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -130,7 +130,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie # delta_epsilon_r is the current time step self.delta_epsilon_r = self.cal_delta_integration( self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) - # FIXME: here we can not sum up selta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary + # FIXME: here we can not sum up delta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary activation = [self.k_i_control * val for val in self.delta_epsilon_r] if self.activation_clip is not None: activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) @@ -139,10 +139,11 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b else None for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] for ind in list_overshoot: if ind is not None: - print(f"overshooting at pos {ind} of {activation}") + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"overshooting at pos {ind} of {activation}") if self.overshoot_rewind: - activation[ind] = 0.0 - print(f"PID controller set to zero now {activation}") + activation[ind] = 0.0 + logger.info(f"PID controller set to zero now {activation}") list_gain = np.exp(activation) target = self.dict_multiply(self.mmu, list_gain) self.mmu = self.dict_clip(target) @@ -158,7 +159,8 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie {f'reg/dyn_{list_str_multiplier_na[i]}': reg_dyn, f'reg/setpoint_{list_str_multiplier_na[i]}': reg_set, }, miter) - self.writer.add_scalar(f'x-axis=task vs y-axis=reg/dyn{list_str_multiplier_na[i]}', reg_dyn, epo_task_loss) + self.writer.add_scalar( + f'x-axis=task vs y-axis=reg/dyn{list_str_multiplier_na[i]}', reg_dyn, epo_task_loss) self.writer.add_scalar('loss_penalized', epo_loss_tr, miter) self.writer.add_scalar('task', epo_task_loss, miter) acc_te = 0 From 4d5b7be1be175e6e72df1d1ac752300a8f5c8050 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 10:21:23 +0200 Subject: [PATCH 336/762] rewind default to false --- .../algos/trainers/fbopt_setpoint_ada.py | 24 ++++++++++--------- .../algos/trainers/train_mu_controller.py | 3 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 6ef014c2f..ada473f8e 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -60,6 +60,7 @@ def __init__(self, host): self.epo_ma = None self.ref = None self.coeff_ma = 0.5 + self.setpoint_rewind = False def reset(self, epo_reg_loss): """ @@ -87,17 +88,18 @@ def observe(self, epo_reg_loss): self.counter = 0 self.reset(epo_reg_loss) - if self.counter > 1 and self.counter <= 3: # only allow self.counter = 2, 3 to rewind setpoing twice - list_pos = list_true(list_comparison_above_setpoint) - print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") - for pos in list_pos: - print(f"\n\n\n!!!!!!!rewinding setpoint at pos {pos} \ - from {self.host.setpoint4R[pos]} to {self.epo_ma[pos]}!\n\n\n") - self.host.setpoint4R[pos] = self.epo_ma[pos] - - if self.counter > 2: - self.host.transition_to(FixedSetpoint()) - self.counter = np.inf # FIXME + if self.setpoint_rewind: + if self.counter > 2 and self.counter <= 3: # only allow self.counter = 2, 3 to rewind setpoing twice + list_pos = list_true(list_comparison_above_setpoint) + print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") + for pos in list_pos: + print(f"\n\n\n!!!!!!!rewinding setpoint at pos {pos} \ + from {self.host.setpoint4R[pos]} to {self.epo_ma[pos]}!\n\n\n") + self.host.setpoint4R[pos] = self.epo_ma[pos] + + if self.counter > 3: + self.host.transition_to(FixedSetpoint()) + self.counter = np.inf # FIXME diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index b34965820..7a68c5f75 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -80,7 +80,8 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) - self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() + # self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() + super().tr_epoch(-1) self.hyper_scheduler.set_setpoint( [ele * self.aconf.ini_setpoint_ratio if ele > 0 else ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) From 0dcaff178138d510508bc9cd5126c23e4c305686 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 10:30:52 +0200 Subject: [PATCH 337/762] fix bug in diva, wrong multiplicatino --- domainlab/algos/trainers/fbopt_alternate.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index 8239b6641..f3a3b5f99 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -145,7 +145,9 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie activation[ind] = 0.0 logger.info(f"PID controller set to zero now {activation}") list_gain = np.exp(activation) - target = self.dict_multiply(self.mmu, list_gain) + dict_gain = {na: val for na, val in zip(list_str_multiplier_na, list_gain)} + target = self.dict_multiply(self.mmu, dict_gain) + breakpoint() self.mmu = self.dict_clip(target) for key, val in self.mmu.items(): @@ -188,14 +190,10 @@ def dict_is_zero(self, dict_mu): return True return False - def dict_multiply(self, dict_base, list_multiplier): + def dict_multiply(self, dict_base, dict_multiplier): """ multiply a float to each element of a dictionary """ - list_keys = list(dict_base.keys()) - list_zip = zip(list_keys, list_multiplier) - dict_multiplier = dict(list_zip) - # NOTE: allow multipler be bigger than 1 return {key: val*dict_multiplier[key] for key, val in dict_base.items()} def update_setpoint(self, epo_reg_loss, epo_task_loss): From e97e9a98547955f91fd9a920a737eb8449b2b691 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 10:33:12 +0200 Subject: [PATCH 338/762] remove breakpoint --- domainlab/algos/trainers/fbopt_alternate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index f3a3b5f99..fe68ebf1c 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -147,7 +147,6 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie list_gain = np.exp(activation) dict_gain = {na: val for na, val in zip(list_str_multiplier_na, list_gain)} target = self.dict_multiply(self.mmu, dict_gain) - breakpoint() self.mmu = self.dict_clip(target) for key, val in self.mmu.items(): From eaa3377de13797d542dd206783bd692f908adaed Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 11:53:56 +0200 Subject: [PATCH 339/762] . --- domainlab/algos/trainers/args_fbopt.py | 4 ++-- run_fbopt_mnist.sh | 2 +- run_fbopt_mnist_diva.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index b80a23524..536339bca 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -29,7 +29,7 @@ def add_args2parser_fbopt(parser): parser.add_argument('--coeff_ma_setpoint', type=float, default=0.0, help='setpoint average') - parser.add_argument('--exp_shoulder_clip', type=float, default=10, + parser.add_argument('--exp_shoulder_clip', type=float, default=5, help='clip before exponential operation') parser.add_argument('--ini_setpoint_ratio', type=float, default=0.99, @@ -43,7 +43,7 @@ def add_args2parser_fbopt(parser): help='disable setpoint update') parser.add_argument('--overshoot_rewind', type=str, default="yes", - help='overshoot_rewind, for benchmark, use yes or no') + help='overshoot_rewind, for benchmark, use yes or no') parser.add_argument('--str_diva_multiplier_type', type=str, default="gammad_recon", help='which penalty to tune') diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 0039893ea..44d8726b6 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_output_state=0.5 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 diff --git a/run_fbopt_mnist_diva.sh b/run_fbopt_mnist_diva.sh index 4ed25b720..5162770b7 100644 --- a/run_fbopt_mnist_diva.sh +++ b/run_fbopt_mnist_diva.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_output_state=0.5 --gamma_y=1.0 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=500 --mu_init=0.00001 --gamma_y=1.0 From 2d5fb21016aaefa3ab298f82d5ce9fad035dc239 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 12:00:31 +0200 Subject: [PATCH 340/762] remove irrelavent file --- domainlab/algos/trainers/fbopt.py | 171 --------------------- domainlab/algos/trainers/train_fbopt.py | 192 ------------------------ 2 files changed, 363 deletions(-) delete mode 100644 domainlab/algos/trainers/fbopt.py delete mode 100644 domainlab/algos/trainers/train_fbopt.py diff --git a/domainlab/algos/trainers/fbopt.py b/domainlab/algos/trainers/fbopt.py deleted file mode 100644 index d5c97b194..000000000 --- a/domainlab/algos/trainers/fbopt.py +++ /dev/null @@ -1,171 +0,0 @@ -""" -update hyper-parameters during training -""" -import copy -import numpy as np -from domainlab.utils.logger import Logger - - -class HyperSchedulerFeedback(): - """ - design $\\mu$$ sequence based on state of penalized loss - """ - def __init__(self, trainer, **kwargs): - """ - kwargs is a dictionary with key the hyper-parameter name and its value - """ - self.trainer = trainer - self.mmu = kwargs - self.mmu = {key: 0.0 for key, val in self.mmu.items()} - self.ploss_old_theta_old_mu = None - self.ploss_old_theta_new_mu = None - self.ploss_new_theta_old_mu = None - self.ploss_new_theta_new_mu = None - self.delta_mu = trainer.aconf.delta_mu - self.init_mu = trainer.aconf.mu_init - # for exponential increase of mu, mu can not be starting from zero - self.beta_mu = trainer.aconf.beta_mu - self.dict_theta_bar = None - self.dict_theta = copy.deepcopy(dict(self.trainer.model.named_parameters())) - # theta_ref should be equal to either theta or theta bar as reference - # since theta_ref will be used to judge if criteria is met - self.dict_theta_ref = None - self.budget_mu_per_step = trainer.aconf.budget_mu_per_step - self.budget_theta_update_per_mu = trainer.aconf.budget_theta_update_per_mu - self.count_found_operator = 0 - self.count_search_mu = 0 - - def update_anchor(self, dict_par): - """ - update the last ensured value of theta^{(k)} - """ - self.dict_theta = copy.deepcopy(dict_par) - - def set_theta_ref(self): - """ - # theta_ref should be equal to either theta or theta bar as reference - # since theta_ref will be used to judge if criteria is met - """ - if self.trainer.aconf.anchor_bar: - self.dict_theta_ref = copy.deepcopy(self.dict_theta_bar) - else: - self.dict_theta_ref = copy.deepcopy(self.dict_theta) - - def search_mu(self, dict_theta, iter_start): - """ - start from parameter dictionary dict_theta: {"layer":tensor}, - enlarge mu w.r.t. its current value - to see if the criteria is met - """ - self.count_search_mu += 1 - # FIXME: theta_bar always be overwriten by theta, to keep both at the same shoulder index - # Search always start from the model parameter - self.dict_theta_bar = copy.deepcopy(dict_theta) - self.set_theta_ref() - # theta_ref should be equal to either theta or theta bar as reference - # since theta_ref will be used to judge if criteria is met - - # I am not sure if necessary here to deepcopy, but safer - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - mmu = None - # self.mmu is not updated until a reg-descent operator is found - self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta_ref) - for miter in range(iter_start, self.budget_mu_per_step): - mmu = self.dict_mu_iter(miter) - print(f"trying mu={mmu} at mu iteration {miter} of {self.budget_mu_per_step}") - if self.search_theta(mmu): - self.count_found_operator += 1 - logger.info(f"!!!!!!!!!!!!!found reg-pareto operator with mu={mmu}") - logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") - return True - logger.warn(f"!failed to find mu within budget, mu={mmu}") - logger.info(f"success rate: {self.count_found_operator}/{self.count_search_mu}") - return False - - def search_theta(self, mmu_new): - """ - conditioned on fixed $$\\mu$$, the operator should search theta based on - the current value of $theta$ - - the execution will set the value for mu and theta as well - """ - self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta_ref) - # FIXME: where the search should start? theta_bar is the gradient descent result of old mu, - # it makes sense to start the search there? - theta4mu_new = copy.deepcopy(self.dict_theta_bar) - for i in range(self.budget_theta_update_per_mu): - print(f"search theta at iteration {i} with mu={mmu_new}") - theta4mu_new = self.trainer.opt_theta(mmu_new, theta4mu_new) - self.ploss_new_theta_new_mu = self.trainer.eval_p_loss(mmu_new, theta4mu_new) - self.ploss_new_theta_old_mu = self.trainer.eval_p_loss(self.mmu, theta4mu_new) - if self.is_criteria_met(): - self.mmu = mmu_new - # theta_bar is set at search_mu, no need to update - self.dict_theta = theta4mu_new - return True - return False - - def is_criteria_met(self): - """ - if the reg-descent criteria is met - """ - flag_improve = self.ploss_new_theta_new_mu < self.ploss_old_theta_new_mu - flag_deteriorate = self.ploss_new_theta_old_mu > self.ploss_old_theta_old_mu - return flag_improve & flag_deteriorate - - # below are just auxilliary code - def observe_state(self, mmu_new, theta4mu_new): - """ - FIXME: the function maybe not be needed anymore - depreatecated: - it can happen, the GD operator on the penalized function reduces both R and L - in this case, we get a descent operator for free. - - the state variable for high level control is the loss, we query them here - we only update the controller theta, the neural network theta is done by the trainer - """ - self.ploss_old_theta_old_mu = self.trainer.eval_p_loss(self.mmu, self.dict_theta_ref) - self.ploss_old_theta_new_mu = self.trainer.eval_p_loss(mmu_new, self.dict_theta_ref) - self.ploss_new_theta_new_mu = self.trainer.eval_p_loss(mmu_new, theta4mu_new) - self.ploss_new_theta_old_mu = self.trainer.eval_p_loss(self.mmu, theta4mu_new) - - def dict_mu_iter(self, miter): - """ - update the dictionary of mu w.r.t. its current value, and its iteration, and its iteration - """ - if miter == 0: - return self.mmu - if self.delta_mu is not None: - mmu = self.dict_addition(self.mmu, miter * self.delta_mu) - elif self.beta_mu is not None: - if self.dict_is_zero(self.mmu): - base = self.dict_addition(self.mmu, self.init_mu) - else: - base = self.mmu - multiplier = np.power(self.beta_mu, miter) - mmu = self.dict_multiply(base, multiplier) - else: - raise RuntimeError("delta_mu and beta_mu can not be simultaneously None!") - return mmu - - def dict_is_zero(self, dict_mu): - """ - check if hyper-parameter start from zero - """ - for key in dict_mu.keys(): - if dict_mu[key] == 0.0: - return True - return False - - def dict_multiply(self, dict_base, multiplier): - """ - multiply a float to each element of a dictionary - """ - assert multiplier > 1 - return {key: val*multiplier for key, val in dict_base.items()} - - def dict_addition(self, dict_base, delta): - """ - increase the value of a dictionary by delta - """ - return {key: val + delta for key, val in dict_base.items()} diff --git a/domainlab/algos/trainers/train_fbopt.py b/domainlab/algos/trainers/train_fbopt.py deleted file mode 100644 index 90949ec53..000000000 --- a/domainlab/algos/trainers/train_fbopt.py +++ /dev/null @@ -1,192 +0,0 @@ - -""" -feedback optimization -""" -import copy -from operator import add - -import torch - -from domainlab.algos.trainers.a_trainer import AbstractTrainer -from domainlab.algos.trainers.train_basic import TrainerBasic -from domainlab.algos.trainers.fbopt import HyperSchedulerFeedback -from domainlab.algos.trainers.fbopt_alternate import HyperSchedulerFeedbackAlternave -from domainlab.algos.msels.c_msel_bang import MSelBang -from domainlab.utils.logger import Logger - -def list_divide(list_val, scalar): - return [ele/scalar for ele in list_val] - -class HyperSetter(): - """ - mock object to force hyper-parameter in the model - """ - def __init__(self, dict_hyper): - self.dict_hyper = dict_hyper - - def __call__(self, epoch=None): - return self.dict_hyper - - -class TrainerFbOpt(AbstractTrainer): - """ - feedback optimization - """ - def set_scheduler(self, scheduler=HyperSchedulerFeedback): - """ - Args: - scheduler: The class name of the scheduler, the object corresponding to - this class name will be created inside model - """ - # model.hyper_init will register the hyper-parameters of the model to scheduler - self.hyper_scheduler = self.model.hyper_init(scheduler, trainer=self) - - def before_tr(self): - """ - before training begins, construct helper objects - """ - if self.aconf.msel == "last": - self.observer.model_sel = MSelBang(max_es=None) - # although validation distribution will be very difference from test distribution, it is still a better - # idea to not to use the last iteration of the model - # self.set_scheduler(scheduler=HyperSchedulerFeedback) - self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) - self.model.evaluate(self.loader_te, self.device) - self.inner_trainer = TrainerBasic() # look ahead - # here we need a mechanism to generate deep copy of the model - self.inner_trainer.init_business( - copy.deepcopy(self.model), self.task, self.observer, self.device, self.aconf, - flag_accept=False) - - epo_reg_loss, epo_task_loss = self.eval_r_loss() - self.hyper_scheduler.set_setpoint( - [ele * self.aconf.ini_setpoint_ratio for ele in epo_reg_loss], epo_task_loss) - - def opt_theta(self, dict4mu, dict_theta0): - """ - operator for theta, move gradient for one epoch, then check if criteria is met - this method will be invoked by the hyper-parameter scheduling object - """ - self.inner_trainer.reset() - self.inner_trainer.model.set_params(dict_theta0) - # mock the model hyper-parameter to be from dict4mu - self.inner_trainer.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) - # hide implementation details of inner_trainer - self.inner_trainer.model.train() - for _, (tensor_x, vec_y, vec_d, *others) in enumerate(self.inner_trainer.loader_tr): - self.inner_trainer.train_batch(tensor_x, vec_y, vec_d, others) # update inner_net - dict_par = dict(self.inner_trainer.model.named_parameters()) - return dict_par - - def eval_p_loss(self, dict4mu, dict_theta): - """ - evaluate the penalty function value on all available training data - # TODO: normalize loss via batchsize - """ - temp_model = copy.deepcopy(self.model) - # mock the model hyper-parameter to be from dict4mu - temp_model.hyper_update(epoch=None, fun_scheduler=HyperSetter(dict4mu)) - temp_model.set_params(dict_theta) - epo_p_loss = 0 # penalized loss - counter = 0.0 - with torch.no_grad(): - for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): - tensor_x, vec_y, vec_d = \ - tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) - # sum will kill the dimension of the mini batch - b_p_loss = temp_model.cal_loss(tensor_x, vec_y, vec_d).sum() - epo_p_loss += b_p_loss - counter += 1.0 - return epo_p_loss/counter - - def eval_r_loss(self): - """ - evaluate the regularization loss and ERM loss with respect ot parameter dict_theta - ERM loss on all available training data - # TODO: normalize loss via batchsize - """ - temp_model = copy.deepcopy(self.model) - temp_model.eval() - # mock the model hyper-parameter to be from dict4mu - epo_reg_loss = [] - epo_task_loss = 0 - counter = 0.0 - with torch.no_grad(): - for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): - tensor_x, vec_y, vec_d = \ - tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) - tuple_reg_loss = temp_model.cal_reg_loss(tensor_x, vec_y, vec_d) - # NOTE: first [0] extract the loss, second [0] get the list - list_b_reg_loss = tuple_reg_loss[0] # FIXME: this only works when scalar multiplier - list_b_reg_loss_sumed = [ele.sum().item() for ele in list_b_reg_loss] - if len(epo_reg_loss) == 0: - epo_reg_loss = list_b_reg_loss_sumed - else: - epo_reg_loss = list(map(add, epo_reg_loss, list_b_reg_loss_sumed)) - # FIXME: change this to vector - # each component of vector is a mini batch loss - b_task_loss = temp_model.cal_task_loss(tensor_x, vec_y).sum() - # sum will kill the dimension of the mini batch - epo_task_loss += b_task_loss - counter += 1.0 - return list_divide(epo_reg_loss, counter), epo_task_loss/counter - - def tr_epoch(self, epoch): - """ - the algorithm will try to search for the reg-descent operator, only when found, - the model will tunnel/jump/shoot into the found pivot parameter $\\theta^{(k+1)}$, - otherwise, - """ - epo_reg_loss, epo_task_loss = self.eval_r_loss() - if self.aconf.msel == "loss_tr": - if self.aconf.msel_tr_loss =="reg": - self.epo_loss_tr = epo_reg_loss - elif self.aconf.msel_tr_loss =="task": - self.epo_loss_tr = epo_task_loss - else: - raise RuntimeError("msel_tr_loss set to be the wrong value") - elif self.aconf.msel == "last" or self.aconf.msel == "val": - self.epo_loss_tr = 1.0 # FIXME: check if this is not used at all - else: - raise RuntimeError("msel type not supported") - - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info(f"at epoch {epoch}, epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") - - # double check if loss evaluation is the same when executed two times - epo_reg_loss, epo_task_loss = self.eval_r_loss() - - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info(f"at epoch {epoch}, epo_reg_loss={epo_reg_loss}, epo_task_loss={epo_task_loss}") - - # self.model.train() # FIXME: i guess no need to put into train mode? - - flag_success = self.hyper_scheduler.search_mu( - dict(self.model.named_parameters()), - miter=epoch) # FIXME: iter_start=0 or 1? - - if flag_success: - # only in success case, mu will be updated - logger.info("pivot parameter found, jumping/shooting there now!") - epo_reg_loss, epo_task_loss = self.eval_r_loss() - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info( - f"at epoch {epoch}, before shooting: epo_reg_loss={epo_reg_loss}, \ - epo_task_loss={epo_task_loss}") - - # shoot/tunnel to new found parameter configuration - self.model.set_params(self.hyper_scheduler.dict_theta) - - epo_reg_loss, epo_task_loss = self.eval_r_loss() - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info( - f"at epoch {epoch}, after shooting: epo_reg_loss={epo_reg_loss}, \ - epo_task_loss={epo_task_loss}") - self.hyper_scheduler.update_setpoint(epo_reg_loss, epo_task_loss) - #if self.aconf.myoptic_pareto: - # self.hyper_scheduler.update_anchor(dict_par) - flag_early_stop_observer = self.observer.update(epoch) - flag_msel_early_stop = self.observer.model_sel.if_stop() - self.mu_iter_start = 1 # start from mu=0, due to arange(iter_start, budget) - # FIXME: after a long seesion with Emilio, we could not resovle this, this is a hack at themoment - return flag_msel_early_stop From 0f86d82f23a8eaf17d7d81a3ed4e8613395923ab Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 12:15:21 +0200 Subject: [PATCH 341/762] clean code --- domainlab/algos/trainers/args_fbopt.py | 22 +++++-------------- domainlab/algos/trainers/fbopt_alternate.py | 17 -------------- .../algos/trainers/fbopt_setpoint_ada.py | 3 ++- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 536339bca..1d6f7367d 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -45,20 +45,10 @@ def add_args2parser_fbopt(parser): parser.add_argument('--overshoot_rewind', type=str, default="yes", help='overshoot_rewind, for benchmark, use yes or no') - parser.add_argument('--str_diva_multiplier_type', type=str, default="gammad_recon", help='which penalty to tune') - - - # the following hyperparamters do not need to be tuned - parser.add_argument('--beta_mu', type=float, default=1.1, - help='how much to multiply mu each time') - parser.add_argument('--delta_mu', type=float, default=None, - help='how much to increment mu each time') - parser.add_argument('--budget_mu_per_step', type=int, default=5, - help='number of mu iterations to try') - parser.add_argument('--budget_theta_update_per_mu', type=int, default=5, - help='number of theta update for each fixed mu') - parser.add_argument('--anchor_bar', action='store_true', default=False, - help='use theta bar as anchor point') - parser.add_argument('--myoptic_pareto', action='store_true', default=False, - help='update theta^{k} upon pareto descent') + parser.add_argument('--setpoint_rewind', type=str, default="no", + help='setpoing_rewind, for benchmark, use yes or no') + + parser.add_argument('--str_diva_multiplier_type', type=str, default="gammad_recon", + help='which penalty to tune') + return parser diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_alternate.py index fe68ebf1c..dd1d53cc7 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_alternate.py @@ -40,23 +40,6 @@ def __init__(self, trainer, **kwargs): self.mu_min = trainer.aconf.mu_min self.mmu = kwargs self.mmu = {key: self.init_mu for key, val in self.mmu.items()} - self.ploss_old_theta_old_mu = None - self.ploss_old_theta_new_mu = None - self.ploss_new_theta_old_mu = None - self.ploss_new_theta_new_mu = None - self.delta_mu = trainer.aconf.delta_mu - # for exponential increase of mu, mu can not be starting from zero - self.beta_mu = trainer.aconf.beta_mu - self.dict_theta_bar = None - self.dict_theta = copy.deepcopy(dict(self.trainer.model.named_parameters())) - # theta_ref should be equal to either theta or theta bar as reference - # since theta_ref will be used to judge if criteria is met - self.dict_theta_ref = None - self.budget_mu_per_step = trainer.aconf.budget_mu_per_step - self.budget_theta_update_per_mu = trainer.aconf.budget_theta_update_per_mu - self.count_found_operator = 0 - self.count_search_mu = 0 - ######################################## self.set_point_controller = FbOptSetpointController(args=self.trainer.aconf) self.k_i_control = trainer.aconf.k_i_gain self.overshoot_rewind = trainer.aconf.overshoot_rewind == "yes" diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index ada473f8e..726be8296 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -60,7 +60,7 @@ def __init__(self, host): self.epo_ma = None self.ref = None self.coeff_ma = 0.5 - self.setpoint_rewind = False + self.setpoint_rewind = host.flag_setpoint_rewind def reset(self, epo_reg_loss): """ @@ -117,6 +117,7 @@ def __init__(self, state=None, args=None): else: state = DominateAnyComponent() self.transition_to(state) + self.flag_setpoint_rewind = args.setpoint_rewind == "yes" self.setpoint_rewinder = SetpointRewinder(self) self.state_task_loss = 0.0 self.state_epo_reg_loss = [0.0 for _ in range(10)] # FIXME: 10 is the maximum number losses here From d5b12991df99df743495b8c16f865227e42082e3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 12:47:40 +0200 Subject: [PATCH 342/762] . --- .../benchmark/fbopt_mnist_jigen_alone.yaml | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 examples/benchmark/fbopt_mnist_jigen_alone.yaml diff --git a/examples/benchmark/fbopt_mnist_jigen_alone.yaml b/examples/benchmark/fbopt_mnist_jigen_alone.yaml new file mode 100644 index 000000000..18143eb8e --- /dev/null +++ b/examples/benchmark/fbopt_mnist_jigen_alone.yaml @@ -0,0 +1,74 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt + +sampling_seed: 0 +startseed: 0 +endseed: 4 + +test_domains: + - 0 + + +domainlab_args: + task: mnistcolor10 + tr_d: [1, 2] + dmem: False + lr: 0.001 + epos: 500 + es: 100 + bs: 64 + nname: conv_bn_pool_2 + san_check: False + exp_shoulder_clip: 10 + mu_clip: 10 + coeff_ma: 0.5 + no_tensorboard: False + pperm: 0.5 + + + +Shared params: + setpoint_rewind: + distribution: categorical + datatype: str + values: + - "yes" + - "no" + overshoot_rewind: + distribution: categorical + datatype: str + values: + - "yes" + - "no" + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + num: 3 + distribution: loguniform + + gamma_reg: + min: 0.01 + max: 10_000 + num: 10 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations + +jigen_feedback: + aname: jigen + trainer: fbopt + ini_setpoint_ratio: 0.99 + shared: + - k_i_gain + - mu_init + - setpoint_rewind + - overshoot_rewind From fe165892e80ca84ef7a2b898bc5a9eca9a493ed3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 12:53:30 +0200 Subject: [PATCH 343/762] . --- examples/benchmark/fbopt_mnist_jigen_alone.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/fbopt_mnist_jigen_alone.yaml b/examples/benchmark/fbopt_mnist_jigen_alone.yaml index 18143eb8e..06cd6fbe6 100644 --- a/examples/benchmark/fbopt_mnist_jigen_alone.yaml +++ b/examples/benchmark/fbopt_mnist_jigen_alone.yaml @@ -16,7 +16,7 @@ domainlab_args: dmem: False lr: 0.001 epos: 500 - es: 100 + es: 50 bs: 64 nname: conv_bn_pool_2 san_check: False @@ -29,6 +29,16 @@ domainlab_args: Shared params: + coeff_ma_output_state: + distribution: uniform + min: 0.0 + max: 0.9 + num: 3 + coeff_ma_setpoint: + distribution: uniform + min: 0.0 + max: 0.9 + num: 3 setpoint_rewind: distribution: categorical datatype: str From 7d91bc7f9974cefeee1ec148b935a8e6fa10f23f Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 13:16:28 +0200 Subject: [PATCH 344/762] Update pacs_diva_others.yaml --- examples/benchmark/pacs_diva_others.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml index 2547daf07..bee01ce8e 100644 --- a/examples/benchmark/pacs_diva_others.yaml +++ b/examples/benchmark/pacs_diva_others.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full +output_dir: zoutput/benchmarks/pacs_diva_others sampling_seed: 0 From e0fb6366951f0ea3de84927905fe003607deaaa3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 14:35:55 +0200 Subject: [PATCH 345/762] stricter setpoint --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 726be8296..3f615b53f 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -115,7 +115,7 @@ def __init__(self, state=None, args=None): if args is not None and args.no_setpoint_update: state = FixedSetpoint() else: - state = DominateAnyComponent() + state = DominateAllComponent() self.transition_to(state) self.flag_setpoint_rewind = args.setpoint_rewind == "yes" self.setpoint_rewinder = SetpointRewinder(self) From 97123d31ac9e90ac8b115b3f6d0ab54f90ab59bf Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 15:18:23 +0200 Subject: [PATCH 346/762] fix bug: constant multiplier --- domainlab/algos/trainers/train_mu_controller.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index 7a68c5f75..895ce04ca 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -87,6 +87,9 @@ def before_tr(self): self.epo_task_loss_tr) self.list_str_multiplier_na = self.model.list_str_multiplier_na + def set_mu(self): + self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) + def tr_epoch(self, epoch): """ update hyper-parameters only per epoch @@ -99,5 +102,6 @@ def tr_epoch(self, epoch): dict(self.model.named_parameters()), miter=epoch) self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) + self.set_mu() flag = super().tr_epoch(epoch) return flag From a759cc2edd6f440e67c89adc7f56931c104057d1 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 15:42:27 +0200 Subject: [PATCH 347/762] Update pacs_diva_others.yaml --- examples/benchmark/pacs_diva_others.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml index bee01ce8e..7101d0384 100644 --- a/examples/benchmark/pacs_diva_others.yaml +++ b/examples/benchmark/pacs_diva_others.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/pacs_diva_others sampling_seed: 0 startseed: 0 -endseed: 2 +endseed: 5 test_domains: - sketch From 32f61f05b6e50c1cff00f0123095b902b4c68797 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 16:15:25 +0200 Subject: [PATCH 348/762] ma --- domainlab/algos/trainers/args_fbopt.py | 4 ++-- examples/benchmark/fbopt_mnist_jigen_alone.yaml | 6 ++++-- run_fbopt_mnist.sh | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 1d6f7367d..6340fc93c 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -23,10 +23,10 @@ def add_args2parser_fbopt(parser): parser.add_argument('--coeff_ma', type=float, default=0.5, help='exponential moving average') - parser.add_argument('--coeff_ma_output_state', type=float, default=0.0, + parser.add_argument('--coeff_ma_output_state', type=float, default=0.5, help='setpoint output as state exponential moving average') - parser.add_argument('--coeff_ma_setpoint', type=float, default=0.0, + parser.add_argument('--coeff_ma_setpoint', type=float, default=0.5, help='setpoint average') parser.add_argument('--exp_shoulder_clip', type=float, default=5, diff --git a/examples/benchmark/fbopt_mnist_jigen_alone.yaml b/examples/benchmark/fbopt_mnist_jigen_alone.yaml index 06cd6fbe6..cd5238432 100644 --- a/examples/benchmark/fbopt_mnist_jigen_alone.yaml +++ b/examples/benchmark/fbopt_mnist_jigen_alone.yaml @@ -33,12 +33,12 @@ Shared params: distribution: uniform min: 0.0 max: 0.9 - num: 3 + num: 2 coeff_ma_setpoint: distribution: uniform min: 0.0 max: 0.9 - num: 3 + num: 2 setpoint_rewind: distribution: categorical datatype: str @@ -77,6 +77,8 @@ jigen_feedback: aname: jigen trainer: fbopt ini_setpoint_ratio: 0.99 + coeff_ma_output_state: 0.5 + coeff_ma_setpoint: 0.5 shared: - k_i_gain - mu_init diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 44d8726b6..021ca4e53 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output=0.0 From 06b63815fdcad9704055ca92166299748dcf0be7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 16:26:03 +0200 Subject: [PATCH 349/762] rename --- .../{fbopt_pacs_jigen_alone => fbopt_pacs_jigen_alone.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{fbopt_pacs_jigen_alone => fbopt_pacs_jigen_alone.yaml} (100%) diff --git a/examples/benchmark/fbopt_pacs_jigen_alone b/examples/benchmark/fbopt_pacs_jigen_alone.yaml similarity index 100% rename from examples/benchmark/fbopt_pacs_jigen_alone rename to examples/benchmark/fbopt_pacs_jigen_alone.yaml From 110d4aa58fc3e80b24b18dfead002d623cbdc7dc Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 12 Oct 2023 17:01:10 +0200 Subject: [PATCH 350/762] es --- examples/benchmark/fbopt_mnist_jigen_alone.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/fbopt_mnist_jigen_alone.yaml b/examples/benchmark/fbopt_mnist_jigen_alone.yaml index cd5238432..9bfd0f993 100644 --- a/examples/benchmark/fbopt_mnist_jigen_alone.yaml +++ b/examples/benchmark/fbopt_mnist_jigen_alone.yaml @@ -16,7 +16,7 @@ domainlab_args: dmem: False lr: 0.001 epos: 500 - es: 50 + es: 100 bs: 64 nname: conv_bn_pool_2 san_check: False From 9ff3f4205a5e448ff85208e2a263e3405c6c416c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 18:26:34 +0200 Subject: [PATCH 351/762] Update train_mu_controller.py --- .../algos/trainers/train_mu_controller.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_mu_controller.py index 895ce04ca..f92632619 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_mu_controller.py @@ -79,20 +79,25 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) - self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) - # self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() - super().tr_epoch(-1) + self.set_model_with_mu() # very small value + self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() self.hyper_scheduler.set_setpoint( [ele * self.aconf.ini_setpoint_ratio if ele > 0 else ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], - self.epo_task_loss_tr) - self.list_str_multiplier_na = self.model.list_str_multiplier_na + self.epo_task_loss_tr) # setpoing w.r.t. random initialization of neural network - def set_mu(self): + @property + def list_str_multiplier_na(self): + return self.model.list_str_multiplier_na + + def erm(self): + super().tr_epoch(-1) + + def set_model_with_mu(self): self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) def tr_epoch(self, epoch): """ - update hyper-parameters only per epoch + update multipliers only per epoch """ self.hyper_scheduler.search_mu( self.epo_reg_loss_tr, @@ -101,7 +106,9 @@ def tr_epoch(self, epoch): self.list_str_multiplier_na, dict(self.model.named_parameters()), miter=epoch) - self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) - self.set_mu() + self.set_model_with_mu() + flag = super().tr_epoch(epoch) + # is it good to update setpoint after we know the new value of each loss? + self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) return flag From 21adf614e866ddc99ce571504b06d1605339ed8c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 18:39:15 +0200 Subject: [PATCH 352/762] Update run_fbopt_mnist.sh --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 021ca4e53..a988ea4cd 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output=0.0 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output=0.0 From 4c81ea6ca99caf07b9bd3059164c3fa000a1300e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 19:17:32 +0200 Subject: [PATCH 353/762] Update fbopt_mnist_jigen_alone.yaml --- examples/benchmark/fbopt_mnist_jigen_alone.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/fbopt_mnist_jigen_alone.yaml b/examples/benchmark/fbopt_mnist_jigen_alone.yaml index 9bfd0f993..2ed9c1f9f 100644 --- a/examples/benchmark/fbopt_mnist_jigen_alone.yaml +++ b/examples/benchmark/fbopt_mnist_jigen_alone.yaml @@ -15,8 +15,8 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 500 - es: 100 + epos: 1000 + es: 200 bs: 64 nname: conv_bn_pool_2 san_check: False From cc851ac69a17ae34834c7e6394bfafba083b0315 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 20:38:01 +0200 Subject: [PATCH 354/762] Rename fbopt_pacs_diva_alone to fbopt_pacs_diva_alone.yaml --- .../{fbopt_pacs_diva_alone => fbopt_pacs_diva_alone.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{fbopt_pacs_diva_alone => fbopt_pacs_diva_alone.yaml} (100%) diff --git a/examples/benchmark/fbopt_pacs_diva_alone b/examples/benchmark/fbopt_pacs_diva_alone.yaml similarity index 100% rename from examples/benchmark/fbopt_pacs_diva_alone rename to examples/benchmark/fbopt_pacs_diva_alone.yaml From 2848e322e00c0dfa4d5fa75855b0797dd2578487 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 20:48:14 +0200 Subject: [PATCH 355/762] Update and rename fbopt_pacs_jigen_alone.yaml to pacs_jigen_fbopt__alone.yaml --- ...fbopt_pacs_jigen_alone.yaml => pacs_jigen_fbopt__alone.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/benchmark/{fbopt_pacs_jigen_alone.yaml => pacs_jigen_fbopt__alone.yaml} (94%) diff --git a/examples/benchmark/fbopt_pacs_jigen_alone.yaml b/examples/benchmark/pacs_jigen_fbopt__alone.yaml similarity index 94% rename from examples/benchmark/fbopt_pacs_jigen_alone.yaml rename to examples/benchmark/pacs_jigen_fbopt__alone.yaml index 354ce3689..69bfa33c0 100644 --- a/examples/benchmark/fbopt_pacs_jigen_alone.yaml +++ b/examples/benchmark/pacs_jigen_fbopt__alone.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full +output_dir: zoutput/benchmarks/pacs_jigen_fbopt_alone sampling_seed: 0 From 3650ec2ce3bdf2659224cc873a0a355bdd508030 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 20:49:55 +0200 Subject: [PATCH 356/762] Rename pacs_jigen_fbopt__alone.yaml to pacs_jigen_fbopt_alone.yaml --- .../{pacs_jigen_fbopt__alone.yaml => pacs_jigen_fbopt_alone.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{pacs_jigen_fbopt__alone.yaml => pacs_jigen_fbopt_alone.yaml} (100%) diff --git a/examples/benchmark/pacs_jigen_fbopt__alone.yaml b/examples/benchmark/pacs_jigen_fbopt_alone.yaml similarity index 100% rename from examples/benchmark/pacs_jigen_fbopt__alone.yaml rename to examples/benchmark/pacs_jigen_fbopt_alone.yaml From 6b63f6093830d576876db92995375fcc8d4ddee1 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 12 Oct 2023 21:10:08 +0200 Subject: [PATCH 357/762] Update and rename fbopt_mnist_diva_alone.yaml to mnist_diva_fbopt_alone.yaml --- ...alone.yaml => mnist_diva_fbopt_alone.yaml} | 24 ------------------- 1 file changed, 24 deletions(-) rename examples/benchmark/{fbopt_mnist_diva_alone.yaml => mnist_diva_fbopt_alone.yaml} (75%) diff --git a/examples/benchmark/fbopt_mnist_diva_alone.yaml b/examples/benchmark/mnist_diva_fbopt_alone.yaml similarity index 75% rename from examples/benchmark/fbopt_mnist_diva_alone.yaml rename to examples/benchmark/mnist_diva_fbopt_alone.yaml index ef2d48211..50bb8105b 100644 --- a/examples/benchmark/fbopt_mnist_diva_alone.yaml +++ b/examples/benchmark/mnist_diva_fbopt_alone.yaml @@ -79,29 +79,5 @@ diva_fbopt_a: - k_i_gain - mu_init -diva_feedforward_a: - aname: diva - trainer: hyperscheduler - str_diva_multiplier_type: gammad_recon - gamma_y: 1.0 - shared: - - gamma_d - -diva_default: - aname: diva - trainer: hyperscheduler - str_diva_multiplier_type: default - shared: - - gamma_d - - gamma_y - -diva_fixed_penalty: - aname: diva - trainer: basic - str_diva_multiplier_type: default - shared: - - gamma_d - - gamma_y - erm: aname: deepall From 20d124ec3d1f7a11be580abfdade6b0ea0b38335 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 09:42:22 +0200 Subject: [PATCH 358/762] rename --- .../{fbopt_alternate.py => fbopt_mu_controller.py} | 2 +- .../trainers/{train_mu_controller.py => train_fbopt_b.py} | 8 ++++---- domainlab/algos/trainers/zoo_trainer.py | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) rename domainlab/algos/trainers/{fbopt_alternate.py => fbopt_mu_controller.py} (99%) rename domainlab/algos/trainers/{train_mu_controller.py => train_fbopt_b.py} (95%) diff --git a/domainlab/algos/trainers/fbopt_alternate.py b/domainlab/algos/trainers/fbopt_mu_controller.py similarity index 99% rename from domainlab/algos/trainers/fbopt_alternate.py rename to domainlab/algos/trainers/fbopt_mu_controller.py index dd1d53cc7..c4f43ecfd 100644 --- a/domainlab/algos/trainers/fbopt_alternate.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -27,7 +27,7 @@ def add_scalars(self, *args, **kwargs): """ -class HyperSchedulerFeedbackAlternave(): +class HyperSchedulerFeedback(): """ design $\\mu$$ sequence based on state of penalized loss """ diff --git a/domainlab/algos/trainers/train_mu_controller.py b/domainlab/algos/trainers/train_fbopt_b.py similarity index 95% rename from domainlab/algos/trainers/train_mu_controller.py rename to domainlab/algos/trainers/train_fbopt_b.py index f92632619..a2663fe04 100644 --- a/domainlab/algos/trainers/train_mu_controller.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -4,7 +4,7 @@ from operator import add import torch from domainlab.algos.trainers.train_basic import TrainerBasic -from domainlab.algos.trainers.fbopt_alternate import HyperSchedulerFeedbackAlternave +from domainlab.algos.trainers.fbopt_mu_controller import HyperSchedulerFeedback from domainlab.utils.logger import Logger @@ -78,8 +78,8 @@ def before_batch(self, epoch, ind_batch): return super().after_batch(epoch, ind_batch) def before_tr(self): - self.set_scheduler(scheduler=HyperSchedulerFeedbackAlternave) - self.set_model_with_mu() # very small value + self.set_scheduler(scheduler=HyperSchedulerFeedback) + self.set_model_with_mu() # very small value self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() self.hyper_scheduler.set_setpoint( [ele * self.aconf.ini_setpoint_ratio if ele > 0 else ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], @@ -107,7 +107,7 @@ def tr_epoch(self, epoch): dict(self.model.named_parameters()), miter=epoch) self.set_model_with_mu() - + flag = super().tr_epoch(epoch) # is it good to update setpoint after we know the new value of each loss? self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) diff --git a/domainlab/algos/trainers/zoo_trainer.py b/domainlab/algos/trainers/zoo_trainer.py index f564be0bf..345064ca5 100644 --- a/domainlab/algos/trainers/zoo_trainer.py +++ b/domainlab/algos/trainers/zoo_trainer.py @@ -6,8 +6,7 @@ from domainlab.algos.trainers.train_matchdg import TrainerMatchDG from domainlab.algos.trainers.train_mldg import TrainerMLDG from domainlab.algos.trainers.train_hyper_scheduler import TrainerHyperScheduler -# from domainlab.algos.trainers.train_fbopt import TrainerFbOpt -from domainlab.algos.trainers.train_mu_controller import TrainerFbOpt +from domainlab.algos.trainers.train_fbopt_b import TrainerFbOpt class TrainerChainNodeGetter(object): From 39949d50e40b5df51777a4693b63aaa98bb1b052 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 10:06:48 +0200 Subject: [PATCH 359/762] rewind --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 4 ++-- tests/test_fbopt_setpoint_rewind.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/test_fbopt_setpoint_rewind.py diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 3f615b53f..764722dbd 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -154,10 +154,10 @@ def observe(self, epo_reg_loss, epo_task_loss): self.state_task_loss = epo_task_loss self.state_task_loss = self.coeff_ma_output * self.state_task_loss + \ (1-self.coeff_ma_output) * epo_task_loss - self.setpoint_rewinder.observe(epo_reg_loss) + self.setpoint_rewinder.observe(self.state_epo_reg_loss) flag_update, list_pos = self.state_updater.update_setpoint() if flag_update: - self.setpoint_rewinder.reset(epo_reg_loss) + self.setpoint_rewinder.reset(self.state_epo_reg_loss) logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"!!!!!set point old value {self.setpoint4R}!") self.update_setpoint_ma(self.state_epo_reg_loss, list_pos) diff --git a/tests/test_fbopt_setpoint_rewind.py b/tests/test_fbopt_setpoint_rewind.py new file mode 100644 index 000000000..868903c2f --- /dev/null +++ b/tests/test_fbopt_setpoint_rewind.py @@ -0,0 +1,11 @@ +""" +unit and end-end test for deep all, mldg +""" +from tests.utils_test import utils_test_algo + +def test_jigen_fbopt(): + """ + jigen + """ + args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=jigen --trainer=fbopt --nname=alexnet --epos=300 --setpoint_rewind=yes" + utils_test_algo(args) From eec5b39fda5bd60b8a7a303e14d46d8747fc2663 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 11:07:33 +0200 Subject: [PATCH 360/762] better coeff --- domainlab/algos/trainers/args_fbopt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 6340fc93c..831746a38 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -23,11 +23,11 @@ def add_args2parser_fbopt(parser): parser.add_argument('--coeff_ma', type=float, default=0.5, help='exponential moving average') - parser.add_argument('--coeff_ma_output_state', type=float, default=0.5, - help='setpoint output as state exponential moving average') + parser.add_argument('--coeff_ma_output_state', type=float, default=0.9, + help='state exponential moving average of reguarlization loss') - parser.add_argument('--coeff_ma_setpoint', type=float, default=0.5, - help='setpoint average') + parser.add_argument('--coeff_ma_setpoint', type=float, default=0.9, + help='setpoint average coeff for previous setpoint') parser.add_argument('--exp_shoulder_clip', type=float, default=5, help='clip before exponential operation') From 8e0d8f09a2ebc1ffa9b27ac295cf88fcd1245185 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 11:35:49 +0200 Subject: [PATCH 361/762] delayed model selection --- domainlab/algos/msels/c_msel_bang.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/domainlab/algos/msels/c_msel_bang.py b/domainlab/algos/msels/c_msel_bang.py index 8eda99469..ccb6e826b 100644 --- a/domainlab/algos/msels/c_msel_bang.py +++ b/domainlab/algos/msels/c_msel_bang.py @@ -1,22 +1,24 @@ """ -Model Selection should be decoupled from +Multiobjective Model Selection """ -from domainlab.algos.msels.a_model_sel import AMSel +from domainlab.algos.msels.c_msel_val import MSelValPerf -class MSelBang(AMSel): +class MSelSetpointDelay(MSelValPerf): """ 1. Model selection using validation performance - 2. Visitor pattern to trainer + 2. Only update if setpoint has been decreased """ def __init__(self, max_es): - self.best_val_acc = 0.0 + self.oracle_last_setpoing_sel_te_acc = 0.0 + super().__init__(max_es) - def if_stop(self): - return False - - def update(self): + def update(self, clear_counter=False): """ if the best model should be updated """ - return True + if clear_counter: + self.oracle_last_setpoing_sel_te_acc = self.sel_model_te_acc + flag = super().update(clear_counter) + # FIXME: flag is to persist model, which is not possible anymore + return flag From 2669f1acd20fa1639a68eed2b83f58865b5117c9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 11:36:33 +0200 Subject: [PATCH 362/762] rename c_msel_bang to c_msel_setpoint_delay --- .../algos/msels/{c_msel_bang.py => c_msel_setpoint_delay.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename domainlab/algos/msels/{c_msel_bang.py => c_msel_setpoint_delay.py} (100%) diff --git a/domainlab/algos/msels/c_msel_bang.py b/domainlab/algos/msels/c_msel_setpoint_delay.py similarity index 100% rename from domainlab/algos/msels/c_msel_bang.py rename to domainlab/algos/msels/c_msel_setpoint_delay.py From 9e220fe72d6442076acf54a2becda47fea497a7a Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 11:59:02 +0200 Subject: [PATCH 363/762] fix wrong gamma_d sign issue #525 --- domainlab/models/model_diva.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index c4a4a024a..dc6a43dca 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -144,7 +144,7 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): _, d_target = tensor_d.max(dim=1) lc_d = F.cross_entropy(logit_d, d_target, reduction="none") return [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ - [self.mu_recon, -self.beta_d, -self.beta_x, -self.beta_y, -self.gamma_d] + [self.mu_recon, -self.beta_d, -self.beta_x, -self.beta_y, self.gamma_d] class ModelDIVAGammadRecon(ModelDIVA): def hyper_update(self, epoch, fun_scheduler): From 824fbb2ee58ee7eb774c394e9e55ff3f2e571c53 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 12:15:23 +0200 Subject: [PATCH 364/762] Update and rename fbopt_mnist_jigen_alone.yaml to mnist_jigen_fbopt_alone.yaml --- ...t_jigen_alone.yaml => mnist_jigen_fbopt_alone.yaml} | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) rename examples/benchmark/{fbopt_mnist_jigen_alone.yaml => mnist_jigen_fbopt_alone.yaml} (90%) diff --git a/examples/benchmark/fbopt_mnist_jigen_alone.yaml b/examples/benchmark/mnist_jigen_fbopt_alone.yaml similarity index 90% rename from examples/benchmark/fbopt_mnist_jigen_alone.yaml rename to examples/benchmark/mnist_jigen_fbopt_alone.yaml index 2ed9c1f9f..7501f1a0d 100644 --- a/examples/benchmark/fbopt_mnist_jigen_alone.yaml +++ b/examples/benchmark/mnist_jigen_fbopt_alone.yaml @@ -16,7 +16,7 @@ domainlab_args: dmem: False lr: 0.001 epos: 1000 - es: 200 + es: 100 bs: 64 nname: conv_bn_pool_2 san_check: False @@ -45,12 +45,6 @@ Shared params: values: - "yes" - "no" - overshoot_rewind: - distribution: categorical - datatype: str - values: - - "yes" - - "no" k_i_gain: min: 0.0001 max: 0.01 @@ -60,7 +54,7 @@ Shared params: mu_init: min: 0.000001 max: 0.00001 - num: 3 + num: 2 distribution: loguniform gamma_reg: From d92ee9b380518145cd32cdd364e3c23d0491bdda Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 12:26:26 +0200 Subject: [PATCH 365/762] code quality --- domainlab/algos/trainers/fbopt_mu_controller.py | 2 +- domainlab/algos/trainers/train_fbopt_b.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index c4f43ecfd..44aa3d61e 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -96,7 +96,7 @@ def cal_delta_integration(self, list_old, list_new, coeff): """ return [(1-coeff)*a + coeff*b for a, b in zip(list_old, list_new)] - def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, dict_theta=None, miter=None): + def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, miter): """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index a2663fe04..c31a5eb9a 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -87,12 +87,21 @@ def before_tr(self): @property def list_str_multiplier_na(self): + """ + return the name of multipliers + """ return self.model.list_str_multiplier_na - def erm(self): + def do_erm(self): + """ + erm step with very small mu + """ super().tr_epoch(-1) def set_model_with_mu(self): + """ + set model multipliers + """ self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) def tr_epoch(self, epoch): @@ -104,7 +113,6 @@ def tr_epoch(self, epoch): self.epo_task_loss_tr, self.epo_loss_tr, self.list_str_multiplier_na, - dict(self.model.named_parameters()), miter=epoch) self.set_model_with_mu() From 6f1a02c9fd107718c733e305ce0fa93b6aef60ec Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 14:30:27 +0200 Subject: [PATCH 366/762] list less than consider sign --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 764722dbd..124155e90 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -27,11 +27,21 @@ def list_multiply(list1, coeff): return [ele * coeff for ele in list1] +def if_list_sign_agree(list1, list2): + """ + each pair must have the same sign + """ + list_agree = [a*b >= 0 for a, b in zip(list1, list2)] + if not all(list_agree): + raise RuntimeError(f"{list1} and {list2} can not be compared!") + + def is_less_list_any(list1, list2): """ judge if one list is less than the other """ - list_comparison = [a < b for a, b in zip(list1, list2)] + if_list_sign_agree(list1, list2) + list_comparison = [a < b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2)] return any(list_comparison), list_true(list_comparison) @@ -39,7 +49,8 @@ def is_less_list_all(list1, list2): """ judge if one list is less than the other """ - list_comparison = [a < b for a, b in zip(list1, list2)] + if_list_sign_agree(list1, list2) + list_comparison = [a < b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2)] return all(list_comparison) @@ -115,7 +126,7 @@ def __init__(self, state=None, args=None): if args is not None and args.no_setpoint_update: state = FixedSetpoint() else: - state = DominateAllComponent() + state = DominateAnyComponent() self.transition_to(state) self.flag_setpoint_rewind = args.setpoint_rewind == "yes" self.setpoint_rewinder = SetpointRewinder(self) From 9fd8438140a272f867fd8afc112e827061b605eb Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 15:10:44 +0200 Subject: [PATCH 367/762] add setpoint msel to rst.csv --- domainlab/algos/msels/c_msel_oracle.py | 6 ++++++ domainlab/algos/msels/c_msel_setpoint_delay.py | 11 ++++++----- domainlab/algos/msels/c_msel_val.py | 1 + domainlab/algos/observers/b_obvisitor.py | 5 +++++ domainlab/algos/trainers/train_fbopt_b.py | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/msels/c_msel_oracle.py b/domainlab/algos/msels/c_msel_oracle.py index 0173a5ecc..3ed36a02a 100644 --- a/domainlab/algos/msels/c_msel_oracle.py +++ b/domainlab/algos/msels/c_msel_oracle.py @@ -36,6 +36,12 @@ def best_te_metric(self): return self.msel.best_te_metric return -1 + @property + def oracle_last_setpoint_sel_te_acc(self): + if self.msel is not None and hasattr(self.msel, "oracle_last_setpoint_sel_te_acc"): + return self.msel.oracle_last_setpoint_sel_te_acc + return -1 + def update(self, clear_counter=False): """ if the best model should be updated diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index ccb6e826b..c427724e1 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -9,16 +9,17 @@ class MSelSetpointDelay(MSelValPerf): 1. Model selection using validation performance 2. Only update if setpoint has been decreased """ - def __init__(self, max_es): - self.oracle_last_setpoing_sel_te_acc = 0.0 - super().__init__(max_es) + def __init__(self, msel): + self.msel = msel + self.oracle_last_setpoint_sel_te_acc = 0.0 + super().__init__(msel.max_es) def update(self, clear_counter=False): """ if the best model should be updated """ if clear_counter: - self.oracle_last_setpoing_sel_te_acc = self.sel_model_te_acc - flag = super().update(clear_counter) + self.oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc + flag = self.msel.update(clear_counter) # FIXME: flag is to persist model, which is not possible anymore return flag diff --git a/domainlab/algos/msels/c_msel_val.py b/domainlab/algos/msels/c_msel_val.py index 01497f0c4..56414f971 100644 --- a/domainlab/algos/msels/c_msel_val.py +++ b/domainlab/algos/msels/c_msel_val.py @@ -21,6 +21,7 @@ def update(self, clear_counter=False): if the best model should be updated """ flag = True + breakpoint() if self.tr_obs.metric_val is None or self.tr_obs.str_msel == "loss_tr": return super().update(clear_counter) metric = self.tr_obs.metric_val[self.tr_obs.str_metric4msel] diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index 82a0b99ca..56bf49968 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -97,6 +97,11 @@ def after_all(self): metric_te.update({"acc_val": self.model_sel.best_val_acc}) else: metric_te.update({"acc_val": -1}) + + if hasattr(self, "model_sel") and hasattr(self.model_sel, "oracle_last_setpoint_sel_te_acc"): + metric_te.update({"acc_setpoing":self.model_sel.oracle_last_setpoint_sel_te_acc}) + else: + metric_te.update({"acc_setpoint": -1}) self.dump_prediction(model_ld, metric_te) self.exp.visitor(metric_te) # prediction dump of test domain is essential to verify the prediction results diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index c31a5eb9a..3b074b62d 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -6,6 +6,7 @@ from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.fbopt_mu_controller import HyperSchedulerFeedback from domainlab.utils.logger import Logger +from domainlab.algos.msels.c_msel_setpoint_delay import MSelSetpointDelay def list_divide(list_val, scalar): @@ -78,6 +79,7 @@ def before_batch(self, epoch, ind_batch): return super().after_batch(epoch, ind_batch) def before_tr(self): + self.observer.model_sel.msel = MSelSetpointDelay(self.aconf.es) self.set_scheduler(scheduler=HyperSchedulerFeedback) self.set_model_with_mu() # very small value self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() From 94b7a7fe1c5bd6d7d494720486cd7f61db284d59 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 15:23:48 +0200 Subject: [PATCH 368/762] pid delta calculation negative value --- domainlab/algos/trainers/fbopt_mu_controller.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 44aa3d61e..dd1ffdc1b 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -9,6 +9,7 @@ import numpy as np from domainlab.utils.logger import Logger from domainlab.algos.trainers.fbopt_setpoint_ada import FbOptSetpointController +from domainlab.algos.trainers.fbopt_setpoint_ada import if_list_sign_agree class StubSummaryWriter(): @@ -88,7 +89,8 @@ def cal_delta4control(self, list1, list_setpoint): """ list difference """ - return [a - b for a, b in zip(list1, list_setpoint)] + if_list_sign_agree(list1, list_setpoint) + return [a - b if a >= 0 and b >= 0 else b - a for a, b in zip(list1, list_setpoint)] def cal_delta_integration(self, list_old, list_new, coeff): """ From d46412a79ff6da0af17a171cf5acb26f83b2dbd6 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 15:50:19 +0200 Subject: [PATCH 369/762] Update mnist_diva_fbopt_alone.yaml --- examples/benchmark/mnist_diva_fbopt_alone.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/mnist_diva_fbopt_alone.yaml b/examples/benchmark/mnist_diva_fbopt_alone.yaml index 50bb8105b..a2a7a6a70 100644 --- a/examples/benchmark/mnist_diva_fbopt_alone.yaml +++ b/examples/benchmark/mnist_diva_fbopt_alone.yaml @@ -48,7 +48,7 @@ Shared params: mu_init: min: 0.000001 - max: 0.00001 + max: 1 num: 3 distribution: loguniform From e53236f2e93640cf7661785a8b5ae39ea3535a50 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 16:02:42 +0200 Subject: [PATCH 370/762] Update benchmark_fbopt_pacs_diva.yaml --- examples/benchmark/benchmark_fbopt_pacs_diva.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml index a577c8a62..240897337 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml +++ b/examples/benchmark/benchmark_fbopt_pacs_diva.yaml @@ -47,7 +47,7 @@ Shared params: mu_init: min: 0.000001 - max: 0.00001 + max: 1 num: 3 distribution: loguniform From e0e4b72be03dddc7706967d91380f84552c7c3af Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 16:03:20 +0200 Subject: [PATCH 371/762] Rename benchmark_fbopt_pacs_diva.yaml to pacs_diva_fbopt_and_others.yaml --- ...hmark_fbopt_pacs_diva.yaml => pacs_diva_fbopt_and_others.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{benchmark_fbopt_pacs_diva.yaml => pacs_diva_fbopt_and_others.yaml} (100%) diff --git a/examples/benchmark/benchmark_fbopt_pacs_diva.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml similarity index 100% rename from examples/benchmark/benchmark_fbopt_pacs_diva.yaml rename to examples/benchmark/pacs_diva_fbopt_and_others.yaml From ea0ab3853c0ed02e49b67d79c38853e2f235783d Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 16:10:15 +0200 Subject: [PATCH 372/762] Update pacs_diva_fbopt_and_others.yaml --- examples/benchmark/pacs_diva_fbopt_and_others.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml index 240897337..2acebedd9 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_others.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full +output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_others sampling_seed: 0 From 542e2e24875ea178626e0a4c2372f2800d1ae580 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 17:13:01 +0200 Subject: [PATCH 373/762] . --- domainlab/algos/trainers/train_fbopt_b.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 3b074b62d..9cca70626 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -79,7 +79,8 @@ def before_batch(self, epoch, ind_batch): return super().after_batch(epoch, ind_batch) def before_tr(self): - self.observer.model_sel.msel = MSelSetpointDelay(self.aconf.es) + new_msel = MSelSetpointDelay(self.observer.model_sel.msel) + self.observer.model_sel.msel = new_msel self.set_scheduler(scheduler=HyperSchedulerFeedback) self.set_model_with_mu() # very small value self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() From 9ea0806b165298b12a45ee70fa5ecb7e98b89f36 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 13 Oct 2023 17:19:55 +0200 Subject: [PATCH 374/762] . --- domainlab/algos/msels/c_msel_setpoint_delay.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index c427724e1..7d9b531ee 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -1,6 +1,7 @@ """ Multiobjective Model Selection """ +import copy from domainlab.algos.msels.c_msel_val import MSelValPerf @@ -10,7 +11,7 @@ class MSelSetpointDelay(MSelValPerf): 2. Only update if setpoint has been decreased """ def __init__(self, msel): - self.msel = msel + self.msel = copy.deepcopy(msel) self.oracle_last_setpoint_sel_te_acc = 0.0 super().__init__(msel.max_es) From da21db6e1f6d4d987a9ed6947b8b952437e6012c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:00:37 +0200 Subject: [PATCH 375/762] Ignore msel string Update c_msel_val.py --- domainlab/algos/msels/c_msel_val.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_val.py b/domainlab/algos/msels/c_msel_val.py index 5796f3432..865dd3c8f 100644 --- a/domainlab/algos/msels/c_msel_val.py +++ b/domainlab/algos/msels/c_msel_val.py @@ -36,7 +36,7 @@ def update(self, clear_counter=False): """ flag = True breakpoint() - if self.tr_obs.metric_val is None or self.tr_obs.str_msel == "loss_tr": + if self.tr_obs.metric_val is None: return super().update(clear_counter) metric = self.tr_obs.metric_val[self.tr_obs.str_metric4msel] if self.tr_obs.metric_te is not None: From 32bd1095952f18f50ef12bec6f242219cff1e8eb Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:01:33 +0200 Subject: [PATCH 376/762] Update c_msel_val.py, delete breakpoint --- domainlab/algos/msels/c_msel_val.py | 1 - 1 file changed, 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_val.py b/domainlab/algos/msels/c_msel_val.py index 865dd3c8f..e51d68480 100644 --- a/domainlab/algos/msels/c_msel_val.py +++ b/domainlab/algos/msels/c_msel_val.py @@ -35,7 +35,6 @@ def update(self, clear_counter=False): if the best model should be updated """ flag = True - breakpoint() if self.tr_obs.metric_val is None: return super().update(clear_counter) metric = self.tr_obs.metric_val[self.tr_obs.str_metric4msel] From af784f41a90a3642d31ddb414d804b3d7fa415b2 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:07:16 +0200 Subject: [PATCH 377/762] Update b_obvisitor.py, add flag_info to observer.update --- domainlab/algos/observers/b_obvisitor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index fffe481d6..df456f2c3 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -38,7 +38,7 @@ def str_metric4msel(self): """ return self.host_trainer.str_metric4msel - def update(self, epoch): + def update(self, epoch, flag_info=False): logger = Logger.get_logger() logger.info(f"epoch: {epoch}") self.epo = epoch @@ -55,7 +55,7 @@ def update(self, epoch): metric_te = self.host_trainer.model.cal_perf_metric( self.loader_te, self.device) self.metric_te = metric_te - if self.model_sel.update(): + if self.model_sel.update(flag_info): logger.info("better model found") self.exp.visitor.save(self.host_trainer.model) logger.info("persisted") From fc3a4dc432449fbc2fcba471f3d03929d34576e6 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:08:34 +0200 Subject: [PATCH 378/762] Update c_obvisitor_cleanup.py --- domainlab/algos/observers/c_obvisitor_cleanup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/observers/c_obvisitor_cleanup.py b/domainlab/algos/observers/c_obvisitor_cleanup.py index fe5d3819e..0a5467570 100644 --- a/domainlab/algos/observers/c_obvisitor_cleanup.py +++ b/domainlab/algos/observers/c_obvisitor_cleanup.py @@ -16,8 +16,8 @@ def after_all(self): def accept(self, trainer): self.observer.accept(trainer) - def update(self, epoch): - return self.observer.update(epoch) + def update(self, epoch, flag_info=False): + return self.observer.update(epoch, flag_info) def clean_up(self): self.observer.clean_up() From 59d7ec75327e43d6a3ddadefaba0e8bbba81910d Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:13:02 +0200 Subject: [PATCH 379/762] Boolean to indicate setpoing update Update fbopt_setpoint_ada.py --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 124155e90..b91a66f9a 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -173,6 +173,8 @@ def observe(self, epo_reg_loss, epo_task_loss): logger.info(f"!!!!!set point old value {self.setpoint4R}!") self.update_setpoint_ma(self.state_epo_reg_loss, list_pos) logger.info(f"!!!!!set point updated to {self.setpoint4R}!") + return True + return False class FbOptSetpointControllerState(): From 5026ec76578c39cf6f211b7af994ca0f106321dc Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:14:09 +0200 Subject: [PATCH 380/762] Mu controller return if setpoint has been updated Update fbopt_mu_controller.py --- domainlab/algos/trainers/fbopt_mu_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index dd1ffdc1b..94ad74b32 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -184,4 +184,4 @@ def update_setpoint(self, epo_reg_loss, epo_task_loss): """ update setpoint """ - self.set_point_controller.observe(epo_reg_loss, epo_task_loss) + return self.set_point_controller.observe(epo_reg_loss, epo_task_loss) From 0a03ebb0daa562c1e68094524bfb6ae402dd47ee Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:17:40 +0200 Subject: [PATCH 381/762] Flag IF SETPOINT UPDATED Update train_fbopt_b.py --- domainlab/algos/trainers/train_fbopt_b.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 9cca70626..1cf6f614a 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -79,6 +79,7 @@ def before_batch(self, epoch, ind_batch): return super().after_batch(epoch, ind_batch) def before_tr(self): + self.flag_setpoint_updated = False new_msel = MSelSetpointDelay(self.observer.model_sel.msel) self.observer.model_sel.msel = new_msel self.set_scheduler(scheduler=HyperSchedulerFeedback) @@ -121,5 +122,5 @@ def tr_epoch(self, epoch): flag = super().tr_epoch(epoch) # is it good to update setpoint after we know the new value of each loss? - self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) + self.setpoint_updated = self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) return flag From 26e3171c5afa331971e2650c4e11f88e47406da8 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:18:38 +0200 Subject: [PATCH 382/762] Add flag_info to tr_epoch() Update train_basic.py --- domainlab/algos/trainers/train_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_basic.py b/domainlab/algos/trainers/train_basic.py index f63ca79c6..165d090b4 100644 --- a/domainlab/algos/trainers/train_basic.py +++ b/domainlab/algos/trainers/train_basic.py @@ -22,7 +22,7 @@ def before_tr(self): """ self.model.evaluate(self.loader_te, self.device) - def tr_epoch(self, epoch): + def tr_epoch(self, epoch, flag_info=False): self.model.train() self.counter_batch = 0.0 self.epo_loss_tr = 0 @@ -35,7 +35,7 @@ def tr_epoch(self, epoch): self.epo_reg_loss_tr = list_divide(self.epo_reg_loss_tr, self.counter_batch) assert self.epo_loss_tr is not None assert not math.isnan(self.epo_loss_tr) - flag_stop = self.observer.update(epoch) # notify observer + flag_stop = self.observer.update(epoch, flag_info) # notify observer assert flag_stop is not None return flag_stop From 05ba8f643c76e8ce6717475d4b50940af66c98e7 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:20:27 +0200 Subject: [PATCH 383/762] Add setpoint updated flag to tr_epoch Update train_fbopt_b.py --- domainlab/algos/trainers/train_fbopt_b.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 1cf6f614a..9aa91e5bb 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -120,7 +120,7 @@ def tr_epoch(self, epoch): miter=epoch) self.set_model_with_mu() - flag = super().tr_epoch(epoch) + flag = super().tr_epoch(epoch, self.flag_setpoint_updated) # is it good to update setpoint after we know the new value of each loss? - self.setpoint_updated = self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) + self.flag_setpoint_updated = self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) return flag From a126c9f23808d3f983c92201f88afeb5876279b4 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:24:06 +0200 Subject: [PATCH 384/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 7d9b531ee..29bb76aac 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -12,15 +12,18 @@ class MSelSetpointDelay(MSelValPerf): """ def __init__(self, msel): self.msel = copy.deepcopy(msel) - self.oracle_last_setpoint_sel_te_acc = 0.0 + self._oracle_last_setpoint_sel_te_acc = 0.0 super().__init__(msel.max_es) - + + def self.oracle_last_setpoing_sel_te_acc(self): + return self._oracle_last_setpoint_sel_te_acc + def update(self, clear_counter=False): """ if the best model should be updated """ if clear_counter: - self.oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc + self._oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc flag = self.msel.update(clear_counter) # FIXME: flag is to persist model, which is not possible anymore return flag From 5ddd31cc45f7d994208195f74a38756742aadeba Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:27:50 +0200 Subject: [PATCH 385/762] Update c_msel_val.py --- domainlab/algos/msels/c_msel_val.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_val.py b/domainlab/algos/msels/c_msel_val.py index e51d68480..8f7cc95b8 100644 --- a/domainlab/algos/msels/c_msel_val.py +++ b/domainlab/algos/msels/c_msel_val.py @@ -12,10 +12,14 @@ class MSelValPerf(MSelTrLoss): """ def __init__(self, max_es): self._best_val_acc = 0.0 - self.sel_model_te_acc = 0.0 + self._sel_model_te_acc = 0.0 self._best_te_metric = 0.0 super().__init__(max_es) # construct self.tr_obs (observer) + @property + def sel_model_te_acc(self): + return self._sel_model_te_acc + @property def best_val_acc(self): """ @@ -51,7 +55,7 @@ def update(self, clear_counter=False): if self.tr_obs.metric_te is not None: metric_te_current = \ self.tr_obs.metric_te[self.tr_obs.str_metric4msel] - self.sel_model_te_acc = metric_te_current + self._sel_model_te_acc = metric_te_current else: self.es_c += 1 From 90ff514e9045f9f47743367160193f1b448302f3 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:28:55 +0200 Subject: [PATCH 386/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 29bb76aac..47a517260 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -14,7 +14,8 @@ def __init__(self, msel): self.msel = copy.deepcopy(msel) self._oracle_last_setpoint_sel_te_acc = 0.0 super().__init__(msel.max_es) - + + @property def self.oracle_last_setpoing_sel_te_acc(self): return self._oracle_last_setpoint_sel_te_acc From 85a2faa43813e21cd6e7bdea2552c0246c2240f5 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:30:22 +0200 Subject: [PATCH 387/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index db4d892ad..8b0942177 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -57,3 +57,9 @@ def best_te_metric(self): if self.msel is not None: return self.msel.best_te_metric return -1 + + @property + def sel_model_te_acc(self): + if self.msel is not None: + return self.msel.sel_model_te_acc + return -1 From dcaab197d5fd0d12b9b1ae8cf8f82620980ed0c4 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:31:39 +0200 Subject: [PATCH 388/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 47a517260..c76603e19 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -16,7 +16,7 @@ def __init__(self, msel): super().__init__(msel.max_es) @property - def self.oracle_last_setpoing_sel_te_acc(self): + def self.oracle_last_setpoint_sel_te_acc(self): return self._oracle_last_setpoint_sel_te_acc def update(self, clear_counter=False): From 870ef6512f24e4acd08eade47b636068367cc4d6 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:34:06 +0200 Subject: [PATCH 389/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 8b0942177..ff0b3b383 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -63,3 +63,9 @@ def sel_model_te_acc(self): if self.msel is not None: return self.msel.sel_model_te_acc return -1 + + @property + def oracle_last_setpoint_sel_te_acc(self): + if self.msel is not None: + return self.msel.oracle_last_setpoint_sel_te_acc + return -1 \ No newline at end of file From f575a71b355080ff69ad847afefd6aef12abfc6e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:35:14 +0200 Subject: [PATCH 390/762] Update b_obvisitor.py --- domainlab/algos/observers/b_obvisitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index df456f2c3..ca643ccff 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -105,7 +105,7 @@ def after_all(self): metric_te.update({"acc_val": -1}) if hasattr(self, "model_sel") and hasattr(self.model_sel, "oracle_last_setpoint_sel_te_acc"): - metric_te.update({"acc_setpoing":self.model_sel.oracle_last_setpoint_sel_te_acc}) + metric_te.update({"acc_setpoint":self.model_sel.oracle_last_setpoint_sel_te_acc}) else: metric_te.update({"acc_setpoint": -1}) self.dump_prediction(model_ld, metric_te) From 1a9e3465c3e67c474a7ad7ecd0b8462a3152fc04 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 18:50:57 +0200 Subject: [PATCH 391/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index c76603e19..a87e491f0 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -16,7 +16,7 @@ def __init__(self, msel): super().__init__(msel.max_es) @property - def self.oracle_last_setpoint_sel_te_acc(self): + def oracle_last_setpoint_sel_te_acc(self): return self._oracle_last_setpoint_sel_te_acc def update(self, clear_counter=False): From d5a7d825853b41808b1994c7e8492c3c249acc5c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:28:58 +0200 Subject: [PATCH 392/762] Update mnist_jigen_fbopt_alone.yaml --- examples/benchmark/mnist_jigen_fbopt_alone.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/benchmark/mnist_jigen_fbopt_alone.yaml b/examples/benchmark/mnist_jigen_fbopt_alone.yaml index 7501f1a0d..10a10db80 100644 --- a/examples/benchmark/mnist_jigen_fbopt_alone.yaml +++ b/examples/benchmark/mnist_jigen_fbopt_alone.yaml @@ -76,5 +76,3 @@ jigen_feedback: shared: - k_i_gain - mu_init - - setpoint_rewind - - overshoot_rewind From a047f9cf0518f99344fe6b8cade1e82065fb98a1 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:37:06 +0200 Subject: [PATCH 393/762] Update train_fbopt_b.py --- domainlab/algos/trainers/train_fbopt_b.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 9aa91e5bb..6e61fa1f5 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -80,8 +80,8 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.flag_setpoint_updated = False - new_msel = MSelSetpointDelay(self.observer.model_sel.msel) - self.observer.model_sel.msel = new_msel + new_msel = MSelSetpointDelay(self.observer.model_sel) + self.observer.model_sel = new_msel self.set_scheduler(scheduler=HyperSchedulerFeedback) self.set_model_with_mu() # very small value self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() From e1a5b76600bfe6a765928b9b2f03c4d73150463f Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:40:24 +0200 Subject: [PATCH 394/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index ff0b3b383..0a9df56f6 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -16,6 +16,7 @@ def __init__(self): self.trainer = None self.tr_obs = None self.msel = None + self.max_es = None def accept(self, trainer, tr_obs): """ @@ -68,4 +69,4 @@ def sel_model_te_acc(self): def oracle_last_setpoint_sel_te_acc(self): if self.msel is not None: return self.msel.oracle_last_setpoint_sel_te_acc - return -1 \ No newline at end of file + return -1 From f45f4006ec4344395d8e763628d217d1916d1568 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:47:35 +0200 Subject: [PATCH 395/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index a87e491f0..128dd7c49 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -11,7 +11,7 @@ class MSelSetpointDelay(MSelValPerf): 2. Only update if setpoint has been decreased """ def __init__(self, msel): - self.msel = copy.deepcopy(msel) + self.msel = msel self._oracle_last_setpoint_sel_te_acc = 0.0 super().__init__(msel.max_es) From 7a96b3f972a8b79ab2efcad0ffa45698eff9330e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:49:15 +0200 Subject: [PATCH 396/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 128dd7c49..11894e5c8 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -2,18 +2,18 @@ Multiobjective Model Selection """ import copy -from domainlab.algos.msels.c_msel_val import MSelValPerf +from domainlab.algos.msels.a_model_sel import AMSel -class MSelSetpointDelay(MSelValPerf): +class MSelSetpointDelay(AMsel): """ 1. Model selection using validation performance 2. Only update if setpoint has been decreased """ def __init__(self, msel): + super().__init__() self.msel = msel self._oracle_last_setpoint_sel_te_acc = 0.0 - super().__init__(msel.max_es) @property def oracle_last_setpoint_sel_te_acc(self): From 683437f2af02146f213a302da9f5030200e18f39 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:49:57 +0200 Subject: [PATCH 397/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 11894e5c8..09533a4cb 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -5,7 +5,7 @@ from domainlab.algos.msels.a_model_sel import AMSel -class MSelSetpointDelay(AMsel): +class MSelSetpointDelay(AMSel): """ 1. Model selection using validation performance 2. Only update if setpoint has been decreased From 10259c1184ea435017a12f9853a5463e9a7d0851 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:50:44 +0200 Subject: [PATCH 398/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 09533a4cb..64f6a5143 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -17,6 +17,9 @@ def __init__(self, msel): @property def oracle_last_setpoint_sel_te_acc(self): + """ + return the last setpoint best acc + """ return self._oracle_last_setpoint_sel_te_acc def update(self, clear_counter=False): @@ -26,5 +29,4 @@ def update(self, clear_counter=False): if clear_counter: self._oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc flag = self.msel.update(clear_counter) - # FIXME: flag is to persist model, which is not possible anymore return flag From 02ef28daa8e428e49ae15d928b7c55ee09a363e5 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:53:09 +0200 Subject: [PATCH 399/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 0a9df56f6..7e82b9e2e 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -39,6 +39,8 @@ def if_stop(self): check if trainer should stop return boolean """ + if self.msel is not None: + return self.msel.if_stop() raise NotImplementedError @property From 683f921b5c29a62a18b46a4d4cf484b81bef1684 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:55:43 +0200 Subject: [PATCH 400/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 64f6a5143..9fbf7e706 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -13,6 +13,7 @@ class MSelSetpointDelay(AMSel): def __init__(self, msel): super().__init__() self.msel = msel + self.max_es = msel.max_es self._oracle_last_setpoint_sel_te_acc = 0.0 @property From 7f92ff9afa01de1a1c39d180bb94764b4366b382 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 19:56:46 +0200 Subject: [PATCH 401/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 9fbf7e706..1b0df8fbb 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -14,6 +14,8 @@ def __init__(self, msel): super().__init__() self.msel = msel self.max_es = msel.max_es + self.tr_obs = msel.tr_obs + self.trainer = msel.trainer self._oracle_last_setpoint_sel_te_acc = 0.0 @property From 8323275bd749ca68eb334eacf4a9c9ae987ab34d Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:01:22 +0200 Subject: [PATCH 402/762] Update train_fbopt_b.py --- domainlab/algos/trainers/train_fbopt_b.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 6e61fa1f5..cca2ce064 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -80,8 +80,7 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.flag_setpoint_updated = False - new_msel = MSelSetpointDelay(self.observer.model_sel) - self.observer.model_sel = new_msel + self.observer.model_sel = MSelSetpointDelay(self.observer.model_sel) self.set_scheduler(scheduler=HyperSchedulerFeedback) self.set_model_with_mu() # very small value self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() From cd890d14b200e686dab5b84eb886635731b41813 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:03:45 +0200 Subject: [PATCH 403/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 7e82b9e2e..0a9df56f6 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -39,8 +39,6 @@ def if_stop(self): check if trainer should stop return boolean """ - if self.msel is not None: - return self.msel.if_stop() raise NotImplementedError @property From 332c79d0c6ece5ba2849f0c45497a1baff2e9bd4 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:06:33 +0200 Subject: [PATCH 404/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 0a9df56f6..7e82b9e2e 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -39,6 +39,8 @@ def if_stop(self): check if trainer should stop return boolean """ + if self.msel is not None: + return self.msel.if_stop() raise NotImplementedError @property From 8960548659f4e7fd9053d70494fa5367a27c8679 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:08:22 +0200 Subject: [PATCH 405/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 7e82b9e2e..502c450dc 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -16,7 +16,13 @@ def __init__(self): self.trainer = None self.tr_obs = None self.msel = None - self.max_es = None + self._max_es = None + + @property + def max_es(self): + if self.msel is not None: + return self.msel.max_es + return self._max_es def accept(self, trainer, tr_obs): """ From fb43509fb171a35ec9552700af2dc293f9e8cfa6 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:09:23 +0200 Subject: [PATCH 406/762] Update c_msel_tr_loss.py --- domainlab/algos/msels/c_msel_tr_loss.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_tr_loss.py b/domainlab/algos/msels/c_msel_tr_loss.py index 3b9d4581e..5f878f553 100644 --- a/domainlab/algos/msels/c_msel_tr_loss.py +++ b/domainlab/algos/msels/c_msel_tr_loss.py @@ -14,9 +14,13 @@ class MSelTrLoss(AMSel): def __init__(self, max_es): self.best_loss = float("inf") self.es_c = 0 - self.max_es = max_es + self._max_es = max_es super().__init__() + @property + def max_es(self): + return self._max_es + def update(self, clear_counter=False): """ if the best model should be updated From 2fd10d5f7fa6017a51319cad36b1528d729b17ad Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:10:20 +0200 Subject: [PATCH 407/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 1b0df8fbb..e1cf71aed 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -13,7 +13,6 @@ class MSelSetpointDelay(AMSel): def __init__(self, msel): super().__init__() self.msel = msel - self.max_es = msel.max_es self.tr_obs = msel.tr_obs self.trainer = msel.trainer self._oracle_last_setpoint_sel_te_acc = 0.0 From fe3ceab4066869f3a6543a46c32e0dc8e236f91e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:16:45 +0200 Subject: [PATCH 408/762] Update train_fbopt_b.py --- domainlab/algos/trainers/train_fbopt_b.py | 1 - 1 file changed, 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index cca2ce064..b6b763fb7 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -80,7 +80,6 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.flag_setpoint_updated = False - self.observer.model_sel = MSelSetpointDelay(self.observer.model_sel) self.set_scheduler(scheduler=HyperSchedulerFeedback) self.set_model_with_mu() # very small value self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() From 9100e97ac0f94a9318c7968a1109dddc610ce8ad Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:18:56 +0200 Subject: [PATCH 409/762] Update builder_jigen1.py --- domainlab/algos/builder_jigen1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/builder_jigen1.py b/domainlab/algos/builder_jigen1.py index a04129031..30b31ea14 100644 --- a/domainlab/algos/builder_jigen1.py +++ b/domainlab/algos/builder_jigen1.py @@ -4,6 +4,7 @@ from domainlab.algos.a_algo_builder import NodeAlgoBuilder from domainlab.algos.msels.c_msel_val import MSelValPerf from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor +from domainlab.algos.msel.c_msel_setpoint_delay import MselSetpointDelay from domainlab.algos.observers.b_obvisitor import ObVisitor from domainlab.algos.observers.c_obvisitor_cleanup import ObVisitorCleanUp from domainlab.algos.trainers.train_hyper_scheduler import TrainerHyperScheduler @@ -39,7 +40,7 @@ def init_business(self, exp): task = exp.task args = exp.args device = get_device(args) - msel = MSelOracleVisitor(MSelValPerf(max_es=args.es)) + msel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerf(max_es=args.es))) observer = ObVisitor(msel, device, exp=exp) observer = ObVisitorCleanUp(observer) From 2d69af0d5b76c5113bc5b440111f20d8fe5e7bcb Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:19:24 +0200 Subject: [PATCH 410/762] Update builder_jigen1.py --- domainlab/algos/builder_jigen1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/builder_jigen1.py b/domainlab/algos/builder_jigen1.py index 30b31ea14..036e4cff8 100644 --- a/domainlab/algos/builder_jigen1.py +++ b/domainlab/algos/builder_jigen1.py @@ -4,7 +4,7 @@ from domainlab.algos.a_algo_builder import NodeAlgoBuilder from domainlab.algos.msels.c_msel_val import MSelValPerf from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor -from domainlab.algos.msel.c_msel_setpoint_delay import MselSetpointDelay +from domainlab.algos.msels.c_msel_setpoint_delay import MselSetpointDelay from domainlab.algos.observers.b_obvisitor import ObVisitor from domainlab.algos.observers.c_obvisitor_cleanup import ObVisitorCleanUp from domainlab.algos.trainers.train_hyper_scheduler import TrainerHyperScheduler From 9503a0c0355519c8161a8cca6b5ecf3b0c1ed366 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:20:03 +0200 Subject: [PATCH 411/762] Update builder_jigen1.py --- domainlab/algos/builder_jigen1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/builder_jigen1.py b/domainlab/algos/builder_jigen1.py index 036e4cff8..3c3b8c4f3 100644 --- a/domainlab/algos/builder_jigen1.py +++ b/domainlab/algos/builder_jigen1.py @@ -4,7 +4,7 @@ from domainlab.algos.a_algo_builder import NodeAlgoBuilder from domainlab.algos.msels.c_msel_val import MSelValPerf from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor -from domainlab.algos.msels.c_msel_setpoint_delay import MselSetpointDelay +from domainlab.algos.msels.c_msel_setpoint_delay import MSelSetpointDelay from domainlab.algos.observers.b_obvisitor import ObVisitor from domainlab.algos.observers.c_obvisitor_cleanup import ObVisitorCleanUp from domainlab.algos.trainers.train_hyper_scheduler import TrainerHyperScheduler From 341c894e01bc96eb9e41da0110ff87662d3d80bb Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:22:01 +0200 Subject: [PATCH 412/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index e1cf71aed..738478add 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -13,8 +13,8 @@ class MSelSetpointDelay(AMSel): def __init__(self, msel): super().__init__() self.msel = msel - self.tr_obs = msel.tr_obs - self.trainer = msel.trainer + self.tr_obs = msel.msel.tr_obs + self.trainer = msel.msel.trainer self._oracle_last_setpoint_sel_te_acc = 0.0 @property From 977c90c3b16266130d080ba54bb6cda7eafffb69 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:26:24 +0200 Subject: [PATCH 413/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 502c450dc..aa5b7b746 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -14,10 +14,16 @@ def __init__(self): trainer and tr_observer """ self.trainer = None - self.tr_obs = None + self._tr_obs = None self.msel = None self._max_es = None + @property(self): + def tr_obs(self): + if self.msel is not None: + return self.msel.tr_obs + return self._tr_obs + @property def max_es(self): if self.msel is not None: From 2abac738ec775afc37a7ab785431e8f9cabde2f8 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:26:40 +0200 Subject: [PATCH 414/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index aa5b7b746..f8847413b 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -36,7 +36,7 @@ def accept(self, trainer, tr_obs): accept trainer and tr_observer """ self.trainer = trainer - self.tr_obs = tr_obs + self._tr_obs = tr_obs @abc.abstractmethod def update(self, clear_counter=False): From e1f4ced3b80b1e40716b5cbc8d923c9eaebe1d92 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:27:32 +0200 Subject: [PATCH 415/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 738478add..64f6a5143 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -13,8 +13,6 @@ class MSelSetpointDelay(AMSel): def __init__(self, msel): super().__init__() self.msel = msel - self.tr_obs = msel.msel.tr_obs - self.trainer = msel.msel.trainer self._oracle_last_setpoint_sel_te_acc = 0.0 @property From 1df4df51a15fc9efddf442bcdb5747bf0ef350e1 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:28:09 +0200 Subject: [PATCH 416/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index f8847413b..89e85b569 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -18,7 +18,7 @@ def __init__(self): self.msel = None self._max_es = None - @property(self): + @property def tr_obs(self): if self.msel is not None: return self.msel.tr_obs From e08c2550b4cad3f1ac0324a883bd6e32b5c75a86 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:32:28 +0200 Subject: [PATCH 417/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 89e85b569..a121dc99c 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -20,7 +20,7 @@ def __init__(self): @property def tr_obs(self): - if self.msel is not None: + if self._tr_obs is None and self.msel is not None: return self.msel.tr_obs return self._tr_obs From 0fc203bcb95a202291e60adcd2072865cbfaf278 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:35:49 +0200 Subject: [PATCH 418/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index a121dc99c..0bfa2fb33 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -37,6 +37,9 @@ def accept(self, trainer, tr_obs): """ self.trainer = trainer self._tr_obs = tr_obs + if self.msel is not None: + self.msel.trainer=trainer + self.msel._tr_obs = tr_obs @abc.abstractmethod def update(self, clear_counter=False): From 4c5a284fa67a424359c9c9d8dfcb851d25a35b4d Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:39:51 +0200 Subject: [PATCH 419/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 0bfa2fb33..eb2efacd5 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -20,8 +20,6 @@ def __init__(self): @property def tr_obs(self): - if self._tr_obs is None and self.msel is not None: - return self.msel.tr_obs return self._tr_obs @property @@ -38,8 +36,7 @@ def accept(self, trainer, tr_obs): self.trainer = trainer self._tr_obs = tr_obs if self.msel is not None: - self.msel.trainer=trainer - self.msel._tr_obs = tr_obs + self.msel.accept(trainer, tr_obs) @abc.abstractmethod def update(self, clear_counter=False): From 730eeb3ad9720c5a7a69c4ade467b3916260cb80 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:43:06 +0200 Subject: [PATCH 420/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index eb2efacd5..7d6b6a68a 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -24,6 +24,8 @@ def tr_obs(self): @property def max_es(self): + if self._max_es is not None: + return self._max_es if self.msel is not None: return self.msel.max_es return self._max_es From d1d95d4fcfab88cec576e8392959fe1d01215185 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:47:27 +0200 Subject: [PATCH 421/762] Update builder_jigen1.py --- domainlab/algos/builder_jigen1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/builder_jigen1.py b/domainlab/algos/builder_jigen1.py index 3c3b8c4f3..0cdb317d3 100644 --- a/domainlab/algos/builder_jigen1.py +++ b/domainlab/algos/builder_jigen1.py @@ -41,6 +41,7 @@ def init_business(self, exp): args = exp.args device = get_device(args) msel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerf(max_es=args.es))) + breakpoint() observer = ObVisitor(msel, device, exp=exp) observer = ObVisitorCleanUp(observer) From 398a2c04e31596f87b6a7aa070d01103f088372a Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:50:28 +0200 Subject: [PATCH 422/762] Update c_msel_tr_loss.py --- domainlab/algos/msels/c_msel_tr_loss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_tr_loss.py b/domainlab/algos/msels/c_msel_tr_loss.py index 5f878f553..4cba7f61f 100644 --- a/domainlab/algos/msels/c_msel_tr_loss.py +++ b/domainlab/algos/msels/c_msel_tr_loss.py @@ -12,10 +12,10 @@ class MSelTrLoss(AMSel): 2. Visitor pattern to trainer """ def __init__(self, max_es): + super().__init__() self.best_loss = float("inf") self.es_c = 0 self._max_es = max_es - super().__init__() @property def max_es(self): From a5edd9c7c72dda9f26a45528e73d4ef5684afc05 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:52:00 +0200 Subject: [PATCH 423/762] Update builder_jigen1.py --- domainlab/algos/builder_jigen1.py | 1 - 1 file changed, 1 deletion(-) diff --git a/domainlab/algos/builder_jigen1.py b/domainlab/algos/builder_jigen1.py index 0cdb317d3..3c3b8c4f3 100644 --- a/domainlab/algos/builder_jigen1.py +++ b/domainlab/algos/builder_jigen1.py @@ -41,7 +41,6 @@ def init_business(self, exp): args = exp.args device = get_device(args) msel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerf(max_es=args.es))) - breakpoint() observer = ObVisitor(msel, device, exp=exp) observer = ObVisitorCleanUp(observer) From f636f16f03a47ee3bc6dc1e49c16d3774d55ce31 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 20:52:56 +0200 Subject: [PATCH 424/762] Update builder_diva.py --- domainlab/algos/builder_diva.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/builder_diva.py b/domainlab/algos/builder_diva.py index adf59df67..8ad1e6321 100644 --- a/domainlab/algos/builder_diva.py +++ b/domainlab/algos/builder_diva.py @@ -4,6 +4,7 @@ from domainlab.algos.a_algo_builder import NodeAlgoBuilder from domainlab.algos.msels.c_msel_val import MSelValPerf from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor +from domainlab.algos.msels.c_msel_setpoint_delay import MSelSetpointDelay from domainlab.algos.observers.b_obvisitor import ObVisitor from domainlab.algos.observers.c_obvisitor_cleanup import ObVisitorCleanUp from domainlab.algos.observers.c_obvisitor_gen import ObVisitorGen @@ -47,7 +48,7 @@ def init_business(self, exp): beta_y=args.beta_y, beta_d=args.beta_d) device = get_device(args) - model_sel = MSelOracleVisitor(MSelValPerf(max_es=args.es)) + model_sel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerf(max_es=args.es))) if not args.gen: observer = ObVisitorCleanUp( ObVisitor(model_sel, From baac295d7a4928fdefaa74f56c28516fd6cca7e8 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 21:19:59 +0200 Subject: [PATCH 425/762] Update mnist_diva_fbopt_alone.yaml --- examples/benchmark/mnist_diva_fbopt_alone.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/mnist_diva_fbopt_alone.yaml b/examples/benchmark/mnist_diva_fbopt_alone.yaml index a2a7a6a70..87e80c31b 100644 --- a/examples/benchmark/mnist_diva_fbopt_alone.yaml +++ b/examples/benchmark/mnist_diva_fbopt_alone.yaml @@ -49,7 +49,7 @@ Shared params: mu_init: min: 0.000001 max: 1 - num: 3 + num: 4 distribution: loguniform gamma_y: From d51567ce5161037573460e16c5792d73dae9e11c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 22:16:49 +0200 Subject: [PATCH 426/762] Update and rename benchmark_fbopt_mnist_diva.yaml to mnist_diva_baselines.yaml --- ...k_fbopt_mnist_diva.yaml => mnist_diva_baselines.yaml} | 9 --------- 1 file changed, 9 deletions(-) rename examples/benchmark/{benchmark_fbopt_mnist_diva.yaml => mnist_diva_baselines.yaml} (89%) diff --git a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml b/examples/benchmark/mnist_diva_baselines.yaml similarity index 89% rename from examples/benchmark/benchmark_fbopt_mnist_diva.yaml rename to examples/benchmark/mnist_diva_baselines.yaml index ef2d48211..7175dff02 100644 --- a/examples/benchmark/benchmark_fbopt_mnist_diva.yaml +++ b/examples/benchmark/mnist_diva_baselines.yaml @@ -68,16 +68,7 @@ Shared params: # Test fbopt with different hyperparameter configurations -diva_fbopt_a: - aname: diva - trainer: fbopt - str_diva_multiplier_type: gammad_recon - gamma_y: 1.0 - init_setpoint_ratio: 0.99 - shared: - - k_i_gain - - mu_init diva_feedforward_a: aname: diva From dbdb55f84b3f4d10455d0b3fc96eecf85771b9a2 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 22:36:44 +0200 Subject: [PATCH 427/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 64f6a5143..7e9ceb50c 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -12,6 +12,7 @@ class MSelSetpointDelay(AMSel): """ def __init__(self, msel): super().__init__() + # NOTE: super() has to come first always otherwise self.msel will be overwritten to be None self.msel = msel self._oracle_last_setpoint_sel_te_acc = 0.0 From eb1e0a02de87694abd669499d7fc29c58bd3fc26 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 22:38:55 +0200 Subject: [PATCH 428/762] Update a_model_sel.py --- domainlab/algos/msels/a_model_sel.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index 7d6b6a68a..a8ed30d06 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -53,6 +53,10 @@ def if_stop(self): check if trainer should stop return boolean """ + # NOTE: since if_stop is not abstract, one has to + # be careful to always override it in child class + # only if the child class has a decorator which will + # dispatched. if self.msel is not None: return self.msel.if_stop() raise NotImplementedError From 851aaf7d8b08f5c8383da4733e3c826487ba9d3a Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 22:41:32 +0200 Subject: [PATCH 429/762] Update c_msel_tr_loss.py --- domainlab/algos/msels/c_msel_tr_loss.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/msels/c_msel_tr_loss.py b/domainlab/algos/msels/c_msel_tr_loss.py index 4cba7f61f..f44831944 100644 --- a/domainlab/algos/msels/c_msel_tr_loss.py +++ b/domainlab/algos/msels/c_msel_tr_loss.py @@ -13,6 +13,7 @@ class MSelTrLoss(AMSel): """ def __init__(self, max_es): super().__init__() + # NOTE: super() must come first otherwise it will overwrite existing values! self.best_loss = float("inf") self.es_c = 0 self._max_es = max_es From d3a9be650a5e9c7b3194d1e22ab2da147f80059c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 23:14:11 +0200 Subject: [PATCH 430/762] Update pacs_diva_fbopt_and_others.yaml --- examples/benchmark/pacs_diva_fbopt_and_others.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml index 2acebedd9..5a3140334 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_others.yaml @@ -14,8 +14,8 @@ domainlab_args: tpath: examples/tasks/task_pacs_path_list.py dmem: False lr: 5e-5 - epos: 200 - es: 10 + epos: 2000 + es: 500 bs: 64 san_check: True npath: examples/nets/resnet50domainbed.py @@ -47,7 +47,7 @@ Shared params: mu_init: min: 0.000001 - max: 1 + max: 0.9 num: 3 distribution: loguniform From dce80dd2ee2bed014dccbf91b18fc4f851099933 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 23:15:20 +0200 Subject: [PATCH 431/762] Rename benchmark_fbopt_mnist_jigen.yaml to mnist_jigen_fbopt_and_others.yaml --- ...k_fbopt_mnist_jigen.yaml => mnist_jigen_fbopt_and_others.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{benchmark_fbopt_mnist_jigen.yaml => mnist_jigen_fbopt_and_others.yaml} (100%) diff --git a/examples/benchmark/benchmark_fbopt_mnist_jigen.yaml b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml similarity index 100% rename from examples/benchmark/benchmark_fbopt_mnist_jigen.yaml rename to examples/benchmark/mnist_jigen_fbopt_and_others.yaml From 4f17f89b11f7e2bc42282e4a2ec2c71cc143f07a Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 23:16:13 +0200 Subject: [PATCH 432/762] Update c_msel_val.py allow equal val --- domainlab/algos/msels/c_msel_val.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_val.py b/domainlab/algos/msels/c_msel_val.py index 8f7cc95b8..2dd39d801 100644 --- a/domainlab/algos/msels/c_msel_val.py +++ b/domainlab/algos/msels/c_msel_val.py @@ -47,7 +47,7 @@ def update(self, clear_counter=False): self.tr_obs.metric_te[self.tr_obs.str_metric4msel] self._best_te_metric = max(self._best_te_metric, metric_te_current) - if metric > self._best_val_acc: # update hat{model} + if metric >= self._best_val_acc: # update hat{model} # different from loss, accuracy should be improved: # the bigger the better self._best_val_acc = metric From b487d965cf5dfcfe733a364b37fa1e2500dd8f91 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 23:18:52 +0200 Subject: [PATCH 433/762] Update mnist_jigen_fbopt_and_others.yaml --- examples/benchmark/mnist_jigen_fbopt_and_others.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/mnist_jigen_fbopt_and_others.yaml b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml index c58868965..88dbd1ff5 100644 --- a/examples/benchmark/mnist_jigen_fbopt_and_others.yaml +++ b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/benchmark_fbopt +output_dir: zoutput/benchmarks/mnist_fbopt_and_others sampling_seed: 0 startseed: 0 From 7b4f4d592b74fdcc80b20edfa2d265b29664c8f2 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 23:21:20 +0200 Subject: [PATCH 434/762] Update mnist_diva_baselines.yaml --- examples/benchmark/mnist_diva_baselines.yaml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/mnist_diva_baselines.yaml b/examples/benchmark/mnist_diva_baselines.yaml index 7175dff02..ec55ad9e9 100644 --- a/examples/benchmark/mnist_diva_baselines.yaml +++ b/examples/benchmark/mnist_diva_baselines.yaml @@ -15,8 +15,8 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 500 - es: 50 + epos: 2000 + es: 500 bs: 64 zx_dim: 0 zy_dim: 32 @@ -68,7 +68,15 @@ Shared params: # Test fbopt with different hyperparameter configurations - +diva_fbopt_a: + aname: diva + trainer: fbopt + str_diva_multiplier_type: gammad_recon + gamma_y: 1.0 + init_setpoint_ratio: 0.99 + shared: + - k_i_gain + - mu_init diva_feedforward_a: aname: diva From f4d000c1cee6c1c434633444fc7933dbb2c20d24 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 23:22:19 +0200 Subject: [PATCH 435/762] Update and rename mnist_diva_baselines.yaml to mnist_diva_fbopt_and_baselines.yaml --- ..._diva_baselines.yaml => mnist_diva_fbopt_and_baselines.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/benchmark/{mnist_diva_baselines.yaml => mnist_diva_fbopt_and_baselines.yaml} (96%) diff --git a/examples/benchmark/mnist_diva_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml similarity index 96% rename from examples/benchmark/mnist_diva_baselines.yaml rename to examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index ec55ad9e9..20ae5a6b6 100644 --- a/examples/benchmark/mnist_diva_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/benchmark_fbopt +output_dir: zoutput/benchmarks/mnist_diva_fbopt_and_baselines sampling_seed: 0 startseed: 0 From 0c1d45dd66bd0c05bc4a4e902c3a8387fc68ef1b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 13 Oct 2023 23:36:14 +0200 Subject: [PATCH 436/762] Update pacs_diva_fbopt_and_others.yaml --- examples/benchmark/pacs_diva_fbopt_and_others.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml index 5a3140334..7e655d9f8 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_others.yaml @@ -14,8 +14,8 @@ domainlab_args: tpath: examples/tasks/task_pacs_path_list.py dmem: False lr: 5e-5 - epos: 2000 - es: 500 + epos: 200 + es: 10 bs: 64 san_check: True npath: examples/nets/resnet50domainbed.py From 625728847999bc24a10e6ce0c5083e6df95475ca Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 00:05:16 +0200 Subject: [PATCH 437/762] Update pacs_jigen_fbopt_alone.yaml --- examples/benchmark/pacs_jigen_fbopt_alone.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone.yaml b/examples/benchmark/pacs_jigen_fbopt_alone.yaml index 69bfa33c0..c12f49ff3 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 5 + es: 10 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py From dea92991d9311b2cefbe72b570ed2407eadee5e8 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 00:06:57 +0200 Subject: [PATCH 438/762] Rename fbopt_pacs_diva_alone.yaml to pacs_diva_fbopt_alone.yaml --- .../{fbopt_pacs_diva_alone.yaml => pacs_diva_fbopt_alone.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{fbopt_pacs_diva_alone.yaml => pacs_diva_fbopt_alone.yaml} (100%) diff --git a/examples/benchmark/fbopt_pacs_diva_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml similarity index 100% rename from examples/benchmark/fbopt_pacs_diva_alone.yaml rename to examples/benchmark/pacs_diva_fbopt_alone.yaml From 70ad57457c3a825dc747a3ec9fdefdeadf7fc3f5 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 00:08:14 +0200 Subject: [PATCH 439/762] Update and rename benchmark_fbopt_pacs_jigen.yaml to pacs_jigen_fbopt_and_others.yaml --- ...k_fbopt_pacs_jigen.yaml => pacs_jigen_fbopt_and_others.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename examples/benchmark/{benchmark_fbopt_pacs_jigen.yaml => pacs_jigen_fbopt_and_others.yaml} (99%) diff --git a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml b/examples/benchmark/pacs_jigen_fbopt_and_others.yaml similarity index 99% rename from examples/benchmark/benchmark_fbopt_pacs_jigen.yaml rename to examples/benchmark/pacs_jigen_fbopt_and_others.yaml index aa9d56696..83e5c092b 100644 --- a/examples/benchmark/benchmark_fbopt_pacs_jigen.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_others.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 5 + es: 10 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py From 20f9f36a1eed9e57cf0161a848cc529259b5f03c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 00:09:09 +0200 Subject: [PATCH 440/762] Delete examples/benchmark/benchmark_fbopt_pacs_full.yaml --- .../benchmark/benchmark_fbopt_pacs_full.yaml | 106 ------------------ 1 file changed, 106 deletions(-) delete mode 100644 examples/benchmark/benchmark_fbopt_pacs_full.yaml diff --git a/examples/benchmark/benchmark_fbopt_pacs_full.yaml b/examples/benchmark/benchmark_fbopt_pacs_full.yaml deleted file mode 100644 index f0484765a..000000000 --- a/examples/benchmark/benchmark_fbopt_pacs_full.yaml +++ /dev/null @@ -1,106 +0,0 @@ -mode: grid - -output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full - -sampling_seed: 0 - -startseed: 0 -endseed: 2 - -test_domains: - - sketch - -domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py - dmem: False - lr: 5e-5 - epos: 200 - bs: 64 - san_check: True - npath: examples/nets/resnet50domainbed.py - npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - exp_shoulder_clip: 10 - mu_clip: 10_000 - coeff_ma: 0.5 - zx_dim: 0 - zy_dim: 64 - zd_dim: 64 - - - - -Shared params: - ini_setpoint_ratio: - min: 0.5 - max: 0.99 - num: 3 - step: 0.05 - distribution: uniform - - k_i_gain: - min: 0.0001 - max: 0.1 - num: 3 - step: 0.0001 - distribution: uniform - - es: - distribution: categorical - datatype: int - values: - - 1 - - 5 - - gamma_y: - min: 1e4 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - gamma_d: - min: 1e4 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - -# Test fbopt with different hyperparameter configurations - -jigen_fbopt: - aname: jigen - trainer: fbopt - - shared: - - ini_setpoint_ratio - - k_i_gain - - es - - -diva_fbopt: - aname: diva - trainer: fbopt - shared: - - ini_setpoint_ratio - - k_i_gain - - es - - gamma_y - -hduva_fbopt: - aname: hduva - trainer: fbopt - shared: - - ini_setpoint_ratio - - k_i_gain - - es - - gamma_y - -dann_fbopt: - aname: dann - trainer: fbopt - shared: - - ini_setpoint_ratio - - k_i_gain - - es From 1154cad90a05fe4590740bd7a387cecc49758fab Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 00:09:36 +0200 Subject: [PATCH 441/762] Rename benchmark_fbopt_mnist_dann.yaml to mnist_dann_fbopt.yaml --- .../{benchmark_fbopt_mnist_dann.yaml => mnist_dann_fbopt.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{benchmark_fbopt_mnist_dann.yaml => mnist_dann_fbopt.yaml} (100%) diff --git a/examples/benchmark/benchmark_fbopt_mnist_dann.yaml b/examples/benchmark/mnist_dann_fbopt.yaml similarity index 100% rename from examples/benchmark/benchmark_fbopt_mnist_dann.yaml rename to examples/benchmark/mnist_dann_fbopt.yaml From d10a593f33084850dd835e249d501cfcd8ee388f Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 00:10:17 +0200 Subject: [PATCH 442/762] Rename benchmark_fbopt_dann.yaml to pacs_dann_fbopt.yaml --- .../benchmark/{benchmark_fbopt_dann.yaml => pacs_dann_fbopt.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{benchmark_fbopt_dann.yaml => pacs_dann_fbopt.yaml} (100%) diff --git a/examples/benchmark/benchmark_fbopt_dann.yaml b/examples/benchmark/pacs_dann_fbopt.yaml similarity index 100% rename from examples/benchmark/benchmark_fbopt_dann.yaml rename to examples/benchmark/pacs_dann_fbopt.yaml From 771b0c8be7ba8a57bfd1fbc5106d3fcdab702954 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 00:13:05 +0200 Subject: [PATCH 443/762] Create pacs_jigen_baslines4fbopt.yaml --- .../benchmark/pacs_jigen_baslines4fbopt.yaml | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 examples/benchmark/pacs_jigen_baslines4fbopt.yaml diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml new file mode 100644 index 000000000..d5a70cefa --- /dev/null +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -0,0 +1,75 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_jigen_fbopt_baselines + +sampling_seed: 0 + +startseed: 0 +endseed: 4 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 10 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + pperm: 0.5 + + +Shared params: + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: loguniform + + mu_init: + min: 0.000001 + max: 0.00005 + num: 3 + distribution: loguniform + + pperm: + min: 0.1 + max: 0.9 + num: 3 + distribution: uniform + + gamma_reg: + min: 0.01 + max: 10_000 + num: 10 + distribution: loguniform + +# Test fbopt with different hyperparameter configurations + + +jigen_feedforward: + aname: jigen + trainer: hyperscheduler + shared: + - gamma_reg + +jigen_fixed_penalty: + aname: jigen + trainer: basic + shared: + - gamma_reg + +erm: + aname: deepall From fff70978c97ddaa693051d0a25c33a632ae8e448 Mon Sep 17 00:00:00 2001 From: DanScarc Date: Sat, 14 Oct 2023 08:18:29 +0200 Subject: [PATCH 444/762] Fix typo on Helmholtz GPU guide --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23ed163d6..b83206f0e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ then conda create --name domainlab_py39 python=3.9 conda activate domainlab_py39 conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge -conda install torchmetric==0.10.3 +conda install torchmetrics==0.10.3 git checkout fbopt pip install -r requirements_notorch.txt conda install tensorboard From 39d2aa97bfbbe1b4131d0791a237c93c807a4b7c Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 14 Oct 2023 12:07:45 +0200 Subject: [PATCH 445/762] update diva yaml file --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml index 5ff7280b5..6d70561f6 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone.yaml @@ -47,7 +47,8 @@ Shared params: mu_init: min: 0.000001 - max: 0.00001 + max: 1 + step: 0.000001 num: 3 distribution: loguniform From ec8db316dfaf694674cd719f223d27e4d6addf23 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 12:17:51 +0200 Subject: [PATCH 446/762] disable equal validation loss case in model selection Update c_msel_val.py --- domainlab/algos/msels/c_msel_val.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_val.py b/domainlab/algos/msels/c_msel_val.py index 2dd39d801..8f7cc95b8 100644 --- a/domainlab/algos/msels/c_msel_val.py +++ b/domainlab/algos/msels/c_msel_val.py @@ -47,7 +47,7 @@ def update(self, clear_counter=False): self.tr_obs.metric_te[self.tr_obs.str_metric4msel] self._best_te_metric = max(self._best_te_metric, metric_te_current) - if metric >= self._best_val_acc: # update hat{model} + if metric > self._best_val_acc: # update hat{model} # different from loss, accuracy should be improved: # the bigger the better self._best_val_acc = metric From 65d269e02cbffe6179d00388917bc52032900b1c Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 14 Oct 2023 14:35:56 +0200 Subject: [PATCH 447/762] more pring --- .../algos/trainers/fbopt_mu_controller.py | 55 ++++++++----------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 94ad74b32..bbf8656e8 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -39,14 +39,18 @@ def __init__(self, trainer, **kwargs): self.trainer = trainer self.init_mu = trainer.aconf.mu_init self.mu_min = trainer.aconf.mu_min + self.mu_clip = trainer.aconf.mu_clip + self.mmu = kwargs + # force initial value of mu self.mmu = {key: self.init_mu for key, val in self.mmu.items()} + self.set_point_controller = FbOptSetpointController(args=self.trainer.aconf) + self.k_i_control = trainer.aconf.k_i_gain self.overshoot_rewind = trainer.aconf.overshoot_rewind == "yes" - self.delta_epsilon_r = False # False here just used to decide if value first use or not + self.delta_epsilon_r = None # NOTE: this value will be set according to initial evaluation of neural network - self.mu_clip = trainer.aconf.mu_clip self.activation_clip = trainer.aconf.exp_shoulder_clip if trainer.aconf.no_tensorboard: self.writer = StubSummaryWriter() @@ -54,37 +58,20 @@ def __init__(self, trainer, **kwargs): str_job_id = os.environ.get('SLURM_JOB_ID', '') self.writer = SummaryWriter(comment=str_job_id) self.coeff_ma = trainer.aconf.coeff_ma - self.epsilon_r = False - def get_setpoint4R(self): + def get_setpoing4r(self): """ get setpoint list """ return self.set_point_controller.setpoint4R - def set_setpoint(self, list_setpoint4R, setpoint4ell): + def set_setpoint(self, list_setpoint4r, setpoint4ell): """ set the setpoint """ - self.set_point_controller.setpoint4R = list_setpoint4R + self.set_point_controller.setpoint4R = list_setpoint4r self.set_point_controller.setpoint4ell = setpoint4ell - def update_anchor(self, dict_par): - """ - update the last ensured value of theta^{(k)} - """ - self.dict_theta = copy.deepcopy(dict_par) - - def set_theta_ref(self): - """ - # theta_ref should be equal to either theta or theta bar as reference - # since theta_ref will be used to judge if criteria is met - """ - if self.trainer.aconf.anchor_bar: - self.dict_theta_ref = copy.deepcopy(self.dict_theta_bar) - else: - self.dict_theta_ref = copy.deepcopy(self.dict_theta) - def cal_delta4control(self, list1, list_setpoint): """ list difference @@ -98,16 +85,17 @@ def cal_delta_integration(self, list_old, list_new, coeff): """ return [(1-coeff)*a + coeff*b for a, b in zip(list_old, list_new)] - def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, miter): + def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, + list_str_multiplier_na, miter): """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value to see if the criteria is met - $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-epsilon_R])$$ + $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-ref_R])$$ """ - delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.get_setpoint4R()) + delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.get_setpoing4r()) # TODO: can be replaced by a controller - if self.delta_epsilon_r is False: + if self.delta_epsilon_r is None: self.delta_epsilon_r = delta_epsilon_r else: # PI control. @@ -121,22 +109,27 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplie activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) for val in activation] # overshoot handling - list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b else None for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] + list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b else None + for i, (a, b) in + enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] for ind in list_overshoot: if ind is not None: logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info(f"overshooting at pos {ind} of {activation}") + logger.info(f"error integration: {self.delta_epsilon_r}") + logger.info(f"overshooting at pos {ind} of activation: {activation}") if self.overshoot_rewind: activation[ind] = 0.0 - logger.info(f"PID controller set to zero now {activation}") + logger.info(f"PID controller set to zero now, new activation: {activation}") list_gain = np.exp(activation) - dict_gain = {na: val for na, val in zip(list_str_multiplier_na, list_gain)} + dict_gain = dict(zip(list_str_multiplier_na, list_gain)) target = self.dict_multiply(self.mmu, dict_gain) self.mmu = self.dict_clip(target) + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"current mu: {self.mmu}") for key, val in self.mmu.items(): self.writer.add_scalar(f'mmu/{key}', val, miter) - for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoint4R())): + for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoing4r())): self.writer.add_scalar(f'regd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) self.writer.add_scalar(f'regs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) From 7aa0cf260bf89b9721f15d582d0a6bf819dab47e Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 14 Oct 2023 14:54:58 +0200 Subject: [PATCH 448/762] erm or not, fix issue 518# --- domainlab/algos/trainers/a_trainer.py | 1 + domainlab/algos/trainers/args_fbopt.py | 3 +++ domainlab/algos/trainers/train_fbopt_b.py | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 4d6f2c93f..670f5e3fa 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -58,6 +58,7 @@ def __init__(self, successor_node=None): self.flag_initialized = False # fbopt self.mu_iter_start = 0 + self.flag_setpoint_updated = False @property def str_metric4msel(self): diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 831746a38..cc60d9d68 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -42,6 +42,9 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') + parser.add_argument('--start_with_erm', action='store_true', default=False, + help='disable setpoint update') + parser.add_argument('--overshoot_rewind', type=str, default="yes", help='overshoot_rewind, for benchmark, use yes or no') diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index b6b763fb7..199316fab 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -84,8 +84,11 @@ def before_tr(self): self.set_model_with_mu() # very small value self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() self.hyper_scheduler.set_setpoint( - [ele * self.aconf.ini_setpoint_ratio if ele > 0 else ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], + [ele * self.aconf.ini_setpoint_ratio if ele > 0 else + ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) # setpoing w.r.t. random initialization of neural network + if self.aconf.start_with_erm: + self.do_erm() @property def list_str_multiplier_na(self): From 6c912463588826181069b4c244c9aa3cf9deb906 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 14 Oct 2023 15:02:23 +0200 Subject: [PATCH 449/762] ranem --- domainlab/algos/trainers/args_fbopt.py | 2 +- domainlab/algos/trainers/train_fbopt_b.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index cc60d9d68..ed46ece16 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -42,7 +42,7 @@ def add_args2parser_fbopt(parser): parser.add_argument('--no_setpoint_update', action='store_true', default=False, help='disable setpoint update') - parser.add_argument('--start_with_erm', action='store_true', default=False, + parser.add_argument('--tr_with_init_mu', action='store_true', default=False, help='disable setpoint update') parser.add_argument('--overshoot_rewind', type=str, default="yes", diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 199316fab..a4c0bc9b4 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -81,14 +81,16 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.flag_setpoint_updated = False self.set_scheduler(scheduler=HyperSchedulerFeedback) + self.set_model_with_mu() # very small value + if self.aconf.tr_with_init_mu: + self.tr_with_init_mu() + self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() self.hyper_scheduler.set_setpoint( [ele * self.aconf.ini_setpoint_ratio if ele > 0 else ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) # setpoing w.r.t. random initialization of neural network - if self.aconf.start_with_erm: - self.do_erm() @property def list_str_multiplier_na(self): @@ -97,7 +99,7 @@ def list_str_multiplier_na(self): """ return self.model.list_str_multiplier_na - def do_erm(self): + def tr_with_init_mu(self): """ erm step with very small mu """ From 1b99f9fafa8c6be914c80bbfc21c9074461c7916 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 15:14:01 +0200 Subject: [PATCH 450/762] Update pacs_diva_fbopt_and_others.yaml --- examples/benchmark/pacs_diva_fbopt_and_others.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml index 7e655d9f8..e2967cd11 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_others.yaml @@ -17,7 +17,7 @@ domainlab_args: epos: 200 es: 10 bs: 64 - san_check: True + san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py From 9fa26ab2688679d406f5015eebf06bcd0fdf204b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 15:14:36 +0200 Subject: [PATCH 451/762] Update pacs_diva_fbopt_alone.yaml --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml index 6d70561f6..9e526ef77 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone sampling_seed: 0 @@ -17,7 +17,7 @@ domainlab_args: epos: 200 es: 10 bs: 64 - san_check: True + san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py From 8f69f66787d903085fdaf564a46d6d2e09ca372c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sat, 14 Oct 2023 15:15:08 +0200 Subject: [PATCH 452/762] Update pacs_diva_others.yaml --- examples/benchmark/pacs_diva_others.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml index 7101d0384..40d2750b6 100644 --- a/examples/benchmark/pacs_diva_others.yaml +++ b/examples/benchmark/pacs_diva_others.yaml @@ -17,7 +17,7 @@ domainlab_args: epos: 200 es: 10 bs: 64 - san_check: True + san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py From 01f0004cf96750874cfe31d07c4fcd5e3270ed69 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 14 Oct 2023 17:36:30 +0200 Subject: [PATCH 453/762] mu small --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml index 6d70561f6..cbc8aa5b8 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone.yaml @@ -17,7 +17,7 @@ domainlab_args: epos: 200 es: 10 bs: 64 - san_check: True + san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py @@ -28,6 +28,7 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 + tr_with_init_mu: True @@ -47,7 +48,7 @@ Shared params: mu_init: min: 0.000001 - max: 1 + max: 0.00001 step: 0.000001 num: 3 distribution: loguniform From 410fceb8e836e682247ebcf1b644a6e342bf4094 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 14 Oct 2023 21:14:07 +0200 Subject: [PATCH 454/762] . --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml index 435c2a3df..f15707f00 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone.yaml @@ -28,7 +28,7 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 - tr_with_init_mu: True + tr_with_init_mu: False From 5c14806605166dc445c748a2e406d08618527a50 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 09:59:44 +0200 Subject: [PATCH 455/762] codacy --- domainlab/algos/trainers/fbopt_mu_controller.py | 8 +++++--- domainlab/algos/trainers/train_fbopt_b.py | 17 ++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index bbf8656e8..9e3c118b2 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -83,7 +83,7 @@ def cal_delta_integration(self, list_old, list_new, coeff): """ ma of delta """ - return [(1-coeff)*a + coeff*b for a, b in zip(list_old, list_new)] + return [(1 - coeff) * a + coeff * b for a, b in zip(list_old, list_new)] def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, miter): @@ -93,6 +93,8 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, to see if the criteria is met $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-ref_R])$$ """ + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"before controller: current mu: {self.mmu}") delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.get_setpoing4r()) # TODO: can be replaced by a controller if self.delta_epsilon_r is None: @@ -125,7 +127,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, target = self.dict_multiply(self.mmu, dict_gain) self.mmu = self.dict_clip(target) logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info(f"current mu: {self.mmu}") + logger.info(f"after contoller: current mu: {self.mmu}") for key, val in self.mmu.items(): self.writer.add_scalar(f'mmu/{key}', val, miter) @@ -171,7 +173,7 @@ def dict_multiply(self, dict_base, dict_multiplier): """ multiply a float to each element of a dictionary """ - return {key: val*dict_multiplier[key] for key, val in dict_base.items()} + return {key: val * dict_multiplier[key] for key, val in dict_base.items()} def update_setpoint(self, epo_reg_loss, epo_task_loss): """ diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index a4c0bc9b4..9bc64785e 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -5,12 +5,14 @@ import torch from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.fbopt_mu_controller import HyperSchedulerFeedback -from domainlab.utils.logger import Logger -from domainlab.algos.msels.c_msel_setpoint_delay import MSelSetpointDelay def list_divide(list_val, scalar): - return [ele/scalar for ele in list_val] + """ + divide a list by a scalar + """ + return [ele / scalar for ele in list_val] + class HyperSetter(): """ @@ -66,7 +68,7 @@ def eval_r_loss(self): epo_task_loss += b_task_loss epo_p_loss += p_loss.sum().detach().item() counter += 1.0 - return list_divide(epo_reg_loss, counter), epo_task_loss/counter, epo_p_loss / counter + return list_divide(epo_reg_loss, counter), epo_task_loss / counter, epo_p_loss / counter def before_batch(self, epoch, ind_batch): """ @@ -75,7 +77,7 @@ def before_batch(self, epoch, ind_batch): """ if self.flag_update_hyper_per_batch: # NOTE: if not update per_batch, then not updated - self.model.hyper_update(epoch*self.num_batches + ind_batch, self.hyper_scheduler) + self.model.hyper_update(epoch * self.num_batches + ind_batch, self.hyper_scheduler) return super().after_batch(epoch, ind_batch) def before_tr(self): @@ -111,7 +113,7 @@ def set_model_with_mu(self): """ self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) - def tr_epoch(self, epoch): + def tr_epoch(self, epoch, flag_info=False): """ update multipliers only per epoch """ @@ -125,5 +127,6 @@ def tr_epoch(self, epoch): flag = super().tr_epoch(epoch, self.flag_setpoint_updated) # is it good to update setpoint after we know the new value of each loss? - self.flag_setpoint_updated = self.hyper_scheduler.update_setpoint(self.epo_reg_loss_tr, self.epo_task_loss_tr) + self.flag_setpoint_updated = self.hyper_scheduler.update_setpoint( + self.epo_reg_loss_tr, self.epo_task_loss_tr) return flag From 7c87e6e6556111afe62dd5a8aa59fc85344dc0f6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 10:00:55 +0200 Subject: [PATCH 456/762] epo reg loss printer --- domainlab/algos/trainers/fbopt_mu_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 9e3c118b2..e2adf57c1 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -95,6 +95,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, """ logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"before controller: current mu: {self.mmu}") + logger.info(f"epo reg loss: {epo_reg_loss}") delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.get_setpoing4r()) # TODO: can be replaced by a controller if self.delta_epsilon_r is None: From 2a88ee3088525ba86fa6cb36ce7c2b28d6a18eb9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 10:13:00 +0200 Subject: [PATCH 457/762] reconstruction loss per pixel --- domainlab/models/model_diva.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index dc6a43dca..a09f4eb89 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -160,6 +160,14 @@ def hyper_update(self, epoch, fun_scheduler): self.gamma_d = dict_rst["gamma_d"] self.mu_recon = dict_rst["mu_recon"] + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): + [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], [mu_recon, beta_d, beta_x, beta_y, gamma_d] = super().cal_reg_loss(tensor_x, tensor_y, tensor_d, others) + + return [torch.div(loss_recon_x, tensor_x.shape[1] * tensor_x.shape[2] * tensor_x.shape[3]), zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ + [mu_recon, -beta_d, -beta_x, -beta_y, gamma_d] + + + def hyper_init(self, functor_scheduler, trainer=None): """ initiate a scheduler object via class name and things inside this model From 347e6ec22dffd202a513043714785282b4823b58 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 11:12:08 +0200 Subject: [PATCH 458/762] fbopt_refine_sign_handling --- .../algos/trainers/fbopt_mu_controller.py | 72 +++++++++++-------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index e2adf57c1..10fdb9250 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -1,7 +1,6 @@ """ update hyper-parameters during training """ -import copy import os from torch.utils.tensorboard import SummaryWriter @@ -77,7 +76,15 @@ def cal_delta4control(self, list1, list_setpoint): list difference """ if_list_sign_agree(list1, list_setpoint) - return [a - b if a >= 0 and b >= 0 else b - a for a, b in zip(list1, list_setpoint)] + delta_epsilon_r = [a - b for a, b in zip(list1, list_setpoint)] + if self.delta_epsilon_r is None: + self.delta_epsilon_r = delta_epsilon_r + else: + # PI control. + # self.delta_epsilon_r is the previous time step. + # delta_epsilon_r is the current time step + self.delta_epsilon_r = self.cal_delta_integration( + self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) def cal_delta_integration(self, list_old, list_new, coeff): """ @@ -85,34 +92,11 @@ def cal_delta_integration(self, list_old, list_new, coeff): """ return [(1 - coeff) * a + coeff * b for a, b in zip(list_old, list_new)] - def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, - list_str_multiplier_na, miter): + def tackle_overshoot(self, activation, epo_reg_loss, list_str_multiplier_na): """ - start from parameter dictionary dict_theta: {"layer":tensor}, - enlarge mu w.r.t. its current value - to see if the criteria is met - $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-ref_R])$$ + tackle overshoot """ - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info(f"before controller: current mu: {self.mmu}") - logger.info(f"epo reg loss: {epo_reg_loss}") - delta_epsilon_r = self.cal_delta4control(epo_reg_loss, self.get_setpoing4r()) - # TODO: can be replaced by a controller - if self.delta_epsilon_r is None: - self.delta_epsilon_r = delta_epsilon_r - else: - # PI control. - # self.delta_epsilon_r is the previous time step. - # delta_epsilon_r is the current time step - self.delta_epsilon_r = self.cal_delta_integration( - self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) - # FIXME: here we can not sum up delta_epsilon_r directly, but normalization also makes no sense, the only way is to let gain as a dictionary - activation = [self.k_i_control * val for val in self.delta_epsilon_r] - if self.activation_clip is not None: - activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) - for val in activation] - # overshoot handling - list_overshoot = [i if a < b and self.delta_epsilon_r[i] > b else None + list_overshoot = [i if (a - b) * (self.delta_epsilon_r[i]) < 0 else None for i, (a, b) in enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] for ind in list_overshoot: @@ -120,9 +104,41 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") logger.info(f"error integration: {self.delta_epsilon_r}") logger.info(f"overshooting at pos {ind} of activation: {activation}") + logger.info(f"name reg loss:{list_str_multiplier_na}") if self.overshoot_rewind: activation[ind] = 0.0 logger.info(f"PID controller set to zero now, new activation: {activation}") + return activation + + def cal_activation(self): + """ + calculate activation on exponential shoulder + """ + setpoint = self.get_setpoing4r() + activation = [self.k_i_control * val if setpoint[i] > 0 + else self.k_i_control * (-val) for i, val in enumerate(self.delta_epsilon_r)] + if self.activation_clip is not None: + activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) + for val in activation] + return activation + + + def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, + list_str_multiplier_na, miter): + """ + start from parameter dictionary dict_theta: {"layer":tensor}, + enlarge mu w.r.t. its current value + to see if the criteria is met + $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-ref_R])$$ + """ + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"before controller: current mu: {self.mmu}") + logger.info(f"epo reg loss: {epo_reg_loss}") + logger.info(f"name reg loss:{list_str_multiplier_na}") + self.cal_delta4control(epo_reg_loss, self.get_setpoing4r()) + activation = self.cal_activation() + # overshoot handling + activation = self.tackle_overshoot(activation, epo_reg_loss, list_str_multiplier_na) list_gain = np.exp(activation) dict_gain = dict(zip(list_str_multiplier_na, list_gain)) target = self.dict_multiply(self.mmu, dict_gain) From d7bc4e0817da5571897291d1b6cddb42a1ffdeb6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 13:32:57 +0200 Subject: [PATCH 459/762] separate class --- domainlab/models/model_diva.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index a09f4eb89..4733a7f05 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -160,13 +160,6 @@ def hyper_update(self, epoch, fun_scheduler): self.gamma_d = dict_rst["gamma_d"] self.mu_recon = dict_rst["mu_recon"] - def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): - [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], [mu_recon, beta_d, beta_x, beta_y, gamma_d] = super().cal_reg_loss(tensor_x, tensor_y, tensor_d, others) - - return [torch.div(loss_recon_x, tensor_x.shape[1] * tensor_x.shape[2] * tensor_x.shape[3]), zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ - [mu_recon, -beta_d, -beta_x, -beta_y, gamma_d] - - def hyper_init(self, functor_scheduler, trainer=None): """ @@ -183,8 +176,17 @@ def hyper_init(self, functor_scheduler, trainer=None): mu_recon=self.mu_recon ) + class ModelDIVAGammadReconPerPixel(ModelDIVAGammadRecon): + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): + [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], [mu_recon, beta_d, beta_x, beta_y, gamma_d] = super().cal_reg_loss(tensor_x, tensor_y, tensor_d, others) + + return [torch.div(loss_recon_x, tensor_x.shape[2] * tensor_x.shape[3]), zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ + [mu_recon, -beta_d, -beta_x, -beta_y, gamma_d] class ModelDIVAGammad(ModelDIVA): + """ + only adjust gammad and beta + """ def hyper_update(self, epoch, fun_scheduler): """hyper_update. @@ -213,11 +215,16 @@ def hyper_init(self, functor_scheduler, trainer=None): class ModelDIVADefault(ModelDIVA): """ + mock """ if str_diva_multiplier_type == "gammad_recon": return ModelDIVAGammadRecon + if str_diva_multiplier_type == "gammad_recon_per_pixel": + return ModelDIVAGammadReconPerPixel if str_diva_multiplier_type == "gammad": return ModelDIVAGammad if str_diva_multiplier_type == "default": return ModelDIVADefault - raise RuntimeError("not support argument candiates for str_diva_multiplier_type: allowed: default, gammad_recon, gammad") + raise RuntimeError( + "not support argument candiates for str_diva_multiplier_type: \ + allowed: default, gammad_recon, gammad_recon_per_pixel, gammad") From acbbfd9a8804512c6c3c9cd78c2211247e1f32ac Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 14:15:48 +0200 Subject: [PATCH 460/762] fix #550 --- domainlab/algos/trainers/fbopt_mu_controller.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 10fdb9250..69a7469bf 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -149,18 +149,19 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, for key, val in self.mmu.items(): self.writer.add_scalar(f'mmu/{key}', val, miter) for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoing4r())): - self.writer.add_scalar(f'regd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) - self.writer.add_scalar(f'regs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) + self.writer.add_scalar(f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) + self.writer.add_scalar(f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) self.writer.add_scalars( - f'regds/dyn_{list_str_multiplier_na[i]} with setpoint', - {f'reg/dyn_{list_str_multiplier_na[i]}': reg_dyn, - f'reg/setpoint_{list_str_multiplier_na[i]}': reg_set, + f'lossrds/dyn_{list_str_multiplier_na[i]} with setpoint', + {f'lossr/dyn_{list_str_multiplier_na[i]}': reg_dyn, + f'lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, }, miter) self.writer.add_scalar( - f'x-axis=task vs y-axis=reg/dyn{list_str_multiplier_na[i]}', reg_dyn, epo_task_loss) + f'x-axis=loss_ell task vs y-axis=loss r/dyn{list_str_multiplier_na[i]}', + reg_dyn, epo_task_loss) self.writer.add_scalar('loss_penalized', epo_loss_tr, miter) - self.writer.add_scalar('task', epo_task_loss, miter) + self.writer.add_scalar('loss_ell_task', epo_task_loss, miter) acc_te = 0 acc_val = 0 From 95e270f027f943ceadc62d93d1eecdcd4ec425ef Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 14:18:41 +0200 Subject: [PATCH 461/762] fix #550 --- domainlab/algos/trainers/fbopt_mu_controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 69a7469bf..973bed0b7 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -147,13 +147,13 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, logger.info(f"after contoller: current mu: {self.mmu}") for key, val in self.mmu.items(): - self.writer.add_scalar(f'mmu/{key}', val, miter) + self.writer.add_scalar(f'dyn_mu/{key}', val, miter) for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoing4r())): self.writer.add_scalar(f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) self.writer.add_scalar(f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) self.writer.add_scalars( - f'lossrds/dyn_{list_str_multiplier_na[i]} with setpoint', + f'loss_rds/dyn_{list_str_multiplier_na[i]} with setpoint', {f'lossr/dyn_{list_str_multiplier_na[i]}': reg_dyn, f'lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, }, miter) From 87180aa2c32086710a36b7d1243afc6c526afc50 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 14:27:51 +0200 Subject: [PATCH 462/762] "Fix --- domainlab/algos/trainers/fbopt_mu_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 973bed0b7..925a1fea2 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -148,6 +148,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, for key, val in self.mmu.items(): self.writer.add_scalar(f'dyn_mu/{key}', val, miter) + self.writer.add_scalar(f'dyn_gain/{key}', dict_gain[key], miter) for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoing4r())): self.writer.add_scalar(f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) self.writer.add_scalar(f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) From 811ddae58f058b1517efc98876ef7874b89c914d Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 14:49:01 +0200 Subject: [PATCH 463/762] tensorboard --- domainlab/algos/trainers/fbopt_mu_controller.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 925a1fea2..81948cdb5 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -148,15 +148,15 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, for key, val in self.mmu.items(): self.writer.add_scalar(f'dyn_mu/{key}', val, miter) - self.writer.add_scalar(f'dyn_gain/{key}', dict_gain[key], miter) + self.writer.add_scalar(f'controller_gain/{key}', dict_gain[key], miter) for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoing4r())): self.writer.add_scalar(f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) self.writer.add_scalar(f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) self.writer.add_scalars( - f'loss_rds/dyn_{list_str_multiplier_na[i]} with setpoint', - {f'lossr/dyn_{list_str_multiplier_na[i]}': reg_dyn, - f'lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, + f'dyn_loss_rds/dyn_{list_str_multiplier_na[i]} with setpoint', + {f'dyn_lossr/dyn_{list_str_multiplier_na[i]}': reg_dyn, + f'dyn_lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, }, miter) self.writer.add_scalar( f'x-axis=loss_ell task vs y-axis=loss r/dyn{list_str_multiplier_na[i]}', From dcbf7500b40bfcf5a9d9ebbccfc1635369594c5a Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 14:50:59 +0200 Subject: [PATCH 464/762] all compo2 setpoint descent --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index b91a66f9a..19171cfe9 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -126,7 +126,7 @@ def __init__(self, state=None, args=None): if args is not None and args.no_setpoint_update: state = FixedSetpoint() else: - state = DominateAnyComponent() + state = DominateAllComponent() self.transition_to(state) self.flag_setpoint_rewind = args.setpoint_rewind == "yes" self.setpoint_rewinder = SetpointRewinder(self) From 4fa1e969f479cee8c60e80daf9f73ab074db1ddf Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 16:28:37 +0200 Subject: [PATCH 465/762] better tensorboard --- domainlab/algos/trainers/fbopt_mu_controller.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 81948cdb5..24102b1d0 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -154,15 +154,15 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, self.writer.add_scalar(f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) self.writer.add_scalars( - f'dyn_loss_rds/dyn_{list_str_multiplier_na[i]} with setpoint', - {f'dyn_lossr/dyn_{list_str_multiplier_na[i]}': reg_dyn, - f'dyn_lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, + f'loss_rds/loss_{list_str_multiplier_na[i]} with setpoint', + {f'lossr/loss_{list_str_multiplier_na[i]}': reg_dyn, + f'lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, }, miter) self.writer.add_scalar( f'x-axis=loss_ell task vs y-axis=loss r/dyn{list_str_multiplier_na[i]}', reg_dyn, epo_task_loss) self.writer.add_scalar('loss_penalized', epo_loss_tr, miter) - self.writer.add_scalar('loss_ell_task', epo_task_loss, miter) + self.writer.add_scalar('loss_task_ell', epo_task_loss, miter) acc_te = 0 acc_val = 0 From 880d6a3790f3dd99909cf71ae818020e32d1a9e2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 16:41:23 +0200 Subject: [PATCH 466/762] fix issue 535 --- domainlab/algos/trainers/fbopt_mu_controller.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 24102b1d0..6cfee0abf 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -149,6 +149,8 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, for key, val in self.mmu.items(): self.writer.add_scalar(f'dyn_mu/{key}', val, miter) self.writer.add_scalar(f'controller_gain/{key}', dict_gain[key], miter) + ind = list_str_multiplier_na.index(key) + self.writer.add_scalar(f'delta/{key}', self.delta_epsilon_r[ind], miter) for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoing4r())): self.writer.add_scalar(f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) self.writer.add_scalar(f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) @@ -161,8 +163,8 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, self.writer.add_scalar( f'x-axis=loss_ell task vs y-axis=loss r/dyn{list_str_multiplier_na[i]}', reg_dyn, epo_task_loss) - self.writer.add_scalar('loss_penalized', epo_loss_tr, miter) - self.writer.add_scalar('loss_task_ell', epo_task_loss, miter) + self.writer.add_scalar('loss_task/penalized', epo_loss_tr, miter) + self.writer.add_scalar('loss_task/ell', epo_task_loss, miter) acc_te = 0 acc_val = 0 From 162fd624ebe79f91b99746822343f247df9fd377 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 17:04:04 +0200 Subject: [PATCH 467/762] new command for diva mnist --- fbopt_mnist_diva_pixel.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 fbopt_mnist_diva_pixel.sh diff --git a/fbopt_mnist_diva_pixel.sh b/fbopt_mnist_diva_pixel.sh new file mode 100644 index 000000000..f297d045d --- /dev/null +++ b/fbopt_mnist_diva_pixel.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py + +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=500 --mu_init=0.00001 --gamma_y=1.0 --mu_clip=10 --str_diva_multiplier_type=gammad_recon_per_pixel From 8454568dd48807056b0709fff074c788345fba36 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 17:26:11 +0200 Subject: [PATCH 468/762] fix bug of sign in pixel recon --- domainlab/models/model_diva.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 4733a7f05..dfb8acdb6 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -178,10 +178,13 @@ def hyper_init(self, functor_scheduler, trainer=None): class ModelDIVAGammadReconPerPixel(ModelDIVAGammadRecon): def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): - [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], [mu_recon, beta_d, beta_x, beta_y, gamma_d] = super().cal_reg_loss(tensor_x, tensor_y, tensor_d, others) + [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], [mu_recon, minus_beta_d, minus_beta_x, minus_beta_y, gamma_d] = super().cal_reg_loss(tensor_x, tensor_y, tensor_d, others) - return [torch.div(loss_recon_x, tensor_x.shape[2] * tensor_x.shape[3]), zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ - [mu_recon, -beta_d, -beta_x, -beta_y, gamma_d] + return [torch.div(loss_recon_x, + tensor_x.shape[2] * tensor_x.shape[3]), + zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ + [mu_recon, minus_beta_d, minus_beta_x, + minus_beta_y, gamma_d] class ModelDIVAGammad(ModelDIVA): """ From dc18eb57eccb48071a17843ce5f05439dc4d814e Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 18:00:20 +0200 Subject: [PATCH 469/762] allow equal --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 19171cfe9..d44bc2fd6 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -45,12 +45,14 @@ def is_less_list_any(list1, list2): return any(list_comparison), list_true(list_comparison) -def is_less_list_all(list1, list2): +def is_less_list_all(list1, list2, flag_eq=False): """ judge if one list is less than the other """ if_list_sign_agree(list1, list2) list_comparison = [a < b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2)] + if flag_eq: + list_comparison = [a <= b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2)] return all(list_comparison) @@ -212,7 +214,7 @@ def update_setpoint(self): """ all components of R descreases regardless if ell decreases or not """ - if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R): + if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True): return True, list(range(len(self.host.setpoint4R))) return False, None From 2bc33fe61270e530da74dfd67107c6b8e55279c2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 18:01:38 +0200 Subject: [PATCH 470/762] . --- fbopt_mnist_diva_pixel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbopt_mnist_diva_pixel.sh b/fbopt_mnist_diva_pixel.sh index f297d045d..234cc8457 100644 --- a/fbopt_mnist_diva_pixel.sh +++ b/fbopt_mnist_diva_pixel.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=500 --mu_init=0.00001 --gamma_y=1.0 --mu_clip=10 --str_diva_multiplier_type=gammad_recon_per_pixel +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=2000 --mu_init=0.00001 --gamma_y=1.0 --mu_clip=10 --str_diva_multiplier_type=gammad_recon_per_pixel From ab0c11ddc9bf086208e1bf387f67ed987f695830 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 15 Oct 2023 18:23:37 +0200 Subject: [PATCH 471/762] diva yaml --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml index f15707f00..06921795c 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone.yaml @@ -15,22 +15,16 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 10 + es: 50 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - exp_shoulder_clip: 10 - mu_clip: 1000_000 - coeff_ma: 0.5 zx_dim: 0 zy_dim: 64 zd_dim: 64 - tr_with_init_mu: False - - Shared params: @@ -40,6 +34,21 @@ Shared params: num: 3 distribution: uniform + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + mu_clip: + distribution: categorical + datatype: int + values: + - 10 + - 1000 + - 1000_000 + k_i_gain: min: 0.0001 max: 0.01 @@ -74,9 +83,12 @@ Shared params: diva_fbopt_full: aname: diva trainer: fbopt - str_diva_multiplier_type: gammad_recon + exp_shoulder_clip: 10 + tr_with_init_mu: False + coeff_ma: 0.5 gamma_y: 1.0 ini_setpoint_ratio: 0.99 shared: - k_i_gain - mu_init + - str_diva_multiplier_type \ No newline at end of file From e669afb595712a5e560f6707c2bb75c0e0ae083f Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 15 Oct 2023 18:26:10 +0200 Subject: [PATCH 472/762] diva yaml again --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml index 06921795c..445c556f5 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone.yaml @@ -29,9 +29,9 @@ domainlab_args: Shared params: ini_setpoint_ratio: - min: 0.9 - max: 0.99 - num: 3 + min: 0.990 + max: 0.999 + num: 2 distribution: uniform str_diva_multiplier_type: @@ -91,4 +91,5 @@ diva_fbopt_full: shared: - k_i_gain - mu_init - - str_diva_multiplier_type \ No newline at end of file + - str_diva_multiplier_type + - mu_clip \ No newline at end of file From fb8413d5b1c5b40e820d42a226a47c33dd02d8e4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 18:38:03 +0200 Subject: [PATCH 473/762] fix bug typo --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index d44bc2fd6..0e0545326 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -52,7 +52,7 @@ def is_less_list_all(list1, list2, flag_eq=False): if_list_sign_agree(list1, list2) list_comparison = [a < b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2)] if flag_eq: - list_comparison = [a <= b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2)] + list_comparison = [a <= b if a >= 0 and b >= 0 else a >= b for a, b in zip(list1, list2)] return all(list_comparison) From 5aab629bd8c1cca26cb72b45fd12518ddc06c336 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 15 Oct 2023 19:13:56 +0200 Subject: [PATCH 474/762] Create test_fbopt_setpoint_ada.py --- tests/test_fbopt_setpoint_ada.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/test_fbopt_setpoint_ada.py diff --git a/tests/test_fbopt_setpoint_ada.py b/tests/test_fbopt_setpoint_ada.py new file mode 100644 index 000000000..2895f6744 --- /dev/null +++ b/tests/test_fbopt_setpoint_ada.py @@ -0,0 +1,7 @@ +from domainlab.algos.trainers.fbopt_setpoing_ada import is_less_list_all +def test_less_than(): + a = [3, 4, -9, -8] + b = [1, 0.5, -1, -0.5] + c = [0.5, 0.25, -0.5, -0.25] + assert not is_less_list_all(a, b) + assert is_less_list_all(c, b) From e29c073c3cf20611bf8be707dee1757eb810673a Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 19:31:48 +0200 Subject: [PATCH 475/762] log --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 0e0545326..29855eb5f 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -214,7 +214,9 @@ def update_setpoint(self): """ all components of R descreases regardless if ell decreases or not """ + print(f"comparing: {self.host.state_epo_reg_loss}, {self.host.setpoint4R}") if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True): + print("!!!!!!!!! better than setpoint!") return True, list(range(len(self.host.setpoint4R))) return False, None From e410f7e6a8936cb29d278076a7a08d571112a0da Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 19:42:24 +0200 Subject: [PATCH 476/762] fix bug in setpoint ada --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 29855eb5f..4ec9cc3bc 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -231,6 +231,7 @@ def update_setpoint(self): """ flag, list_pos = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) if flag: + # FIXME self.host.transition_to(SliderAllComponent()) return True, list_pos return False, list_pos @@ -251,7 +252,7 @@ def update_setpoint(self): return flag1 & flag2, list_pos -class DominateAllComponent(FbOptSetpointControllerState): +class DominateAllComponent(SliderAllComponent): """ concrete state pattern """ @@ -259,7 +260,7 @@ def update_setpoint(self): """ if each component of R loss has decreased and ell loss also decreased """ - flag1 = is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R) + flag1, list_pos = super().update_setpoint() flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: self.host.setpoint4ell = self.host.state_task_loss From 09c610fa77a813aa57d71eb6852b75052981d4bf Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 19:55:52 +0200 Subject: [PATCH 477/762] . --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 4ec9cc3bc..0fe17c38d 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -214,7 +214,7 @@ def update_setpoint(self): """ all components of R descreases regardless if ell decreases or not """ - print(f"comparing: {self.host.state_epo_reg_loss}, {self.host.setpoint4R}") + print(f"comparing: \n {self.host.state_epo_reg_loss} \n {self.host.setpoint4R}") if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True): print("!!!!!!!!! better than setpoint!") return True, list(range(len(self.host.setpoint4R))) @@ -263,5 +263,6 @@ def update_setpoint(self): flag1, list_pos = super().update_setpoint() flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: + print("best ell loss: from {self.host.setpoint4ell} to {self.host.state_task_loss}") self.host.setpoint4ell = self.host.state_task_loss - return flag1 & flag2, list(range(len(self.host.setpoint4R))) + return flag1 & flag2, list_pos From c106dd9169fa572d93915ac63538888130514e34 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 19:57:14 +0200 Subject: [PATCH 478/762] . --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 0fe17c38d..0670edc1c 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -263,6 +263,6 @@ def update_setpoint(self): flag1, list_pos = super().update_setpoint() flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: - print("best ell loss: from {self.host.setpoint4ell} to {self.host.state_task_loss}") + print(f"best ell loss: from {self.host.setpoint4ell} to {self.host.state_task_loss}") self.host.setpoint4ell = self.host.state_task_loss return flag1 & flag2, list_pos From 6f915da3f917c0c057e7f0a759dd51eeaac30010 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 20:04:46 +0200 Subject: [PATCH 479/762] refine --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 0670edc1c..ec3542981 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -230,14 +230,13 @@ def update_setpoint(self): if any component of R has decreased regardless if ell decreases """ flag, list_pos = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) - if flag: - # FIXME - self.host.transition_to(SliderAllComponent()) - return True, list_pos - return False, list_pos + return flag, list_pos + def transit(self): + self.host.transition_to(SliderAllComponent()) -class DominateAnyComponent(FbOptSetpointControllerState): + +class DominateAnyComponent(SliderAnyComponent): """ concrete state pattern """ @@ -245,7 +244,7 @@ def update_setpoint(self): """ if any of the component of R loss has decreased together with ell loss """ - flag1, list_pos = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) + flag1, list_pos = super.update_setpoint() flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: self.host.setpoint4ell = self.host.state_task_loss From eaf67dfe7e6745a85eff69b61dcce11d4fff869b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 15 Oct 2023 20:16:56 +0200 Subject: [PATCH 480/762] Update test_fbopt_setpoint_ada.py --- tests/test_fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fbopt_setpoint_ada.py b/tests/test_fbopt_setpoint_ada.py index 2895f6744..3eeca4d0a 100644 --- a/tests/test_fbopt_setpoint_ada.py +++ b/tests/test_fbopt_setpoint_ada.py @@ -1,4 +1,4 @@ -from domainlab.algos.trainers.fbopt_setpoing_ada import is_less_list_all +from domainlab.algos.trainers.fbopt_setpoint_ada import is_less_list_all def test_less_than(): a = [3, 4, -9, -8] b = [1, 0.5, -1, -0.5] From 5a223ae1380a9147c19bbe717da3d2430a069faa Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 20:21:22 +0200 Subject: [PATCH 481/762] fix codacy --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index ec3542981..af760b465 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -244,7 +244,7 @@ def update_setpoint(self): """ if any of the component of R loss has decreased together with ell loss """ - flag1, list_pos = super.update_setpoint() + flag1, list_pos = super().update_setpoint() flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: self.host.setpoint4ell = self.host.state_task_loss From 3ba2d343bbfe596b6c5b07467f3c1f9b33ba9055 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 20:45:36 +0200 Subject: [PATCH 482/762] logger --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index af760b465..0c4475005 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -214,9 +214,10 @@ def update_setpoint(self): """ all components of R descreases regardless if ell decreases or not """ - print(f"comparing: \n {self.host.state_epo_reg_loss} \n {self.host.setpoint4R}") + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"comparing: \n {self.host.state_epo_reg_loss} \n {self.host.setpoint4R}") if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True): - print("!!!!!!!!! better than setpoint!") + logger.info("!!!!!!!!! better than old setpoint!") return True, list(range(len(self.host.setpoint4R))) return False, None @@ -262,6 +263,7 @@ def update_setpoint(self): flag1, list_pos = super().update_setpoint() flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: - print(f"best ell loss: from {self.host.setpoint4ell} to {self.host.state_task_loss}") + logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger.info(f"best ell loss: from {self.host.setpoint4ell} to {self.host.state_task_loss}") self.host.setpoint4ell = self.host.state_task_loss return flag1 & flag2, list_pos From 168981a9097f364fa66759a7003cc83b6878c7e6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 21:02:26 +0200 Subject: [PATCH 483/762] ignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 46e2d0466..edfe19c37 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ tests/__pycache__/ *.pyc .vscode/ -.snakemake/ data/pacs From 29c5d22f0ad6d32c48752c9284e94b1c252cc0d8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 21:09:29 +0200 Subject: [PATCH 484/762] script to test pacs --- run_pacs_diva_fbopt.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 run_pacs_diva_fbopt.sh diff --git a/run_pacs_diva_fbopt.sh b/run_pacs_diva_fbopt.sh new file mode 100644 index 000000000..77e8feb4a --- /dev/null +++ b/run_pacs_diva_fbopt.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py +python main_out.py --te_d=sketch --bs=64 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath_dom=examples/nets/resnet50domainbed.py From 531caaf6ae53024b20b94a62c1a84c7e7b5b4f02 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 21:14:40 +0200 Subject: [PATCH 485/762] add gamma_y --- run_pacs_diva_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_pacs_diva_fbopt.sh b/run_pacs_diva_fbopt.sh index 77e8feb4a..8190a8b5d 100644 --- a/run_pacs_diva_fbopt.sh +++ b/run_pacs_diva_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --bs=64 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath_dom=examples/nets/resnet50domainbed.py +python main_out.py --te_d=sketch --bs=64 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath_dom=examples/nets/resnet50domainbed.py --gamma_y=1.0 From 29040b4512395e97c75ac5a11538b1e824a9e6af Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 15 Oct 2023 21:17:29 +0200 Subject: [PATCH 486/762] Update pacs_diva_fbopt_alone.yaml --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml index 445c556f5..39a20c8f8 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone.yaml @@ -78,7 +78,7 @@ Shared params: -# Test fbopt with different hyperparameter configurations +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small diva_fbopt_full: aname: diva @@ -88,8 +88,8 @@ diva_fbopt_full: coeff_ma: 0.5 gamma_y: 1.0 ini_setpoint_ratio: 0.99 + mu_clip: 1000_000 shared: - k_i_gain - mu_init - str_diva_multiplier_type - - mu_clip \ No newline at end of file From 62d9411fe97db8a64feb32a13108ffbe9df82cc5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 21:19:26 +0200 Subject: [PATCH 487/762] fix typo --- run_pacs_diva_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_pacs_diva_fbopt.sh b/run_pacs_diva_fbopt.sh index 8190a8b5d..1c4d3ffba 100644 --- a/run_pacs_diva_fbopt.sh +++ b/run_pacs_diva_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --bs=64 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath_dom=examples/nets/resnet50domainbed.py --gamma_y=1.0 +python main_out.py --te_d=sketch --bs=64 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath=examples/nets/resnet50domainbed.py --gamma_y=1.0 From 7cf5a9855b53061fc3299c65db4d3d18c1b85bad Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 15 Oct 2023 21:38:34 +0200 Subject: [PATCH 488/762] Update pacs_diva_others.yaml --- examples/benchmark/pacs_diva_others.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml index 40d2750b6..867d6f12c 100644 --- a/examples/benchmark/pacs_diva_others.yaml +++ b/examples/benchmark/pacs_diva_others.yaml @@ -22,9 +22,6 @@ domainlab_args: npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - exp_shoulder_clip: 10 - mu_clip: 1000_000 - coeff_ma: 0.5 zx_dim: 0 zy_dim: 64 zd_dim: 64 From e58d9570d6523cf643e466c72625c2675c8aa824 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 15 Oct 2023 21:40:33 +0200 Subject: [PATCH 489/762] Update pacs_diva_fbopt_alone.yaml --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml index 39a20c8f8..00e05abaa 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 50 + es: 10 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py From 63486f15a7151c9ad85a9f7730e885f76b680edc Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 22:15:27 +0200 Subject: [PATCH 490/762] early stop --- .../benchmark/pacs_diva_fbopt_alone_es5.yaml | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es5.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml new file mode 100644 index 000000000..e635332b4 --- /dev/null +++ b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml @@ -0,0 +1,95 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 5 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + mu_clip: + distribution: categorical + datatype: int + values: + - 10 + - 1000 + - 1000_000 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + aname: diva + trainer: fbopt + exp_shoulder_clip: 10 + tr_with_init_mu: False + coeff_ma: 0.5 + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + mu_clip: 1000_000 + shared: + - k_i_gain + - mu_init + - str_diva_multiplier_type From af356d57929575b9cf6e2a902090c621c6d5ec55 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 22:21:22 +0200 Subject: [PATCH 491/762] es1 --- .../benchmark/pacs_diva_fbopt_alone_es1.yaml | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es1.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml new file mode 100644 index 000000000..52fe9da9b --- /dev/null +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -0,0 +1,95 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 1 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + mu_clip: + distribution: categorical + datatype: int + values: + - 10 + - 1000 + - 1000_000 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + aname: diva + trainer: fbopt + exp_shoulder_clip: 10 + tr_with_init_mu: False + coeff_ma: 0.5 + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + mu_clip: 1000_000 + shared: + - k_i_gain + - mu_init + - str_diva_multiplier_type From 9b47639186a2add3f281eaed9b5f1071f580d7c1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 15 Oct 2023 22:43:02 +0200 Subject: [PATCH 492/762] . --- ...va_fbopt_alone_es1.yaml => pacs_diva_fbopt_alone_es3.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename examples/benchmark/{pacs_diva_fbopt_alone_es1.yaml => pacs_diva_fbopt_alone_es3.yaml} (96%) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es3.yaml similarity index 96% rename from examples/benchmark/pacs_diva_fbopt_alone_es1.yaml rename to examples/benchmark/pacs_diva_fbopt_alone_es3.yaml index 52fe9da9b..63b33b8d5 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es3.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 1 + es: 3 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py @@ -89,7 +89,7 @@ diva_fbopt_full: gamma_y: 1.0 ini_setpoint_ratio: 0.99 mu_clip: 1000_000 + str_diva_multiplier_type: gammad_recon_per_pixel shared: - k_i_gain - mu_init - - str_diva_multiplier_type From 741273b3e85f2c0b4c4bd095bd1770b77ea369c5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 00:03:11 +0200 Subject: [PATCH 493/762] . --- run_fbopt_mnist_diva.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist_diva.sh b/run_fbopt_mnist_diva.sh index 5162770b7..86ff63287 100644 --- a/run_fbopt_mnist_diva.sh +++ b/run_fbopt_mnist_diva.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=500 --mu_init=0.00001 --gamma_y=1.0 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=500 --mu_init=0.000001 --gamma_y=1.0 From a9b8479ca01fb7e5f55072d406557366b1614152 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 08:35:06 +0200 Subject: [PATCH 494/762] diva script --- run_pacs_diva_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_pacs_diva_fbopt.sh b/run_pacs_diva_fbopt.sh index 1c4d3ffba..4b835c2d6 100644 --- a/run_pacs_diva_fbopt.sh +++ b/run_pacs_diva_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --bs=64 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath=examples/nets/resnet50domainbed.py --gamma_y=1.0 +python main_out.py --te_d=sketch --bs=64 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath=examples/nets/resnet50domainbed.py --gamma_y=1.0 --mu_init=1e-6 --lr=5e-5 --zx_dim=0 From 4106a2031cb558a914b40e5504fd61a87cb26db5 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 09:32:14 +0200 Subject: [PATCH 495/762] Delete examples/benchmark/pacs_diva_fbopt_alone_es3.yaml too early, not converging yet --- .../benchmark/pacs_diva_fbopt_alone_es3.yaml | 95 ------------------- 1 file changed, 95 deletions(-) delete mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es3.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es3.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es3.yaml deleted file mode 100644 index 63b33b8d5..000000000 --- a/examples/benchmark/pacs_diva_fbopt_alone_es3.yaml +++ /dev/null @@ -1,95 +0,0 @@ -mode: grid - -output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone - -sampling_seed: 0 - -startseed: 0 -endseed: 2 - -test_domains: - - sketch - -domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py - dmem: False - lr: 5e-5 - epos: 200 - es: 3 - bs: 64 - san_check: False - npath: examples/nets/resnet50domainbed.py - npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - zx_dim: 0 - zy_dim: 64 - zd_dim: 64 - - -Shared params: - ini_setpoint_ratio: - min: 0.990 - max: 0.999 - num: 2 - distribution: uniform - - str_diva_multiplier_type: - distribution: categorical - datatype: str - values: - - gammad_recon - - gammad_recon_per_pixel - - mu_clip: - distribution: categorical - datatype: int - values: - - 10 - - 1000 - - 1000_000 - - k_i_gain: - min: 0.0001 - max: 0.01 - num: 3 - distribution: uniform - - mu_init: - min: 0.000001 - max: 0.00001 - step: 0.000001 - num: 3 - distribution: loguniform - - gamma_y: - min: 1.0 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - gamma_d: - min: 1.0 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - - -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small - -diva_fbopt_full: - aname: diva - trainer: fbopt - exp_shoulder_clip: 10 - tr_with_init_mu: False - coeff_ma: 0.5 - gamma_y: 1.0 - ini_setpoint_ratio: 0.99 - mu_clip: 1000_000 - str_diva_multiplier_type: gammad_recon_per_pixel - shared: - - k_i_gain - - mu_init From 99448334fb38bfbe46b2c899004b2f593f7957f1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 11:25:36 +0200 Subject: [PATCH 496/762] fix issue #557, plot selected acc --- domainlab/algos/trainers/fbopt_mu_controller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 6cfee0abf..4e55bea3f 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -167,12 +167,15 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, self.writer.add_scalar('loss_task/ell', epo_task_loss, miter) acc_te = 0 acc_val = 0 + acc_sel = 0 if miter > 1: acc_te = self.trainer.observer.metric_te["acc"] acc_val = self.trainer.observer.metric_val["acc"] + acc_sel = self.trainer.observer.model_sel.sel_model_te_acc self.writer.add_scalar("acc/te", acc_te, miter) self.writer.add_scalar("acc/val", acc_val, miter) + self.writer.add_scalar("acc/sel", acc_sel, miter) def dict_clip(self, dict_base): """ From 709e2f6baadc54bd9861416af14109ab680ff49f Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 12:28:32 +0200 Subject: [PATCH 497/762] top k --- domainlab/algos/msels/c_msel_val_top_k.py | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 domainlab/algos/msels/c_msel_val_top_k.py diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py new file mode 100644 index 000000000..b5a57ad1e --- /dev/null +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -0,0 +1,34 @@ +""" +Model Selection should be decoupled from +""" +from domainlab.algos.msels.c_msel_val import MSelValPerf +from domainlab.utils.logger import Logger + + +class MSelValPerfTopK(MSelValPerf): + """ + 1. Model selection using validation performance + 2. Visitor pattern to trainer + """ + def __init__(self, max_es, top_k=2): + super().__init__(max_es) # construct self.tr_obs (observer) + self.top_k = top_k + self.list_top_k_acc = [0.0 for _ in range(top_k)] + + def update(self, clear_counter=False): + """ + if the best model should be updated + """ + flag_super = super().update(clear_counter) + metric_val_current = \ + self.tr_obs.metric_val[self.tr_obs.str_metric4msel] + acc_min = min(self.list_top_k_acc) + if metric_val_current > acc_min: + ind = self.list_top_k_acc.index(acc_min) + self.list_top_k_acc[ind] = metric_val_current + # overwrite + metric_te_current = \ + self.tr_obs.metric_te[self.tr_obs.str_metric4msel] + self._sel_model_te_acc = metric_te_current + return True + return flag_super From ce4023ba160716a709818f2c112c5f95756b2842 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 12:44:38 +0200 Subject: [PATCH 498/762] . --- domainlab/algos/msels/c_msel_val_top_k.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index b5a57ad1e..9ee453b28 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -24,11 +24,17 @@ def update(self, clear_counter=False): self.tr_obs.metric_val[self.tr_obs.str_metric4msel] acc_min = min(self.list_top_k_acc) if metric_val_current > acc_min: + # overwrite + self.es_c = 0 # restore counter ind = self.list_top_k_acc.index(acc_min) self.list_top_k_acc[ind] = metric_val_current # overwrite metric_te_current = \ self.tr_obs.metric_te[self.tr_obs.str_metric4msel] self._sel_model_te_acc = metric_te_current + logger = Logger.get_logger() + logger.info(f"top k validation acc updated: \ + {self.list_top_k_acc}, \ + overwriting counter, selected test acc") return True return flag_super From 6899069d546186e9baa6ffbf213ebe2dda076f68 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 13:05:32 +0200 Subject: [PATCH 499/762] topk val --- domainlab/algos/builder_diva.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/builder_diva.py b/domainlab/algos/builder_diva.py index 8ad1e6321..a338be111 100644 --- a/domainlab/algos/builder_diva.py +++ b/domainlab/algos/builder_diva.py @@ -3,6 +3,7 @@ """ from domainlab.algos.a_algo_builder import NodeAlgoBuilder from domainlab.algos.msels.c_msel_val import MSelValPerf +from domainlab.algos.msels.c_msel_val_top_k import MSelValPerfTopK from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor from domainlab.algos.msels.c_msel_setpoint_delay import MSelSetpointDelay from domainlab.algos.observers.b_obvisitor import ObVisitor @@ -48,7 +49,7 @@ def init_business(self, exp): beta_y=args.beta_y, beta_d=args.beta_d) device = get_device(args) - model_sel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerf(max_es=args.es))) + model_sel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerfTopK(max_es=args.es))) if not args.gen: observer = ObVisitorCleanUp( ObVisitor(model_sel, From ec0415c68492f5fcac0f6adfb593420f23fd469a Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 13:09:20 +0200 Subject: [PATCH 500/762] jigen topk --- domainlab/algos/builder_jigen1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/builder_jigen1.py b/domainlab/algos/builder_jigen1.py index 3c3b8c4f3..331adceb7 100644 --- a/domainlab/algos/builder_jigen1.py +++ b/domainlab/algos/builder_jigen1.py @@ -3,6 +3,7 @@ """ from domainlab.algos.a_algo_builder import NodeAlgoBuilder from domainlab.algos.msels.c_msel_val import MSelValPerf +from domainlab.algos.msels.c_msel_val_top_k import MSelValPerfTopK from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor from domainlab.algos.msels.c_msel_setpoint_delay import MSelSetpointDelay from domainlab.algos.observers.b_obvisitor import ObVisitor @@ -40,7 +41,7 @@ def init_business(self, exp): task = exp.task args = exp.args device = get_device(args) - msel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerf(max_es=args.es))) + msel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerfTopK(max_es=args.es))) observer = ObVisitor(msel, device, exp=exp) observer = ObVisitorCleanUp(observer) From b2576f8ee5796f91c7ac51be5229bcc8ba0a3f4d Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 13:35:23 +0200 Subject: [PATCH 501/762] fbopt_top_k --- domainlab/algos/msels/c_msel_val_top_k.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index 9ee453b28..4c11e5dce 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -25,16 +25,21 @@ def update(self, clear_counter=False): acc_min = min(self.list_top_k_acc) if metric_val_current > acc_min: # overwrite + logger = Logger.get_logger() + logger.info(f"top k validation acc: {self.list_top_k_acc} \ + overwriting counter, selected test acc") self.es_c = 0 # restore counter ind = self.list_top_k_acc.index(acc_min) - self.list_top_k_acc[ind] = metric_val_current + # avoid having identical values + if metric_val_current not in self.list_top_k_acc: + self.list_top_k_acc[ind] = metric_val_current + logger.info(f"top k validation acc updated: \ + {self.list_top_k_acc}") + # overwrite to ensure consistency + self._best_val_acc = metric_val_current # overwrite metric_te_current = \ self.tr_obs.metric_te[self.tr_obs.str_metric4msel] self._sel_model_te_acc = metric_te_current - logger = Logger.get_logger() - logger.info(f"top k validation acc updated: \ - {self.list_top_k_acc}, \ - overwriting counter, selected test acc") return True return flag_super From cbdc28a2eee6c74492d2673a92a21d533b7ccbc3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 13:42:28 +0200 Subject: [PATCH 502/762] codacy --- .../algos/trainers/fbopt_setpoint_ada.py | 67 ++++++++++++------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 0c4475005..01b9928e8 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -31,7 +31,7 @@ def if_list_sign_agree(list1, list2): """ each pair must have the same sign """ - list_agree = [a*b >= 0 for a, b in zip(list1, list2)] + list_agree = [a * b >= 0 for a, b in zip(list1, list2)] if not all(list_agree): raise RuntimeError(f"{list1} and {list2} can not be compared!") @@ -41,7 +41,8 @@ def is_less_list_any(list1, list2): judge if one list is less than the other """ if_list_sign_agree(list1, list2) - list_comparison = [a < b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2)] + list_comparison = [a < b if a >= 0 and b >= 0 else a > b + for a, b in zip(list1, list2)] return any(list_comparison), list_true(list_comparison) @@ -50,9 +51,11 @@ def is_less_list_all(list1, list2, flag_eq=False): judge if one list is less than the other """ if_list_sign_agree(list1, list2) - list_comparison = [a < b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2)] + list_comparison = [a < b if a >= 0 and b >= 0 else a > b + for a, b in zip(list1, list2)] if flag_eq: - list_comparison = [a <= b if a >= 0 and b >= 0 else a >= b for a, b in zip(list1, list2)] + list_comparison = [a <= b if a >= 0 and b >= 0 else a >= b + for a, b in zip(list1, list2)] return all(list_comparison) @@ -60,12 +63,14 @@ def list_ma(list_state, list_input, coeff): """ moving average of list """ - return [a * coeff + b * (1-coeff) for a, b in zip(list_state, list_input)] + return [a * coeff + b * (1 - coeff) for a, b in \ + zip(list_state, list_input)] class SetpointRewinder(): """ - rewind setpoint if current loss exponential moving average is bigger than setpoint + rewind setpoint if current loss exponential moving average is + bigger than setpoint """ def __init__(self, host): self.host = host @@ -90,8 +95,10 @@ def observe(self, epo_reg_loss): if self.ref is None: self.reset(epo_reg_loss) self.epo_ma = list_ma(self.epo_ma, epo_reg_loss, self.coeff_ma) - list_comparison_increase = [a < b for a, b in zip(self.ref, self.epo_ma)] - list_comparison_above_setpoint = [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] + list_comparison_increase = \ + [a < b for a, b in zip(self.ref, self.epo_ma)] + list_comparison_above_setpoint = \ + [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] flag_increase = any(list_comparison_increase) flag_above_setpoint = any(list_comparison_above_setpoint) if flag_increase and flag_above_setpoint: @@ -102,12 +109,14 @@ def observe(self, epo_reg_loss): self.reset(epo_reg_loss) if self.setpoint_rewind: - if self.counter > 2 and self.counter <= 3: # only allow self.counter = 2, 3 to rewind setpoing twice + if self.counter > 2 and self.counter <= 3: + # only allow self.counter = 2, 3 to rewind setpoing twice list_pos = list_true(list_comparison_above_setpoint) print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") for pos in list_pos: print(f"\n\n\n!!!!!!!rewinding setpoint at pos {pos} \ - from {self.host.setpoint4R[pos]} to {self.epo_ma[pos]}!\n\n\n") + from {self.host.setpoint4R[pos]} to \ + {self.epo_ma[pos]}!\n\n\n") self.host.setpoint4R[pos] = self.epo_ma[pos] if self.counter > 3: @@ -115,7 +124,6 @@ def observe(self, epo_reg_loss): self.counter = np.inf # FIXME - class FbOptSetpointController(): """ update setpoint for mu @@ -152,26 +160,31 @@ def update_setpoint_ma(self, list_target, list_pos): """ using moving average """ - target_ma = [self.coeff_ma_setpoint * a + (1 - self.coeff_ma_setpoint) * b + target_ma = [self.coeff_ma_setpoint * a + + (1 - self.coeff_ma_setpoint) * b for a, b in zip(self.setpoint4R, list_target)] - self.setpoint4R = [target_ma[i] if i in list_pos else self.setpoint4R[i] for i in range(len(target_ma))] + self.setpoint4R = [target_ma[i] if i in list_pos else + self.setpoint4R[i] for i in range(len(target_ma))] def observe(self, epo_reg_loss, epo_task_loss): """ read current epo_reg_loss continuously """ - self.state_epo_reg_loss = [self.coeff_ma_output*a + (1-self.coeff_ma_output)*b + self.state_epo_reg_loss = [self.coeff_ma_output*a + \ + (1-self.coeff_ma_output)*b if a != 0.0 else b - for a, b in zip(self.state_epo_reg_loss, epo_reg_loss)] + for a, b in zip( + self.state_epo_reg_loss, epo_reg_loss)] if self.state_task_loss == 0.0: self.state_task_loss = epo_task_loss self.state_task_loss = self.coeff_ma_output * self.state_task_loss + \ - (1-self.coeff_ma_output) * epo_task_loss + (1 - self.coeff_ma_output) * epo_task_loss self.setpoint_rewinder.observe(self.state_epo_reg_loss) flag_update, list_pos = self.state_updater.update_setpoint() if flag_update: self.setpoint_rewinder.reset(self.state_epo_reg_loss) - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger( + logger_name='main_out_logger', loglevel="INFO") logger.info(f"!!!!!set point old value {self.setpoint4R}!") self.update_setpoint_ma(self.state_epo_reg_loss, list_pos) logger.info(f"!!!!!set point updated to {self.setpoint4R}!") @@ -214,9 +227,13 @@ def update_setpoint(self): """ all components of R descreases regardless if ell decreases or not """ - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info(f"comparing: \n {self.host.state_epo_reg_loss} \n {self.host.setpoint4R}") - if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True): + logger = Logger.get_logger( + logger_name='main_out_logger', loglevel="INFO") + logger.info( + f"comparing output vs setpoint: \n \ + {self.host.state_epo_reg_loss} \n {self.host.setpoint4R}") + if is_less_list_all( + self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True): logger.info("!!!!!!!!! better than old setpoint!") return True, list(range(len(self.host.setpoint4R))) return False, None @@ -230,7 +247,8 @@ def update_setpoint(self): """ if any component of R has decreased regardless if ell decreases """ - flag, list_pos = is_less_list_any(self.host.state_epo_reg_loss, self.host.setpoint4R) + flag, list_pos = is_less_list_any( + self.host.state_epo_reg_loss, self.host.setpoint4R) return flag, list_pos def transit(self): @@ -263,7 +281,10 @@ def update_setpoint(self): flag1, list_pos = super().update_setpoint() flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") - logger.info(f"best ell loss: from {self.host.setpoint4ell} to {self.host.state_task_loss}") + logger = Logger.get_logger( + logger_name='main_out_logger', loglevel="INFO") + logger.info( + f"best ell loss: from {self.host.setpoint4ell} to \ + {self.host.state_task_loss}") self.host.setpoint4ell = self.host.state_task_loss return flag1 & flag2, list_pos From 9a1724a928ffc5585b0471ea2fa8eac2599bbd8a Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 14:24:34 +0200 Subject: [PATCH 503/762] Update pacs_diva_fbopt_alone_es5.yaml Add output ma coefficient as tuning parameters --- examples/benchmark/pacs_diva_fbopt_alone_es5.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml index e635332b4..e9c677364 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml @@ -41,6 +41,13 @@ Shared params: - gammad_recon - gammad_recon_per_pixel + output_state_ma: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + mu_clip: distribution: categorical datatype: int @@ -93,3 +100,4 @@ diva_fbopt_full: - k_i_gain - mu_init - str_diva_multiplier_type + - output_state_ma From cd239ee5be4a542c7e5f36b86a160b3dc8e1370f Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 14:29:10 +0200 Subject: [PATCH 504/762] Update args_fbopt.py --- domainlab/algos/trainers/args_fbopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index ed46ece16..e108c3fd2 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -23,7 +23,7 @@ def add_args2parser_fbopt(parser): parser.add_argument('--coeff_ma', type=float, default=0.5, help='exponential moving average') - parser.add_argument('--coeff_ma_output_state', type=float, default=0.9, + parser.add_argument('--coeff_ma_output_state', type=float, default=0.1, help='state exponential moving average of reguarlization loss') parser.add_argument('--coeff_ma_setpoint', type=float, default=0.9, From 5f0040791c6ea5f2de01e6d30bd567177b4ec83f Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 15:10:11 +0200 Subject: [PATCH 505/762] fix bug in yaml file --- examples/benchmark/pacs_diva_fbopt_alone_es5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml index e9c677364..f4f818dbc 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml @@ -41,7 +41,7 @@ Shared params: - gammad_recon - gammad_recon_per_pixel - output_state_ma: + coeff_ma_output_state: distribution: categorical datatype: float values: From dd3ed5518f6d336571c558e14209aa57f9d0a409 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 16:20:44 +0200 Subject: [PATCH 506/762] fbopt_msel_setpoint --- .../algos/trainers/fbopt_mu_controller.py | 70 +++++++++++++------ 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 4e55bea3f..56d7b7fce 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -44,12 +44,14 @@ def __init__(self, trainer, **kwargs): # force initial value of mu self.mmu = {key: self.init_mu for key, val in self.mmu.items()} - self.set_point_controller = FbOptSetpointController(args=self.trainer.aconf) + self.set_point_controller = FbOptSetpointController( + args=self.trainer.aconf) self.k_i_control = trainer.aconf.k_i_gain self.overshoot_rewind = trainer.aconf.overshoot_rewind == "yes" self.delta_epsilon_r = None - # NOTE: this value will be set according to initial evaluation of neural network + # NOTE: this value will be set according to initial evaluation of + # neural network self.activation_clip = trainer.aconf.exp_shoulder_clip if trainer.aconf.no_tensorboard: self.writer = StubSummaryWriter() @@ -90,24 +92,32 @@ def cal_delta_integration(self, list_old, list_new, coeff): """ ma of delta """ - return [(1 - coeff) * a + coeff * b for a, b in zip(list_old, list_new)] + return [(1 - coeff) * a + coeff * b + for a, b in zip(list_old, list_new)] - def tackle_overshoot(self, activation, epo_reg_loss, list_str_multiplier_na): + def tackle_overshoot(self, + activation, epo_reg_loss, list_str_multiplier_na): """ tackle overshoot """ - list_overshoot = [i if (a - b) * (self.delta_epsilon_r[i]) < 0 else None + list_overshoot = [i if (a - b) * (self.delta_epsilon_r[i]) < 0 + else None for i, (a, b) in - enumerate(zip(epo_reg_loss, self.set_point_controller.setpoint4R))] + enumerate( + zip(epo_reg_loss, + self.set_point_controller.setpoint4R))] for ind in list_overshoot: if ind is not None: - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger( + logger_name='main_out_logger', loglevel="INFO") logger.info(f"error integration: {self.delta_epsilon_r}") - logger.info(f"overshooting at pos {ind} of activation: {activation}") + logger.info(f"overshooting at pos \ + {ind} of activation: {activation}") logger.info(f"name reg loss:{list_str_multiplier_na}") if self.overshoot_rewind: activation[ind] = 0.0 - logger.info(f"PID controller set to zero now, new activation: {activation}") + logger.info(f"PID controller set to zero now, \ + new activation: {activation}") return activation def cal_activation(self): @@ -116,13 +126,15 @@ def cal_activation(self): """ setpoint = self.get_setpoing4r() activation = [self.k_i_control * val if setpoint[i] > 0 - else self.k_i_control * (-val) for i, val in enumerate(self.delta_epsilon_r)] + else self.k_i_control * (-val) for i, val + in enumerate(self.delta_epsilon_r)] if self.activation_clip is not None: - activation = [np.clip(val, a_min=-1 * self.activation_clip, a_max=self.activation_clip) + activation = [np.clip(val, + a_min=-1 * self.activation_clip, + a_max=self.activation_clip) for val in activation] return activation - def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, miter): """ @@ -131,29 +143,37 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, to see if the criteria is met $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-ref_R])$$ """ - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger( + logger_name='main_out_logger', loglevel="INFO") logger.info(f"before controller: current mu: {self.mmu}") logger.info(f"epo reg loss: {epo_reg_loss}") logger.info(f"name reg loss:{list_str_multiplier_na}") self.cal_delta4control(epo_reg_loss, self.get_setpoing4r()) activation = self.cal_activation() # overshoot handling - activation = self.tackle_overshoot(activation, epo_reg_loss, list_str_multiplier_na) + activation = self.tackle_overshoot( + activation, epo_reg_loss, list_str_multiplier_na) list_gain = np.exp(activation) dict_gain = dict(zip(list_str_multiplier_na, list_gain)) target = self.dict_multiply(self.mmu, dict_gain) self.mmu = self.dict_clip(target) - logger = Logger.get_logger(logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger( + logger_name='main_out_logger', loglevel="INFO") logger.info(f"after contoller: current mu: {self.mmu}") for key, val in self.mmu.items(): self.writer.add_scalar(f'dyn_mu/{key}', val, miter) - self.writer.add_scalar(f'controller_gain/{key}', dict_gain[key], miter) + self.writer.add_scalar( + f'controller_gain/{key}', dict_gain[key], miter) ind = list_str_multiplier_na.index(key) - self.writer.add_scalar(f'delta/{key}', self.delta_epsilon_r[ind], miter) - for i, (reg_dyn, reg_set) in enumerate(zip(epo_reg_loss, self.get_setpoing4r())): - self.writer.add_scalar(f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) - self.writer.add_scalar(f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) + self.writer.add_scalar( + f'delta/{key}', self.delta_epsilon_r[ind], miter) + for i, (reg_dyn, reg_set) in \ + enumerate(zip(epo_reg_loss, self.get_setpoing4r())): + self.writer.add_scalar( + f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) + self.writer.add_scalar( + f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) self.writer.add_scalars( f'loss_rds/loss_{list_str_multiplier_na[i]} with setpoint', @@ -161,21 +181,26 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, f'lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, }, miter) self.writer.add_scalar( - f'x-axis=loss_ell task vs y-axis=loss r/dyn{list_str_multiplier_na[i]}', + f'x-axis=loss_ell task vs y-axis=loss \ + r/dyn{list_str_multiplier_na[i]}', reg_dyn, epo_task_loss) self.writer.add_scalar('loss_task/penalized', epo_loss_tr, miter) self.writer.add_scalar('loss_task/ell', epo_task_loss, miter) acc_te = 0 acc_val = 0 acc_sel = 0 + acc_set = 0 if miter > 1: acc_te = self.trainer.observer.metric_te["acc"] acc_val = self.trainer.observer.metric_val["acc"] acc_sel = self.trainer.observer.model_sel.sel_model_te_acc + acc_set = \ + self.trainer.observer.model_sel.oracle_last_setpoint_sel_te_acc self.writer.add_scalar("acc/te", acc_te, miter) self.writer.add_scalar("acc/val", acc_val, miter) self.writer.add_scalar("acc/sel", acc_sel, miter) + self.writer.add_scalar("acc/setpoint", acc_set, miter) def dict_clip(self, dict_base): """ @@ -197,7 +222,8 @@ def dict_multiply(self, dict_base, dict_multiplier): """ multiply a float to each element of a dictionary """ - return {key: val * dict_multiplier[key] for key, val in dict_base.items()} + return { + key: val * dict_multiplier[key] for key, val in dict_base.items()} def update_setpoint(self, epo_reg_loss, epo_task_loss): """ From bd3098beee10d5e3c4a12790399bfc630a0352cc Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 16:28:40 +0200 Subject: [PATCH 507/762] fix format --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 01b9928e8..ad574015e 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -231,9 +231,10 @@ def update_setpoint(self): logger_name='main_out_logger', loglevel="INFO") logger.info( f"comparing output vs setpoint: \n \ - {self.host.state_epo_reg_loss} \n {self.host.setpoint4R}") - if is_less_list_all( - self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True): + {self.host.state_epo_reg_loss} \n \ + {self.host.setpoint4R}") + if is_less_list_all(self.host.state_epo_reg_loss, + self.host.setpoint4R, flag_eq=True): logger.info("!!!!!!!!! better than old setpoint!") return True, list(range(len(self.host.setpoint4R))) return False, None From 57ca98ecc96c0d0fde4723885d9c421be5fe1631 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 17:19:38 +0200 Subject: [PATCH 508/762] script for jigen --- run_fbopt_pacs.sh => run_pacs_jigen_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename run_fbopt_pacs.sh => run_pacs_jigen_fbopt.sh (72%) diff --git a/run_fbopt_pacs.sh b/run_pacs_jigen_fbopt.sh similarity index 72% rename from run_fbopt_pacs.sh rename to run_pacs_jigen_fbopt.sh index 81e7a1189..ea00aef80 100644 --- a/run_fbopt_pacs.sh +++ b/run_pacs_jigen_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --bs=16 --aname=jigen --trainer=fbopt --nname=alexnet --epos=100 --es=100 +python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --aname=jigen --trainer=fbopt --bs=64 --epos=200 --es=200 --npath=examples/nets/resnet50domainbed.py --mu_init=1e-6 --lr=5e-5 From 9dbc9146fa9a276b9ef222262eafbc53a7a9a4aa Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 17:22:35 +0200 Subject: [PATCH 509/762] . --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index a988ea4cd..5e9d770fb 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output=0.0 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 From 7047a81208fd15c227c7c9e7327ac74737f69d73 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 20:10:16 +0200 Subject: [PATCH 510/762] early stop 1 --- .../benchmark/pacs_diva_fbopt_alone_es1.yaml | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es1.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml new file mode 100644 index 000000000..a02d55683 --- /dev/null +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -0,0 +1,103 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + es: 1 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + + mu_clip: + distribution: categorical + datatype: int + values: + - 10 + - 1000 + - 1000_000 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + aname: diva + trainer: fbopt + exp_shoulder_clip: 10 + tr_with_init_mu: False + coeff_ma: 0.5 + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + mu_clip: 1000_000 + shared: + - k_i_gain + - mu_init + - str_diva_multiplier_type + - output_state_ma From cf977b891951ce04415b536754bed9fda0f05762 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 20:17:58 +0200 Subject: [PATCH 511/762] . --- run_pacs_jigen_fbopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_pacs_jigen_fbopt.sh b/run_pacs_jigen_fbopt.sh index ea00aef80..ad6fb660b 100644 --- a/run_pacs_jigen_fbopt.sh +++ b/run_pacs_jigen_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --aname=jigen --trainer=fbopt --bs=64 --epos=200 --es=200 --npath=examples/nets/resnet50domainbed.py --mu_init=1e-6 --lr=5e-5 +python main_out.py --te_d=sketch --tpath=examples/tasks/task_pacs_path_list.py --aname=jigen --trainer=fbopt --bs=64 --epos=200 --es=200 --npath=examples/nets/resnet50domainbed.py --mu_init=1e-6 --lr=5e-5 --coeff_ma_output_state=0.1 From b94d7e5277cd75f0b9b4118b61040719f7f243b3 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 21:22:25 +0200 Subject: [PATCH 512/762] Update pacs_diva_fbopt_alone_es1.yaml --- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index a02d55683..d1a7b524a 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -96,8 +96,8 @@ diva_fbopt_full: gamma_y: 1.0 ini_setpoint_ratio: 0.99 mu_clip: 1000_000 + gammad_recon_per_pixel shared: - k_i_gain - mu_init - - str_diva_multiplier_type - output_state_ma From dda9ecb38fd86bf2d87fc424b7fe34beaa85e44b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 21:23:31 +0200 Subject: [PATCH 513/762] Update pacs_diva_fbopt_alone_es1.yaml --- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index d1a7b524a..c7274b6a7 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -47,6 +47,7 @@ Shared params: values: - 0.1 - 0.5 + - 0.9 mu_clip: distribution: categorical From e0ff6461c4639711bdb998a5453b4b7bc7e3e0f8 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 21:24:07 +0200 Subject: [PATCH 514/762] Update pacs_diva_fbopt_alone_es1.yaml --- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index c7274b6a7..94a282630 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -101,4 +101,4 @@ diva_fbopt_full: shared: - k_i_gain - mu_init - - output_state_ma + - coeff_ma_output_state From 343d4ab9a80b7e3e5a68df373aae47a00d52a7fd Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 21:29:12 +0200 Subject: [PATCH 515/762] Update pacs_diva_fbopt_alone_es5.yaml --- examples/benchmark/pacs_diva_fbopt_alone_es5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml index f4f818dbc..9b7983f20 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml @@ -100,4 +100,4 @@ diva_fbopt_full: - k_i_gain - mu_init - str_diva_multiplier_type - - output_state_ma + - coeff_ma_output_state From 21ada6625bd04866eb4232d63d845b05abe6534c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 22:21:11 +0200 Subject: [PATCH 516/762] Update pacs_diva_fbopt_alone_es5.yaml --- examples/benchmark/pacs_diva_fbopt_alone_es5.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml index 9b7983f20..528404920 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml @@ -99,5 +99,4 @@ diva_fbopt_full: shared: - k_i_gain - mu_init - - str_diva_multiplier_type - coeff_ma_output_state From 1d6345be904f3eed2b3d0afa4a2d1d8c56beba00 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 22:30:38 +0200 Subject: [PATCH 517/762] Update fbopt_mu_controller.py --- domainlab/algos/trainers/fbopt_mu_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 56d7b7fce..e7e685960 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -110,7 +110,7 @@ def tackle_overshoot(self, if ind is not None: logger = Logger.get_logger( logger_name='main_out_logger', loglevel="INFO") - logger.info(f"error integration: {self.delta_epsilon_r}") + logger.info(f"delta integration: {self.delta_epsilon_r}") logger.info(f"overshooting at pos \ {ind} of activation: {activation}") logger.info(f"name reg loss:{list_str_multiplier_na}") From ba24ab1138bea0bf0040c9560deed1fccfb2921f Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 22:48:04 +0200 Subject: [PATCH 518/762] Update c_msel_val_top_k.py --- domainlab/algos/msels/c_msel_val_top_k.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index 4c11e5dce..bd8abb47b 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -27,7 +27,7 @@ def update(self, clear_counter=False): # overwrite logger = Logger.get_logger() logger.info(f"top k validation acc: {self.list_top_k_acc} \ - overwriting counter, selected test acc") + overwriting/reset counter") self.es_c = 0 # restore counter ind = self.list_top_k_acc.index(acc_min) # avoid having identical values @@ -36,10 +36,12 @@ def update(self, clear_counter=False): logger.info(f"top k validation acc updated: \ {self.list_top_k_acc}") # overwrite to ensure consistency - self._best_val_acc = metric_val_current + logger.info(f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to {metric_val_current} to ensure consistency") + self._best_val_acc = metric_val_current # FIXME: shall we use max here to the top k list? # overwrite metric_te_current = \ self.tr_obs.metric_te[self.tr_obs.str_metric4msel] + logger.info(f"top-2 val sel: overwriting best test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency") self._sel_model_te_acc = metric_te_current return True return flag_super From 38f08bb0e4f07da69269bd34fd536a23512b959e Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 16 Oct 2023 23:17:17 +0200 Subject: [PATCH 519/762] Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 7e9ceb50c..9a70087ae 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -3,6 +3,7 @@ """ import copy from domainlab.algos.msels.a_model_sel import AMSel +from domainlab.utils.logger import Logger class MSelSetpointDelay(AMSel): @@ -28,6 +29,8 @@ def update(self, clear_counter=False): if the best model should be updated """ if clear_counter: + logger = Logger.get_logger() + logger.info("setpoint msel te acc updated from {self._oracle_last_setpoint_sel_te_acc} to {self.sel_model_te_acc}") self._oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc flag = self.msel.update(clear_counter) return flag From d40903d9c304249dee3f7d05faf00fdab749a6d9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 23:34:12 +0200 Subject: [PATCH 520/762] fix bug in yaml --- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index 94a282630..879f863e2 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -45,6 +45,7 @@ Shared params: distribution: categorical datatype: float values: + - 0 - 0.1 - 0.5 - 0.9 @@ -97,7 +98,7 @@ diva_fbopt_full: gamma_y: 1.0 ini_setpoint_ratio: 0.99 mu_clip: 1000_000 - gammad_recon_per_pixel + str_diva_multiplier_type: gammad_recon_per_pixel shared: - k_i_gain - mu_init From 14ae143614d5169a12fff8c575a01602d3fecbe6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 16 Oct 2023 23:41:03 +0200 Subject: [PATCH 521/762] shrink search area --- examples/benchmark/pacs_diva_fbopt_alone_es5.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml index 528404920..3eafb9c48 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml @@ -95,6 +95,7 @@ diva_fbopt_full: coeff_ma: 0.5 gamma_y: 1.0 ini_setpoint_ratio: 0.99 + str_diva_multiplier_type: gammad_recon_per_pixel mu_clip: 1000_000 shared: - k_i_gain From d153076e79d3f637cafe986a434384f7b924d58d Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 00:13:22 +0200 Subject: [PATCH 522/762] update jigen yaml --- .../benchmark/pacs_jigen_fbopt_alone.yaml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone.yaml b/examples/benchmark/pacs_jigen_fbopt_alone.yaml index c12f49ff3..5dad6b291 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/pacs_jigen_fbopt_alone sampling_seed: 0 startseed: 0 -endseed: 4 +endseed: 3 test_domains: - sketch @@ -15,16 +15,13 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 10 + es: 5 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - exp_shoulder_clip: 10 - mu_clip: 10_000 - coeff_ma: 0.5 zx_dim: 0 zy_dim: 64 zd_dim: 64 @@ -56,12 +53,25 @@ Shared params: num: 10 distribution: loguniform + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + - 0.9 + # Test fbopt with different hyperparameter configurations jigen_feedback: aname: jigen trainer: fbopt ini_setpoint_ratio: 0.99 + exp_shoulder_clip: 10 + mu_clip: 10_000 + coeff_ma: 0.5 + shared: - k_i_gain - mu_init + - coeff_ma_output_state From 6341bfbfec63681cbbfb3b4848c43d3c9b6ce351 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 07:49:43 +0200 Subject: [PATCH 523/762] update jigen mnist yaml --- examples/benchmark/mnist_jigen_fbopt_alone.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/mnist_jigen_fbopt_alone.yaml b/examples/benchmark/mnist_jigen_fbopt_alone.yaml index 10a10db80..315c53b3e 100644 --- a/examples/benchmark/mnist_jigen_fbopt_alone.yaml +++ b/examples/benchmark/mnist_jigen_fbopt_alone.yaml @@ -30,10 +30,11 @@ domainlab_args: Shared params: coeff_ma_output_state: - distribution: uniform - min: 0.0 - max: 0.9 - num: 2 + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 coeff_ma_setpoint: distribution: uniform min: 0.0 From e82b637e8cfbb350a9c1e20b4b275d0f33c2317c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 17 Oct 2023 08:13:42 +0200 Subject: [PATCH 524/762] better print Update fbopt_setpoint_ada.py --- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index ad574015e..2004a1ee2 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -235,7 +235,7 @@ def update_setpoint(self): {self.host.setpoint4R}") if is_less_list_all(self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True): - logger.info("!!!!!!!!! better than old setpoint!") + logger.info("!!!!!!!!!In SliderAllComponent: R current value better than current setpoint!") return True, list(range(len(self.host.setpoint4R))) return False, None From 44262f492d67f2ce3039f121b7ef1bc81f46b656 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 17 Oct 2023 08:36:05 +0200 Subject: [PATCH 525/762] swap wrong sign of dann loss --- domainlab/models/model_dann.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/models/model_dann.py b/domainlab/models/model_dann.py index be25ab73e..292acb8b5 100644 --- a/domainlab/models/model_dann.py +++ b/domainlab/models/model_dann.py @@ -88,5 +88,5 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): AutoGradFunReverseMultiply.apply(feat, self.alpha)) _, d_target = tensor_d.max(dim=1) lc_d = F.cross_entropy(logit_d, d_target, reduction="none") - return [-lc_d], [self.alpha] + return [lc_d], [self.alpha] return ModelDAN From deb9df61d0bbd53d1cdc8cedbcfaf9d8ca349c93 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 17 Oct 2023 08:38:52 +0200 Subject: [PATCH 526/762] print Update c_msel_setpoint_delay.py --- domainlab/algos/msels/c_msel_setpoint_delay.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 9a70087ae..650b57527 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -28,8 +28,9 @@ def update(self, clear_counter=False): """ if the best model should be updated """ + logger = Logger.get_logger() + logger.info(f"setpoint selected current acc {self._oracle_last_setpoint_sel_te_acc}") if clear_counter: - logger = Logger.get_logger() logger.info("setpoint msel te acc updated from {self._oracle_last_setpoint_sel_te_acc} to {self.sel_model_te_acc}") self._oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc flag = self.msel.update(clear_counter) From 2a3bc36d6f57a53b7c1f9b4b1bc7eb36013abe95 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 09:12:32 +0200 Subject: [PATCH 527/762] dann yaml --- examples/benchmark/mnist_dann_fbopt.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/benchmark/mnist_dann_fbopt.yaml b/examples/benchmark/mnist_dann_fbopt.yaml index d44ff429b..3cd4ad4eb 100644 --- a/examples/benchmark/mnist_dann_fbopt.yaml +++ b/examples/benchmark/mnist_dann_fbopt.yaml @@ -43,10 +43,9 @@ Shared params: distribution: uniform mu_init: - min: 0.01 - max: 1.0 - num: 10 - step: 0.01 + min: 0.000001 + max: 0.00001 + num: 2 distribution: uniform # Test fbopt with different hyperparameter configurations @@ -54,9 +53,8 @@ Shared params: dann_fbopt: aname: dann trainer: fbopt - + ini_setpoint_ratio: 0.9 shared: - - ini_setpoint_ratio - k_i_gain - mu_init From 422c2b79f1730e04db9febe1fce5dce7b673a219 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 17 Oct 2023 09:39:50 +0200 Subject: [PATCH 528/762] Update c_msel_val_top_k.py --- domainlab/algos/msels/c_msel_val_top_k.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index bd8abb47b..c86ace3a3 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -35,10 +35,10 @@ def update(self, clear_counter=False): self.list_top_k_acc[ind] = metric_val_current logger.info(f"top k validation acc updated: \ {self.list_top_k_acc}") - # overwrite to ensure consistency - logger.info(f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to {metric_val_current} to ensure consistency") - self._best_val_acc = metric_val_current # FIXME: shall we use max here to the top k list? - # overwrite + # overwrite to ensure consistency + logger.info(f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to {metric_val_current} to ensure consistency") + self._best_val_acc = metric_val_current # FIXME: shall we use max here to the top k list or it does not matter? + # overwrite test acc, this does not depend on if val top-k acc has been overwritten or not metric_te_current = \ self.tr_obs.metric_te[self.tr_obs.str_metric4msel] logger.info(f"top-2 val sel: overwriting best test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency") From 18a514e06729e29c10f3039db6bf2b46d51245a4 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 17 Oct 2023 09:47:30 +0200 Subject: [PATCH 529/762] Update c_msel_val_top_k.py --- domainlab/algos/msels/c_msel_val_top_k.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index c86ace3a3..7d2ce975c 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -36,8 +36,8 @@ def update(self, clear_counter=False): logger.info(f"top k validation acc updated: \ {self.list_top_k_acc}") # overwrite to ensure consistency - logger.info(f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to {metric_val_current} to ensure consistency") - self._best_val_acc = metric_val_current # FIXME: shall we use max here to the top k list or it does not matter? + logger.info(f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to minium of {self.list_top_k_acc} which is {min(self.list_top_k_acc)} to ensure consistency") + self._best_val_acc = min(self.list_top_k_acc) # overwrite test acc, this does not depend on if val top-k acc has been overwritten or not metric_te_current = \ self.tr_obs.metric_te[self.tr_obs.str_metric4msel] From 0ca5d6efc2debd871e99c5a527f55c56544f0608 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 17 Oct 2023 10:58:10 +0200 Subject: [PATCH 530/762] Update c_msel_val_top_k.py --- domainlab/algos/msels/c_msel_val_top_k.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index 7d2ce975c..befad9410 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -41,7 +41,7 @@ def update(self, clear_counter=False): # overwrite test acc, this does not depend on if val top-k acc has been overwritten or not metric_te_current = \ self.tr_obs.metric_te[self.tr_obs.str_metric4msel] - logger.info(f"top-2 val sel: overwriting best test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency") + logger.info(f"top-2 val sel: overwriting selected model test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency") self._sel_model_te_acc = metric_te_current return True return flag_super From eed774431f0fa02b2dc879f9f6b2d61b1a97bba1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 11:07:46 +0200 Subject: [PATCH 531/762] fix issue #572 --- domainlab/algos/observers/b_obvisitor.py | 3 ++- domainlab/arg_parser.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index ca643ccff..e689b02ad 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -60,7 +60,8 @@ def update(self, epoch, flag_info=False): self.exp.visitor.save(self.host_trainer.model) logger.info("persisted") flag_stop = self.model_sel.if_stop() - return flag_stop + flag_enough = epoch > self.host_trainer.aconf.epos_min + return flag_stop & flag_enough def accept(self, trainer): """ diff --git a/domainlab/arg_parser.py b/domainlab/arg_parser.py index 1e792fa88..aaf6fd5e1 100644 --- a/domainlab/arg_parser.py +++ b/domainlab/arg_parser.py @@ -51,9 +51,12 @@ def mk_parser_main(): parser.add_argument('--epos', default=2, type=int, help='maximum number of epochs') + parser.add_argument('--epos_min', default=0, type=int, + help='maximum number of epochs') + parser.add_argument('--epo_te', default=1, type=int, help='test performance per {} epochs') - + parser.add_argument('-w', '--warmup', type=int, default=100, help='number of epochs for hyper-parameter warm-up. \ Set to 0 to turn warmup off.') From e84d75c1db11dbc8a26f85877960920d4f38d0c8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 11:09:20 +0200 Subject: [PATCH 532/762] add epos_min to yaml diva --- examples/benchmark/pacs_diva_fbopt_alone_es5.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml index 3eafb9c48..ef271fcf2 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml @@ -15,6 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 + epos_min: 20 es: 5 bs: 64 san_check: False From bc58cf1ee9ca9302159947d6dbd529ff5056c782 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 11:28:30 +0200 Subject: [PATCH 533/762] remove default hyper-parameters --- examples/benchmark/pacs_diva_fbopt_alone_es5.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml index ef271fcf2..46497cc8d 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml @@ -91,13 +91,10 @@ Shared params: diva_fbopt_full: aname: diva trainer: fbopt - exp_shoulder_clip: 10 - tr_with_init_mu: False - coeff_ma: 0.5 + exp_shoulder_clip: 5 gamma_y: 1.0 ini_setpoint_ratio: 0.99 str_diva_multiplier_type: gammad_recon_per_pixel - mu_clip: 1000_000 shared: - k_i_gain - mu_init From 4007dc8b52005d9773265d216d2bd27443373147 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 11:42:22 +0200 Subject: [PATCH 534/762] less core --- run_benchmark_slurm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_benchmark_slurm.sh b/run_benchmark_slurm.sh index 5c3d3338c..3294c1b10 100755 --- a/run_benchmark_slurm.sh +++ b/run_benchmark_slurm.sh @@ -19,4 +19,4 @@ echo "Configuration file: $CONFIGFILE" echo "starting seed is: $DOMAINLAB_CUDA_START_SEED" echo "verbose log: $logfile" # Helmholtz -snakemake --profile "examples/yaml/slurm" --keep-going --keep-incomplete --notemp --cores 5 -s "domainlab/exp_protocol/benchmark.smk" --configfile "$CONFIGFILE" 2>&1 | tee "$logfile" +snakemake --profile "examples/yaml/slurm" --keep-going --keep-incomplete --notemp --cores 3 -s "domainlab/exp_protocol/benchmark.smk" --configfile "$CONFIGFILE" 2>&1 | tee "$logfile" From fa79b119e3f79cfd9fd46555c9f946f21b4c4965 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 11:52:40 +0200 Subject: [PATCH 535/762] deafult diva --- .../pacs_diva_fbopt_alone_fixed.yaml | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml b/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml new file mode 100644 index 000000000..0722fb3f9 --- /dev/null +++ b/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml @@ -0,0 +1,97 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone + +sampling_seed: 0 + +startseed: 0 +endseed: 5 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + epos_min: 20 + es: 5 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + + mu_clip: + distribution: categorical + datatype: int + values: + - 10 + - 1000 + - 1000_000 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + aname: diva + trainer: fbopt + exp_shoulder_clip: 5 + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + mu_init: 1e-6 From 58b5f21e023e4bf4b37a30582ad1ecb235b57df2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 12:35:32 +0200 Subject: [PATCH 536/762] . --- examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml b/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml index 0722fb3f9..d6d05d6cb 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml @@ -94,4 +94,4 @@ diva_fbopt_full: exp_shoulder_clip: 5 gamma_y: 1.0 ini_setpoint_ratio: 0.99 - mu_init: 1e-6 + mu_init: 0.000001 From dc2824e284285d1b5150b394ac87176ad704163a Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 17 Oct 2023 18:49:44 +0200 Subject: [PATCH 537/762] Update c_msel_val_top_k.py issue #569, issue #573 --- domainlab/algos/msels/c_msel_val_top_k.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index befad9410..02687b0f5 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -36,12 +36,16 @@ def update(self, clear_counter=False): logger.info(f"top k validation acc updated: \ {self.list_top_k_acc}") # overwrite to ensure consistency + # issue #569: initially self.list_top_k_acc will be [xx, 0] and it does not matter since 0 will be overwriten by second epoch validation acc. + # actually, after epoch 1, most often, sefl._best_val_acc will be the higher value of self.list_top_k_acc will overwriten by min(self.list_top_k_acc) logger.info(f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to minium of {self.list_top_k_acc} which is {min(self.list_top_k_acc)} to ensure consistency") self._best_val_acc = min(self.list_top_k_acc) # overwrite test acc, this does not depend on if val top-k acc has been overwritten or not metric_te_current = \ self.tr_obs.metric_te[self.tr_obs.str_metric4msel] - logger.info(f"top-2 val sel: overwriting selected model test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency") + if self._sel_model_te_acc != metric_te_current: + # this can only happen if the validation acc has decreased and current val acc is only bigger than min(self.list_top_k_acc} but lower than max(self.list_top_k_acc) + logger.info(f"top-2 val sel: overwriting selected model test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency") self._sel_model_te_acc = metric_te_current return True return flag_super From 4ff16b2500555bcd818fc85c9d996b9045a1c565 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 19:03:32 +0200 Subject: [PATCH 538/762] es1 yaml --- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index 879f863e2..0d8971878 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -15,6 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 + epos_min: 20 es: 1 bs: 64 san_check: False @@ -45,10 +46,8 @@ Shared params: distribution: categorical datatype: float values: - - 0 - 0.1 - 0.5 - - 0.9 mu_clip: distribution: categorical @@ -92,13 +91,9 @@ Shared params: diva_fbopt_full: aname: diva trainer: fbopt - exp_shoulder_clip: 10 - tr_with_init_mu: False - coeff_ma: 0.5 gamma_y: 1.0 ini_setpoint_ratio: 0.99 - mu_clip: 1000_000 - str_diva_multiplier_type: gammad_recon_per_pixel + str_diva_multiplier_type: gammad_recon shared: - k_i_gain - mu_init From 2685ae855c2079135904717141d9b390f6a500ba Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 17 Oct 2023 20:42:39 +0200 Subject: [PATCH 539/762] gen plot script --- sh_genplot.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 sh_genplot.sh diff --git a/sh_genplot.sh b/sh_genplot.sh new file mode 100644 index 000000000..93c4cdbda --- /dev/null +++ b/sh_genplot.sh @@ -0,0 +1 @@ +python main_out.py --gen_plots $1 --outp_dir . From 8915789eb72b9bcd0739f8714d1dbd47f38884cc Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 18 Oct 2023 08:50:14 +0200 Subject: [PATCH 540/762] Update pacs_diva_fbopt_alone_es1.yaml --- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index 879f863e2..e5c11868c 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -52,11 +52,12 @@ Shared params: mu_clip: distribution: categorical - datatype: int + datatype: float values: - 10 - 1000 - - 1000_000 + - 1 + - 100 k_i_gain: min: 0.0001 @@ -103,3 +104,4 @@ diva_fbopt_full: - k_i_gain - mu_init - coeff_ma_output_state + - mu_clip From b49f829ae7d790800827e9d35ec8c640e22e929d Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 18 Oct 2023 08:55:51 +0200 Subject: [PATCH 541/762] Update exp_main.py --- domainlab/compos/exp/exp_main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domainlab/compos/exp/exp_main.py b/domainlab/compos/exp/exp_main.py index 239210f8c..76caed5b9 100755 --- a/domainlab/compos/exp/exp_main.py +++ b/domainlab/compos/exp/exp_main.py @@ -25,6 +25,7 @@ def __init__(self, args, task=None, model=None, observer=None, visitor=AggWriter :param model: default None """ self.task = task + self.curr_dir = os.getcwd() if task is None: self.task = TaskChainNodeGetter(args)() if args.san_check: @@ -67,11 +68,12 @@ def execute(self, num_epochs=None): t_before_epoch = t_c flag_stop = self.trainer.tr_epoch(epoch) t_c = datetime.datetime.now() - logger.info(f"epoch: {epoch}," + logger.info(f"after epoch: {epoch}," f"now: {str(t_c)}," f"epoch time: {t_c - t_before_epoch}," f"used: {t_c - t_0}," f"model: {self.visitor.model_name}") + logger.info(f"working direcotry: {self.curr_dir}") # current time, time since experiment start, epoch time if flag_stop: self.epoch_counter = epoch From 434ef6cfc31c92a17f15795759ef7c148d38f139 Mon Sep 17 00:00:00 2001 From: DanScarc Date: Wed, 18 Oct 2023 19:17:19 +0200 Subject: [PATCH 542/762] Add YAML benchmark --- .../pacs_diva_fbopt_alone_es1_daniele.yaml | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es1_daniele.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_daniele.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_daniele.yaml new file mode 100644 index 000000000..8b827a047 --- /dev/null +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_daniele.yaml @@ -0,0 +1,115 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + epos_min: 20 + es: 1 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0 + - 0.1 + - 0.5 + - 0.9 + + mu_clip: + distribution: categorical + datatype: int + values: + - 10 + - 1000 + - 1 + - 100 + + exp_shoulder_clip: + distribution: categorical + datatype: int + values: + - 2 + - 5 + - 10 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + aname: diva + trainer: fbopt + tr_with_init_mu: False + coeff_ma: 0.5 + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + coeff_ma_output_state: 0.1 + k_i_gain: 0.00835 + mu_init: 0.000011 + shared: + - exp_shoulder_clip + - str_diva_multiplier_type + - mu_clip From 9ee6c890171b4af3be87e4873d2863211ed63153 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 19 Oct 2023 15:17:29 +0200 Subject: [PATCH 543/762] rename --- run_fbopt.sh => run_mnist_jigen.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename run_fbopt.sh => run_mnist_jigen.sh (100%) diff --git a/run_fbopt.sh b/run_mnist_jigen.sh similarity index 100% rename from run_fbopt.sh rename to run_mnist_jigen.sh From 0cbec29b88cfb7ddab6f54e2fba36ad80340c0b3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 19 Oct 2023 15:54:44 +0200 Subject: [PATCH 544/762] clean up code --- .../utils/generate_fbopt_phase_portrait.py | 53 ++++++++++++------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 88b2bd97a..759830c43 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -1,16 +1,16 @@ import glob import os +import argparse import matplotlib.pyplot as plt -from tensorboard.backend.event_processing.event_accumulator import EventAccumulator +from tensorboard.backend.event_processing.event_accumulator \ + import EventAccumulator -# FIXME: maybe adjust the output path where the png is saved -output_dir = "../.." - -def get_xy_from_event_file(event_file, tf_size_guidance=None): +def get_xy_from_event_file(event_file, str1, str2, tf_size_guidance=None): if tf_size_guidance is None: - # settings for which/how much data is loaded from the tensorboard event files + # settings for which/how much data is loaded from the + # tensorboard event files tf_size_guidance = { 'compressedHistograms': 0, 'images': 0, @@ -21,27 +21,32 @@ def get_xy_from_event_file(event_file, tf_size_guidance=None): event = EventAccumulator(event_file, tf_size_guidance) event.Reload() # extract the reg/dyn0 values - y_event = event.Scalars('x-axis=task vs y-axis=reg/dyn0') + y_event = event.Scalars(str1) y = [s.value for s in y_event] - x_int = [s.step for s in y_event] # the .step data are saved as ints in tensorboard, so we will re-extact from 'task' + x_int = [s.step for s in y_event] + # the .step data are saved as ints in tensorboard, + # so we will re-extact from 'task' # extract the corresponding 'task' values - x_event = event.Scalars('task') + x_event = event.Scalars(str2) x = [s.value for s in x_event] # sanity check: for i in range(len(x)): assert int(x[i]) == x_int[i] return x, y -def phase_portrain_combined(event_files, colors): + +def phase_portrain_combined(event_files, colors, str1, str2, output_dir="."): plt.figure() for event_i in range(len(event_files)): - x, y = get_xy_from_event_file(event_files[event_i]) + x, y = get_xy_from_event_file(event_files[event_i], + str1=str1, str2=str2) assert len(x) == len(y) - for i in range(len(x)-1): - plt.arrow(x[i], y[i], (x[i+1]-x[i]), (y[i+1]-y[i]), - head_width=0.2, head_length=0.2, length_includes_head=True, + for i in range(len(x) - 1): + plt.arrow(x[i], y[i], (x[i + 1] - x[i]), (y[i + 1] - y[i]), + head_width=0.2, head_length=0.2, + length_includes_head=True, fc=colors[event_i], ec=colors[event_i], alpha=0.4) plt.plot(x[0], y[0], 'ko') @@ -51,13 +56,21 @@ def phase_portrain_combined(event_files, colors): plt.ylabel("reg/dyn0") plt.title("x-axis=task vs y-axis=reg/dyn0") - plt.savefig(os.path.join(output_dir, 'phase_portrain_combined.png'), dpi=300) + plt.savefig(os.path.join(output_dir, + 'phase_portrain_combined.png'), dpi=300) if __name__ == "__main__": - event_files = glob.glob("../../runs/*/events*") - print("Using the following tensorboard event files:\n{}".format("\n".join(event_files))) - cmap = plt.get_cmap('tab10') # Choose a colormap - colors = [cmap(i) for i in range(len(event_files))] # Different colors for the different runs - phase_portrain_combined(event_files, colors) + parser = argparse.ArgumentParser(description='plot') + parser.add_argument('-str1', "--str1", default=None, type=str) + parser.add_argument('-str2', "--str2", default=None, type=str) + args = parser.parse_args() + event_files = glob.glob("runs/*/events*") + print("Using the following tensorboard event files:\n{}".format( + "\n".join(event_files))) + cmap = plt.get_cmap('tab10') # Choose a colormap + colors = [cmap(i) for i in range(len(event_files))] + # Different colors for the different runs + phase_portrain_combined(event_files, colors, + str1=args.str1, str2=args.str2) From c65167a28c7d1f40ccb424d9eef5a7764fbbcfb3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 19 Oct 2023 16:01:56 +0200 Subject: [PATCH 545/762] disable sanity --- domainlab/utils/generate_fbopt_phase_portrait.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 759830c43..685bf8883 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -7,7 +7,9 @@ import EventAccumulator -def get_xy_from_event_file(event_file, str1, str2, tf_size_guidance=None): +def get_xy_from_event_file(event_file, str1, str2, + tf_size_guidance=None, + sanity_check=False): if tf_size_guidance is None: # settings for which/how much data is loaded from the # tensorboard event files @@ -30,8 +32,9 @@ def get_xy_from_event_file(event_file, str1, str2, tf_size_guidance=None): x_event = event.Scalars(str2) x = [s.value for s in x_event] # sanity check: - for i in range(len(x)): - assert int(x[i]) == x_int[i] + if sanity_check: + for i in range(len(x)): + assert int(x[i]) == x_int[i] return x, y From b98c87500518b4952aaeba811a4ce6011fc2cb24 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 19 Oct 2023 16:05:12 +0200 Subject: [PATCH 546/762] . --- domainlab/utils/generate_fbopt_phase_portrait.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 685bf8883..4b8a3c81d 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -55,9 +55,9 @@ def phase_portrain_combined(event_files, colors, str1, str2, output_dir="."): plt.plot(x[0], y[0], 'ko') plt.scatter(x, y, s=1, c='black') - plt.xlabel("task") - plt.ylabel("reg/dyn0") - plt.title("x-axis=task vs y-axis=reg/dyn0") + plt.xlabel(str1) + plt.ylabel(str2) + plt.title("phase portrait") plt.savefig(os.path.join(output_dir, 'phase_portrain_combined.png'), dpi=300) From 24620555aa574394982cac184207160439a8f6e1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 19 Oct 2023 16:16:41 +0200 Subject: [PATCH 547/762] timecourse plot --- domainlab/utils/generate_fbopt_phase_portrait.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 4b8a3c81d..a4674b8ec 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -63,6 +63,21 @@ def phase_portrain_combined(event_files, colors, str1, str2, output_dir="."): 'phase_portrain_combined.png'), dpi=300) +def curve_combined(event_files, colors, str1, str2, output_dir="."): + plt.figure() + for event_i in range(len(event_files)): + x, y = get_xy_from_event_file(event_files[event_i], + str1=str1, str2=str2) + plt.plot(x) + plt.plot(y) + plt.xlabel("time") + plt.ylabel("loss") + plt.title("timecourse") + + plt.savefig(os.path.join(output_dir, + 'timecourse.png'), dpi=300) + + if __name__ == "__main__": parser = argparse.ArgumentParser(description='plot') parser.add_argument('-str1', "--str1", default=None, type=str) @@ -77,3 +92,4 @@ def phase_portrain_combined(event_files, colors, str1, str2, output_dir="."): # Different colors for the different runs phase_portrain_combined(event_files, colors, str1=args.str1, str2=args.str2) + curve_combined(event_files, colors, str1=args.str1, str2=args.str2) From 7b57592cb0055d33a06f402ebdcac0bf5c7dcd12 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 19 Oct 2023 18:13:39 +0200 Subject: [PATCH 548/762] diva yaml --- .../mnist_diva_fbopt_and_baselines.yaml | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index 20ae5a6b6..4dd54e732 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -4,7 +4,7 @@ output_dir: zoutput/benchmarks/mnist_diva_fbopt_and_baselines sampling_seed: 0 startseed: 0 -endseed: 4 +endseed: 10 test_domains: - 0 @@ -15,8 +15,9 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 2000 - es: 500 + epos: 500 + epos_min: 20 + es: 5 bs: 64 zx_dim: 0 zy_dim: 32 @@ -26,8 +27,6 @@ domainlab_args: nname_topic_distrib_img2topic: conv_bn_pool_2 nname_encoder_sandwich_layer_img2h4zd: conv_bn_pool_2 san_check: False - exp_shoulder_clip: 5.0 - mu_clip: 1000_000 coeff_ma: 0.5 no_tensorboard: False @@ -66,6 +65,21 @@ Shared params: num: 3 distribution: loguniform + exp_shoulder_clip: + distribution: categorical + values: + - 5 + - 10 + - 1 + + mu_clip: + distribution: categorical + values: + - 1000 + - 100 + - 10 + - 1 + # Test fbopt with different hyperparameter configurations diva_fbopt_a: @@ -77,6 +91,8 @@ diva_fbopt_a: shared: - k_i_gain - mu_init + - exp_shoulder_clip + - mu_clip diva_feedforward_a: aname: diva From 60f3e43089bd83266b2b471b72315c8a923d9073 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 19 Oct 2023 18:22:41 +0200 Subject: [PATCH 549/762] . --- examples/benchmark/mnist_diva_fbopt_and_baselines.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index 4dd54e732..3c0daf43c 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -67,6 +67,7 @@ Shared params: exp_shoulder_clip: distribution: categorical + datatype: float values: - 5 - 10 @@ -74,6 +75,7 @@ Shared params: mu_clip: distribution: categorical + datatype: float values: - 1000 - 100 From 27915b37d0aba646a908de0cf0305eb9409b7ce2 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 20 Oct 2023 15:59:03 +0200 Subject: [PATCH 550/762] Update pacs_jigen_baslines4fbopt.yaml --- examples/benchmark/pacs_jigen_baslines4fbopt.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml index d5a70cefa..2cc493318 100644 --- a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -15,16 +15,14 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 10 + epos_min: 20 + es: 1 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - exp_shoulder_clip: 10 - mu_clip: 10_000 - coeff_ma: 0.5 zx_dim: 0 zy_dim: 64 zd_dim: 64 From 15a7d9736abc25b2b6adb72dd226769bccb0a469 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 20 Oct 2023 17:59:16 +0200 Subject: [PATCH 551/762] yaml --- examples/benchmark/pacs_diva_fbopt_and_others.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml index e2967cd11..b43d1f974 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_others.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_others sampling_seed: 0 startseed: 0 -endseed: 2 +endseed: 5 test_domains: - sketch @@ -15,16 +15,14 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 10 + epos_min: 20 + es: 1 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - exp_shoulder_clip: 10 - mu_clip: 1000_000 - coeff_ma: 0.5 zx_dim: 0 zy_dim: 64 zd_dim: 64 @@ -75,9 +73,8 @@ diva_fbopt_full: str_diva_multiplier_type: gammad_recon gamma_y: 1.0 ini_setpoint_ratio: 0.99 - shared: - - k_i_gain - - mu_init + mu_clip: 1.0 + mu_init: 1e-6 diva_feedforward_full: aname: diva From 8163693392ee43c1fbb122d8a3ac9d0acba62396 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 20 Oct 2023 18:00:25 +0200 Subject: [PATCH 552/762] . --- examples/benchmark/pacs_diva_fbopt_and_others.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml index b43d1f974..f2ea94b08 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_others.yaml @@ -75,6 +75,8 @@ diva_fbopt_full: ini_setpoint_ratio: 0.99 mu_clip: 1.0 mu_init: 1e-6 + shared: + - k_i_gain diva_feedforward_full: aname: diva From ddd53fa8827bec393493905a142fe6bb2f3cb0d1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 20 Oct 2023 18:00:55 +0200 Subject: [PATCH 553/762] . --- examples/benchmark/pacs_diva_fbopt_and_others.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml index f2ea94b08..c82d3e58c 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_others.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_others sampling_seed: 0 startseed: 0 -endseed: 5 +endseed: 6 test_domains: - sketch From f404179d14675344ec1effd9d661b1350aeb9834 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sat, 21 Oct 2023 09:19:49 +0200 Subject: [PATCH 554/762] diva mnist --- .../benchmark/mnist_diva_fbopt_and_baselines.yaml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index 3c0daf43c..9af193f46 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -65,14 +65,6 @@ Shared params: num: 3 distribution: loguniform - exp_shoulder_clip: - distribution: categorical - datatype: float - values: - - 5 - - 10 - - 1 - mu_clip: distribution: categorical datatype: float @@ -90,10 +82,10 @@ diva_fbopt_a: str_diva_multiplier_type: gammad_recon gamma_y: 1.0 init_setpoint_ratio: 0.99 + exp_shoulder_clip: 1 + mu_init: 1e-6 shared: - k_i_gain - - mu_init - - exp_shoulder_clip - mu_clip diva_feedforward_a: From 97c454a19455a27896e80cc5facd78c7d4277063 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 23 Oct 2023 11:45:01 +0200 Subject: [PATCH 555/762] jigen all --- .../benchmark/pacs_jigen_fbopt_and_others.yaml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_and_others.yaml b/examples/benchmark/pacs_jigen_fbopt_and_others.yaml index 83e5c092b..3b2a55b24 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_others.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full sampling_seed: 0 startseed: 0 -endseed: 4 +endseed: 5 test_domains: - sketch @@ -15,16 +15,14 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 10 + epos_min: 20 + es: 1 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - exp_shoulder_clip: 10 - mu_clip: 10_000 - coeff_ma: 0.5 zx_dim: 0 zy_dim: 64 zd_dim: 64 @@ -56,6 +54,15 @@ Shared params: num: 10 distribution: loguniform + mu_clip: + distribution: categorical + datatype: float + values: + - 1 + - 10 + - 100 + - 1000 + # Test fbopt with different hyperparameter configurations jigen_feedback: @@ -65,6 +72,7 @@ jigen_feedback: shared: - k_i_gain - mu_init + - mu_clip jigen_feedforward: aname: jigen From 1011fdc2f6813c927e445794d7dd6e3293bec986 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 23 Oct 2023 11:48:22 +0200 Subject: [PATCH 556/762] . --- examples/benchmark/pacs_jigen_fbopt_and_others.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_and_others.yaml b/examples/benchmark/pacs_jigen_fbopt_and_others.yaml index 3b2a55b24..63c25b466 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_others.yaml @@ -33,13 +33,13 @@ Shared params: k_i_gain: min: 0.0001 max: 0.01 - num: 3 + num: 2 distribution: loguniform mu_init: min: 0.000001 max: 0.00005 - num: 3 + num: 2 distribution: loguniform pperm: @@ -51,7 +51,7 @@ Shared params: gamma_reg: min: 0.01 max: 10_000 - num: 10 + num: 4 distribution: loguniform mu_clip: @@ -69,9 +69,9 @@ jigen_feedback: aname: jigen trainer: fbopt ini_setpoint_ratio: 0.99 + mu_init: 0.000001 shared: - k_i_gain - - mu_init - mu_clip jigen_feedforward: From f41fd616cc269a89c1fc987df25f80a4921d285f Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 23 Oct 2023 16:00:23 +0200 Subject: [PATCH 557/762] clean diva yaml file --- examples/benchmark/pacs_diva_fbopt_alone.yaml | 95 --------------- .../benchmark/pacs_diva_fbopt_alone_es1.yaml | 6 +- .../pacs_diva_fbopt_alone_es1_daniele.yaml | 115 ------------------ .../benchmark/pacs_diva_fbopt_alone_es5.yaml | 101 --------------- 4 files changed, 3 insertions(+), 314 deletions(-) delete mode 100644 examples/benchmark/pacs_diva_fbopt_alone.yaml delete mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es1_daniele.yaml delete mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es5.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone.yaml b/examples/benchmark/pacs_diva_fbopt_alone.yaml deleted file mode 100644 index 00e05abaa..000000000 --- a/examples/benchmark/pacs_diva_fbopt_alone.yaml +++ /dev/null @@ -1,95 +0,0 @@ -mode: grid - -output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone - -sampling_seed: 0 - -startseed: 0 -endseed: 2 - -test_domains: - - sketch - -domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py - dmem: False - lr: 5e-5 - epos: 200 - es: 10 - bs: 64 - san_check: False - npath: examples/nets/resnet50domainbed.py - npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - zx_dim: 0 - zy_dim: 64 - zd_dim: 64 - - -Shared params: - ini_setpoint_ratio: - min: 0.990 - max: 0.999 - num: 2 - distribution: uniform - - str_diva_multiplier_type: - distribution: categorical - datatype: str - values: - - gammad_recon - - gammad_recon_per_pixel - - mu_clip: - distribution: categorical - datatype: int - values: - - 10 - - 1000 - - 1000_000 - - k_i_gain: - min: 0.0001 - max: 0.01 - num: 3 - distribution: uniform - - mu_init: - min: 0.000001 - max: 0.00001 - step: 0.000001 - num: 3 - distribution: loguniform - - gamma_y: - min: 1.0 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - gamma_d: - min: 1.0 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - - -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small - -diva_fbopt_full: - aname: diva - trainer: fbopt - exp_shoulder_clip: 10 - tr_with_init_mu: False - coeff_ma: 0.5 - gamma_y: 1.0 - ini_setpoint_ratio: 0.99 - mu_clip: 1000_000 - shared: - - k_i_gain - - mu_init - - str_diva_multiplier_type diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index 9167891a5..1a004a2dc 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -61,7 +61,7 @@ Shared params: k_i_gain: min: 0.0001 max: 0.01 - num: 3 + num: 2 distribution: uniform mu_init: @@ -95,8 +95,8 @@ diva_fbopt_full: gamma_y: 1.0 ini_setpoint_ratio: 0.99 str_diva_multiplier_type: gammad_recon + coeff_ma_output_state: 0.1 + mu_init: 0.000001 shared: - k_i_gain - - mu_init - - coeff_ma_output_state - mu_clip diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_daniele.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_daniele.yaml deleted file mode 100644 index 8b827a047..000000000 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_daniele.yaml +++ /dev/null @@ -1,115 +0,0 @@ -mode: grid - -output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone - -sampling_seed: 0 - -startseed: 0 -endseed: 2 - -test_domains: - - sketch - -domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py - dmem: False - lr: 5e-5 - epos: 200 - epos_min: 20 - es: 1 - bs: 64 - san_check: False - npath: examples/nets/resnet50domainbed.py - npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - zx_dim: 0 - zy_dim: 64 - zd_dim: 64 - - -Shared params: - ini_setpoint_ratio: - min: 0.990 - max: 0.999 - num: 2 - distribution: uniform - - str_diva_multiplier_type: - distribution: categorical - datatype: str - values: - - gammad_recon - - gammad_recon_per_pixel - - coeff_ma_output_state: - distribution: categorical - datatype: float - values: - - 0 - - 0.1 - - 0.5 - - 0.9 - - mu_clip: - distribution: categorical - datatype: int - values: - - 10 - - 1000 - - 1 - - 100 - - exp_shoulder_clip: - distribution: categorical - datatype: int - values: - - 2 - - 5 - - 10 - - k_i_gain: - min: 0.0001 - max: 0.01 - num: 3 - distribution: uniform - - mu_init: - min: 0.000001 - max: 0.00001 - step: 0.000001 - num: 3 - distribution: loguniform - - gamma_y: - min: 1.0 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - gamma_d: - min: 1.0 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - - -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small - -diva_fbopt_full: - aname: diva - trainer: fbopt - tr_with_init_mu: False - coeff_ma: 0.5 - gamma_y: 1.0 - ini_setpoint_ratio: 0.99 - coeff_ma_output_state: 0.1 - k_i_gain: 0.00835 - mu_init: 0.000011 - shared: - - exp_shoulder_clip - - str_diva_multiplier_type - - mu_clip diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml deleted file mode 100644 index 46497cc8d..000000000 --- a/examples/benchmark/pacs_diva_fbopt_alone_es5.yaml +++ /dev/null @@ -1,101 +0,0 @@ -mode: grid - -output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone - -sampling_seed: 0 - -startseed: 0 -endseed: 2 - -test_domains: - - sketch - -domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py - dmem: False - lr: 5e-5 - epos: 200 - epos_min: 20 - es: 5 - bs: 64 - san_check: False - npath: examples/nets/resnet50domainbed.py - npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - zx_dim: 0 - zy_dim: 64 - zd_dim: 64 - - -Shared params: - ini_setpoint_ratio: - min: 0.990 - max: 0.999 - num: 2 - distribution: uniform - - str_diva_multiplier_type: - distribution: categorical - datatype: str - values: - - gammad_recon - - gammad_recon_per_pixel - - coeff_ma_output_state: - distribution: categorical - datatype: float - values: - - 0.1 - - 0.5 - - mu_clip: - distribution: categorical - datatype: int - values: - - 10 - - 1000 - - 1000_000 - - k_i_gain: - min: 0.0001 - max: 0.01 - num: 3 - distribution: uniform - - mu_init: - min: 0.000001 - max: 0.00001 - step: 0.000001 - num: 3 - distribution: loguniform - - gamma_y: - min: 1.0 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - gamma_d: - min: 1.0 - max: 1e6 - step: 100 - num: 3 - distribution: loguniform - - - -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small - -diva_fbopt_full: - aname: diva - trainer: fbopt - exp_shoulder_clip: 5 - gamma_y: 1.0 - ini_setpoint_ratio: 0.99 - str_diva_multiplier_type: gammad_recon_per_pixel - shared: - - k_i_gain - - mu_init - - coeff_ma_output_state From 3a030db3287a2b6773ad898a4c60e7fc9f7043fb Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 24 Oct 2023 14:51:15 +0200 Subject: [PATCH 558/762] yaml --- .../benchmark/mnist_diva_fbopt_alone.yaml | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/benchmark/mnist_diva_fbopt_alone.yaml b/examples/benchmark/mnist_diva_fbopt_alone.yaml index 87e80c31b..79078a21f 100644 --- a/examples/benchmark/mnist_diva_fbopt_alone.yaml +++ b/examples/benchmark/mnist_diva_fbopt_alone.yaml @@ -1,10 +1,10 @@ mode: grid -output_dir: zoutput/benchmarks/benchmark_fbopt +output_dir: zoutput/benchmarks/mnist_diva_fbopt_alone sampling_seed: 0 startseed: 0 -endseed: 4 +endseed: 10 test_domains: - 0 @@ -16,7 +16,8 @@ domainlab_args: dmem: False lr: 0.001 epos: 500 - es: 50 + epos_min: 20 + es: 5 bs: 64 zx_dim: 0 zy_dim: 32 @@ -26,8 +27,6 @@ domainlab_args: nname_topic_distrib_img2topic: conv_bn_pool_2 nname_encoder_sandwich_layer_img2h4zd: conv_bn_pool_2 san_check: False - exp_shoulder_clip: 5.0 - mu_clip: 1000_000 coeff_ma: 0.5 no_tensorboard: False @@ -48,8 +47,8 @@ Shared params: mu_init: min: 0.000001 - max: 1 - num: 4 + max: 0.00001 + num: 3 distribution: loguniform gamma_y: @@ -66,6 +65,15 @@ Shared params: num: 3 distribution: loguniform + mu_clip: + distribution: categorical + datatype: float + values: + - 1000 + - 100 + - 10 + - 1 + # Test fbopt with different hyperparameter configurations diva_fbopt_a: @@ -74,10 +82,11 @@ diva_fbopt_a: str_diva_multiplier_type: gammad_recon gamma_y: 1.0 init_setpoint_ratio: 0.99 - + exp_shoulder_clip: 1 + mu_init: 1e-6 shared: - k_i_gain - - mu_init + - mu_clip erm: aname: deepall From d7f5b97de2e4b79145848adabb6d62c520cab7b7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 24 Oct 2023 15:00:54 +0200 Subject: [PATCH 559/762] fix issue #588 --- domainlab/utils/generate_fbopt_phase_portrait.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index a4674b8ec..708facdd2 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -73,9 +73,10 @@ def curve_combined(event_files, colors, str1, str2, output_dir="."): plt.xlabel("time") plt.ylabel("loss") plt.title("timecourse") + plt.legend([str1, str2]) plt.savefig(os.path.join(output_dir, - 'timecourse.png'), dpi=300) + f'timecourse_{str1}_{str2}.png'), dpi=300) if __name__ == "__main__": From 5a67544dba15a24b9584a9725f079da031d45bb3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 24 Oct 2023 15:09:56 +0200 Subject: [PATCH 560/762] fix bug in plot --- domainlab/utils/generate_fbopt_phase_portrait.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 708facdd2..e16300c60 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -23,13 +23,13 @@ def get_xy_from_event_file(event_file, str1, str2, event = EventAccumulator(event_file, tf_size_guidance) event.Reload() # extract the reg/dyn0 values - y_event = event.Scalars(str1) + y_event = event.Scalars(str2) y = [s.value for s in y_event] x_int = [s.step for s in y_event] # the .step data are saved as ints in tensorboard, # so we will re-extact from 'task' # extract the corresponding 'task' values - x_event = event.Scalars(str2) + x_event = event.Scalars(str1) x = [s.value for s in x_event] # sanity check: if sanity_check: @@ -74,9 +74,10 @@ def curve_combined(event_files, colors, str1, str2, output_dir="."): plt.ylabel("loss") plt.title("timecourse") plt.legend([str1, str2]) - + str11 = str1.replace(os.sep, "_") + str22 = str2.replace(os.sep, "_") plt.savefig(os.path.join(output_dir, - f'timecourse_{str1}_{str2}.png'), dpi=300) + f'timecourse_{str11}_{str22}.png'), dpi=300) if __name__ == "__main__": From 673e14a1f9a75ef88d59c51e278648ffb5afb0cd Mon Sep 17 00:00:00 2001 From: Felix Drost Date: Tue, 24 Oct 2023 16:18:59 +0200 Subject: [PATCH 561/762] Added slurm runner script --- slurm_run_full_pacs.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 slurm_run_full_pacs.sh diff --git a/slurm_run_full_pacs.sh b/slurm_run_full_pacs.sh new file mode 100755 index 000000000..c0c2b38eb --- /dev/null +++ b/slurm_run_full_pacs.sh @@ -0,0 +1,27 @@ +JOB_NAME="fbopt_jigen" +PATH_OUT_BASE="/lustre/groups/imm01/workspace/felix.drost/fbopt_jigen/job_logs" +PATH_CODE="/lustre/groups/imm01/workspace/felix.drost/fbopt_jigen" + + +job_file="${PATH_OUT_BASE}/${JOB_NAME}.cmd" +echo "#!/bin/bash +#SBATCH -J ${JOB_NAME} +#SBATCH -o ${PATH_OUT_BASE}/${JOB_NAME}.out +#SBATCH -e ${PATH_OUT_BASE}/${JOB_NAME}.err +#SBATCH -p cpu_p +#SBATCH -t 2-00:00:00 +#SBATCH -c 20 +#SBATCH --mem=32G +#SBATCH --qos=cpu_normal +#SBATCH --no-requeue +#SBATCH --nice=10000 + +source ~/.bash_profile +conda activate fbopt + +${PATH_CODE}/run_benchmark_slurm.sh ${PATH_CODE}/examples/benchmark/pacs_jigen_fbopt_and_others.yaml 0 +" > ${job_file} +sbatch ${job_file} + + + From c23c4caf1afeecc9db36450b82dbc4d4fe897816 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 24 Oct 2023 16:27:28 +0200 Subject: [PATCH 562/762] clean --- slurm_run_full_pacs.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/slurm_run_full_pacs.sh b/slurm_run_full_pacs.sh index c0c2b38eb..6501cee0f 100755 --- a/slurm_run_full_pacs.sh +++ b/slurm_run_full_pacs.sh @@ -1,6 +1,8 @@ -JOB_NAME="fbopt_jigen" -PATH_OUT_BASE="/lustre/groups/imm01/workspace/felix.drost/fbopt_jigen/job_logs" -PATH_CODE="/lustre/groups/imm01/workspace/felix.drost/fbopt_jigen" +JOB_NAME="fbopt" +PATH_CODE="~/fbopt_jigen" +PATH_OUT_BASE="${PATH_CODE}/job_logs" +PATH_YAML=$2 +START_SEED=$3 job_file="${PATH_OUT_BASE}/${JOB_NAME}.cmd" @@ -17,11 +19,9 @@ echo "#!/bin/bash #SBATCH --nice=10000 source ~/.bash_profile +source ~/.bashrc conda activate fbopt -${PATH_CODE}/run_benchmark_slurm.sh ${PATH_CODE}/examples/benchmark/pacs_jigen_fbopt_and_others.yaml 0 +${PATH_CODE}/run_benchmark_slurm.sh ${PATH_CODE}/${PATH_YAML} ${START_SEED} " > ${job_file} sbatch ${job_file} - - - From 1c2d1bb15305b459036d0d07ac8380a43e43912e Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 24 Oct 2023 16:28:24 +0200 Subject: [PATCH 563/762] rename --- slurm_run_full_pacs.sh => submit_slurm_cpu.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename slurm_run_full_pacs.sh => submit_slurm_cpu.sh (100%) diff --git a/slurm_run_full_pacs.sh b/submit_slurm_cpu.sh similarity index 100% rename from slurm_run_full_pacs.sh rename to submit_slurm_cpu.sh From 1eac207bfdcade7dac1860c90ea96e6fb01ba998 Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:21:51 -0400 Subject: [PATCH 564/762] addresses https://github.com/marrlab/DomainLab/issues/582 --- .../utils/generate_fbopt_phase_portrait.py | 128 ++++++++++++++---- generate_all_figures_diva.sh | 33 +++++ 2 files changed, 133 insertions(+), 28 deletions(-) create mode 100755 generate_all_figures_diva.sh diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index e16300c60..43ead88a3 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -7,9 +7,9 @@ import EventAccumulator -def get_xy_from_event_file(event_file, str1, str2, +def get_xy_from_event_file(event_file, plot1, plot2=None, tf_size_guidance=None, - sanity_check=False): + sanity_check=False, verbose=True): if tf_size_guidance is None: # settings for which/how much data is loaded from the # tensorboard event files @@ -22,28 +22,41 @@ def get_xy_from_event_file(event_file, str1, str2, # load event file event = EventAccumulator(event_file, tf_size_guidance) event.Reload() - # extract the reg/dyn0 values - y_event = event.Scalars(str2) - y = [s.value for s in y_event] - x_int = [s.step for s in y_event] - # the .step data are saved as ints in tensorboard, - # so we will re-extact from 'task' - # extract the corresponding 'task' values - x_event = event.Scalars(str1) + # print names of available plots + if verbose: + print(f"Event file {event_file} -- available plots:") + print(event.Tags()['scalars']) + if plot2: + # extract the plot2 values (e.g., reg/dyn0) + y_event = event.Scalars(plot2) + y = [s.value for s in y_event] + x_int = [s.step for s in y_event] + # the .step data are saved as ints in tensorboard, + # (so, in case of phase portrait, we re-extact from 'task') + else: + y = None + # extract the corresponding plot1 values (e.g., 'task') + x_event = event.Scalars(plot1) x = [s.value for s in x_event] - # sanity check: + # sanity check (originally added for the reg/dyn0 vs. task phase portrait; + # shouldn't be needed if plot1 and plot2 represent something else): if sanity_check: for i in range(len(x)): assert int(x[i]) == x_int[i] return x, y -def phase_portrain_combined(event_files, colors, str1, str2, output_dir="."): +def phase_portrait_combined(event_files, colors, plot1, plot2, + label1=None, label2=None, output_dir="."): + """ + combined phase portait for multiple (at least one) Tensorboard + event files in the same plot + """ plt.figure() for event_i in range(len(event_files)): x, y = get_xy_from_event_file(event_files[event_i], - str1=str1, str2=str2) + plot1=plot1, plot2=plot2) assert len(x) == len(y) for i in range(len(x) - 1): @@ -55,43 +68,102 @@ def phase_portrain_combined(event_files, colors, str1, str2, output_dir="."): plt.plot(x[0], y[0], 'ko') plt.scatter(x, y, s=1, c='black') - plt.xlabel(str1) - plt.ylabel(str2) + if label1 is None: label1=plot1 + if label2 is None: label2=plot2 + plt.xlabel(label1) + plt.ylabel(label2) plt.title("phase portrait") + if not os.path.exists(output_dir): + os.makedirs(output_dir) + label22 = label2.split(os.sep)[-1] plt.savefig(os.path.join(output_dir, - 'phase_portrain_combined.png'), dpi=300) + f'phase_portrait_combined_{label22}.png'), dpi=300) -def curve_combined(event_files, colors, str1, str2, output_dir="."): +def two_curves_combined(event_files, colors, plot1, plot2, + label1=None, label2=None, output_dir="."): + """ + FIXME: colors parameter is not used + """ plt.figure() for event_i in range(len(event_files)): x, y = get_xy_from_event_file(event_files[event_i], - str1=str1, str2=str2) + plot1=plot1, plot2=plot2) plt.plot(x) plt.plot(y) plt.xlabel("time") plt.ylabel("loss") plt.title("timecourse") - plt.legend([str1, str2]) - str11 = str1.replace(os.sep, "_") - str22 = str2.replace(os.sep, "_") + if label1 is None: label1=plot1 + if label2 is None: label2=plot2 + plt.legend([label1, label2]) + + label11 = label1.replace(os.sep, "_") + label22 = label2.replace(os.sep, "_") + + if not os.path.exists(output_dir): + os.makedirs(output_dir) + plt.savefig(os.path.join(output_dir, + f'timecourse_{label11}_{label22}.png'), dpi=300) + + +def curves_combined(event_files, colors, plot1, label1=None, output_dir="."): + """ + FIXME: colors parameter is not used + """ + plt.figure() + for event_i in range(len(event_files)): + x, _ = get_xy_from_event_file(event_files[event_i], plot1=plot1) + plt.plot(x) + plt.xlabel("time") + if label1 is None: label1=plot1 + plt.ylabel(label1) + plt.title("timecourse") + + label11 = label1.replace(os.sep, "_") + + if not os.path.exists(output_dir): + os.makedirs(output_dir) plt.savefig(os.path.join(output_dir, - f'timecourse_{str11}_{str22}.png'), dpi=300) + f'timecourse_{label11}.png'), dpi=300) if __name__ == "__main__": parser = argparse.ArgumentParser(description='plot') - parser.add_argument('-str1', "--str1", default=None, type=str) - parser.add_argument('-str2', "--str2", default=None, type=str) + parser.add_argument('-plot1', "--plot1", default=None, type=str) + parser.add_argument('-plot2', "--plot2", default=None, type=str) + parser.add_argument('-label1', "--label1", default=None, type=str) + parser.add_argument('-label2', "--label2", default=None, type=str) + parser.add_argument('--output_dir', default='.', type=str) + parser.add_argument('--phase_portrait', action='store_true', + help="if True plots a phase portrait,\ + otherwise a curve (default)") args = parser.parse_args() + # get event files from all available runs event_files = glob.glob("runs/*/events*") print("Using the following tensorboard event files:\n{}".format( "\n".join(event_files))) + + # Different colors for the different runs cmap = plt.get_cmap('tab10') # Choose a colormap colors = [cmap(i) for i in range(len(event_files))] - # Different colors for the different runs - phase_portrain_combined(event_files, colors, - str1=args.str1, str2=args.str2) - curve_combined(event_files, colors, str1=args.str1, str2=args.str2) + + if args.phase_portrait: + phase_portrait_combined(event_files, colors, + plot1=args.plot1, plot2=args.plot2, + label1=args.label1, label2=args.label2, + output_dir=args.output_dir) + else: + if args.plot2: + # two curves per plot + two_curves_combined(event_files, colors, + plot1=args.plot1, plot2=args.plot2, + label1=args.label1, label2=args.label2, + output_dir=args.output_dir) + else: + # one curve per plot + curves_combined(event_files, colors, + plot1=args.plot1, label1=args.label1, + output_dir=args.output_dir) diff --git a/generate_all_figures_diva.sh b/generate_all_figures_diva.sh new file mode 100755 index 000000000..2161f671c --- /dev/null +++ b/generate_all_figures_diva.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Phase portraits +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dyngamma_d" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dyngamma_d" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynmu_recon" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dynmu_recon" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_d" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_d" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_x" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_x" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_y" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_y" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait + + +# Plot R and the corresponding set point curves (both in the same figure) +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --label1="loss dynamic corresponding to multiplier dyn_gamma_d" --label2="corresponding setpoint_gamma_d" --output_dir="./figures_diva" + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --label1="loss dynamic corresponding to multiplier dyn_mu_recon" --label2="corresponding setpoint_mu_recon" --output_dir="./figures_diva" + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --label1="loss dynamic corresponding to multiplier dyn_beta_d" --label2="corresponding setpoint_beta_d" --output_dir="./figures_diva" + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --label1="loss dynamic corresponding to multiplier dyn_beta_x" --label2="corresponding setpoint_beta_x" --output_dir="./figures_diva" + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --label1="loss dynamic corresponding to multiplier dyn_beta_y" --label2="corresponding setpoint_beta_y" --output_dir="./figures_diva" + + +# Other plots (one curve per figure) +values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_x' 'controller_gain/gamma_d' 'controller_gain/mu_recon' 'dyn_mu/beta_d' 'delta/beta_d' 'dyn_mu/beta_y' 'delta/beta_y' 'dyn_mu/beta_x' 'delta/beta_x' 'dyn_mu/gamma_d' 'delta/gamma_d' 'dyn_mu/mu_recon' 'delta/mu_recon' 'loss_task/penalized' 'loss_task/ell' 'acc/te' 'acc/val' 'acc/sel' 'acc/setpoint') +# Loop over the array +for val in "${values[@]}" +do + python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="$val" --label1="$val" --output_dir="./figures_diva" +done From 46fd90b1f10acc7662164419b431d44c99c7b9ba Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 09:54:35 +0200 Subject: [PATCH 565/762] update pacs diva yaml --- .../benchmark/pacs_diva_fbopt_and_others.yaml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_others.yaml index c82d3e58c..f18cf72a7 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_others.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_others.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_others +output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_baselines sampling_seed: 0 @@ -63,20 +63,27 @@ Shared params: num: 3 distribution: loguniform - + mu_clip: + distribution: categorical + datatype: float + values: + - 1 + - 10 + - 100 + - 1000 # Test fbopt with different hyperparameter configurations - -diva_fbopt_full: +diva_fbopt_a: aname: diva trainer: fbopt - str_diva_multiplier_type: gammad_recon gamma_y: 1.0 ini_setpoint_ratio: 0.99 - mu_clip: 1.0 + str_diva_multiplier_type: gammad_recon + coeff_ma_output_state: 0.1 mu_init: 1e-6 shared: - k_i_gain + - mu_clip diva_feedforward_full: aname: diva From 11f53689c7efeed898799a51c8dec025bc3272bf Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 10:43:01 +0200 Subject: [PATCH 566/762] refine --- submit_slurm_cpu.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/submit_slurm_cpu.sh b/submit_slurm_cpu.sh index 6501cee0f..4eb35437f 100755 --- a/submit_slurm_cpu.sh +++ b/submit_slurm_cpu.sh @@ -1,5 +1,7 @@ JOB_NAME="fbopt" -PATH_CODE="~/fbopt_jigen" +VENV="domainlab_py39" +BASHRC="~/.bashrc" # source ~/.bash_profile +PATH_CODE=$1 PATH_OUT_BASE="${PATH_CODE}/job_logs" PATH_YAML=$2 START_SEED=$3 @@ -18,9 +20,8 @@ echo "#!/bin/bash #SBATCH --no-requeue #SBATCH --nice=10000 -source ~/.bash_profile -source ~/.bashrc -conda activate fbopt +source ${BASHRC} +conda activate ${VENV} ${PATH_CODE}/run_benchmark_slurm.sh ${PATH_CODE}/${PATH_YAML} ${START_SEED} " > ${job_file} From a15ed3da09313fa8f07d7e54a009ef808c0f19e2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 10:47:44 +0200 Subject: [PATCH 567/762] rename file --- submit_slurm_cpu.sh => sbatch4submit_slurm_cpu_node.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename submit_slurm_cpu.sh => sbatch4submit_slurm_cpu_node.sh (100%) diff --git a/submit_slurm_cpu.sh b/sbatch4submit_slurm_cpu_node.sh similarity index 100% rename from submit_slurm_cpu.sh rename to sbatch4submit_slurm_cpu_node.sh From 0b6ca04dd1aa20f9f90a3584ef7607c233d16b76 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 10:52:26 +0200 Subject: [PATCH 568/762] two files one call the other --- sbatch4submit_slurm_cpu_node.sh | 5 ++++- submit_slurm_via_cpu_node.sh | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 submit_slurm_via_cpu_node.sh diff --git a/sbatch4submit_slurm_cpu_node.sh b/sbatch4submit_slurm_cpu_node.sh index 4eb35437f..ddc8eb72f 100755 --- a/sbatch4submit_slurm_cpu_node.sh +++ b/sbatch4submit_slurm_cpu_node.sh @@ -1,6 +1,9 @@ -JOB_NAME="fbopt" +# change the following two lines if needed VENV="domainlab_py39" BASHRC="~/.bashrc" # source ~/.bash_profile + +## +JOB_NAME="fbopt" PATH_CODE=$1 PATH_OUT_BASE="${PATH_CODE}/job_logs" PATH_YAML=$2 diff --git a/submit_slurm_via_cpu_node.sh b/submit_slurm_via_cpu_node.sh new file mode 100644 index 000000000..fbc6a733f --- /dev/null +++ b/submit_slurm_via_cpu_node.sh @@ -0,0 +1,3 @@ +DIR=$(pwd) +echo $DIR +bash ./sbatch4submit_slurm_cpu_node.sh $DIR $1 $2 From 626670365d8445ef8f51afcc9467af8aed2fd617 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 11:03:11 +0200 Subject: [PATCH 569/762] yaml with scientitic notation, decrease ki --- examples/benchmark/mnist_diva_fbopt_alone.yaml | 4 ++-- examples/benchmark/mnist_diva_fbopt_and_baselines.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/mnist_diva_fbopt_alone.yaml b/examples/benchmark/mnist_diva_fbopt_alone.yaml index 79078a21f..bfd2e857a 100644 --- a/examples/benchmark/mnist_diva_fbopt_alone.yaml +++ b/examples/benchmark/mnist_diva_fbopt_alone.yaml @@ -40,8 +40,8 @@ Shared params: distribution: uniform k_i_gain: - min: 0.0001 - max: 0.01 + min: 1e-4 + max: 1e-3 num: 2 distribution: loguniform diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index 9af193f46..e8d9458f2 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -40,8 +40,8 @@ Shared params: distribution: uniform k_i_gain: - min: 0.0001 - max: 0.01 + min: 1e-4 + max: 1e-3 num: 2 distribution: loguniform From cdda26ea1c068ded8b0e24fff8043d11999ae1ae Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 11:05:54 +0200 Subject: [PATCH 570/762] mkdir --- sbatch4submit_slurm_cpu_node.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sbatch4submit_slurm_cpu_node.sh b/sbatch4submit_slurm_cpu_node.sh index ddc8eb72f..9c61cc92f 100755 --- a/sbatch4submit_slurm_cpu_node.sh +++ b/sbatch4submit_slurm_cpu_node.sh @@ -6,6 +6,7 @@ BASHRC="~/.bashrc" # source ~/.bash_profile JOB_NAME="fbopt" PATH_CODE=$1 PATH_OUT_BASE="${PATH_CODE}/job_logs" +mkdir $PATH_OUT_BASE PATH_YAML=$2 START_SEED=$3 From 6f201c5d64b83a395d8cd5c75396365ed95c7b24 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 11:51:55 +0200 Subject: [PATCH 571/762] script jigen plot --- script_jigen_plot.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 script_jigen_plot.sh diff --git a/script_jigen_plot.sh b/script_jigen_plot.sh new file mode 100644 index 000000000..ad8e4c325 --- /dev/null +++ b/script_jigen_plot.sh @@ -0,0 +1,5 @@ +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_ +alpha" --plot1="loss_task/ell" --label2="regularization loss jigen" --label1="classification loss" --output_dir="." --phase_portrait + + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_alpha" --plot1="lossrs/setpoint_alpha" --label2="regularization loss jigen" --label1="setpoint" --output_dir="." From 54f17e56a232df3f87084d8351a9e1044e525e62 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 25 Oct 2023 13:54:18 +0200 Subject: [PATCH 572/762] Rename pacs_jigen_fbopt_and_others.yaml to pacs_jigen_fbopt_and_baselines.yaml --- ..._fbopt_and_others.yaml => pacs_jigen_fbopt_and_baselines.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{pacs_jigen_fbopt_and_others.yaml => pacs_jigen_fbopt_and_baselines.yaml} (100%) diff --git a/examples/benchmark/pacs_jigen_fbopt_and_others.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml similarity index 100% rename from examples/benchmark/pacs_jigen_fbopt_and_others.yaml rename to examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml From 43072a1bf8950bbc49daed71f7e98bcc4b1b9feb Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 25 Oct 2023 13:55:28 +0200 Subject: [PATCH 573/762] Rename pacs_diva_fbopt_and_others.yaml to pacs_diva_fbopt_and_baselines.yaml --- ...a_fbopt_and_others.yaml => pacs_diva_fbopt_and_baselines.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{pacs_diva_fbopt_and_others.yaml => pacs_diva_fbopt_and_baselines.yaml} (100%) diff --git a/examples/benchmark/pacs_diva_fbopt_and_others.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml similarity index 100% rename from examples/benchmark/pacs_diva_fbopt_and_others.yaml rename to examples/benchmark/pacs_diva_fbopt_and_baselines.yaml From 22c9672d08dcaedbcc71c21d928f0d97680df214 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Wed, 25 Oct 2023 14:19:22 +0200 Subject: [PATCH 574/762] Update mnist_jigen_fbopt_and_others.yaml --- .../mnist_jigen_fbopt_and_others.yaml | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/examples/benchmark/mnist_jigen_fbopt_and_others.yaml b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml index 88dbd1ff5..a9e2cbe41 100644 --- a/examples/benchmark/mnist_jigen_fbopt_and_others.yaml +++ b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml @@ -15,14 +15,12 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 500 - es: 100 + epos: 2000 + epos_min: 100 + es: 1 bs: 64 nname: conv_bn_pool_2 san_check: False - exp_shoulder_clip: 10 - mu_clip: 10 - coeff_ma: 0.5 no_tensorboard: False pperm: 0.5 @@ -30,8 +28,8 @@ domainlab_args: Shared params: k_i_gain: - min: 0.0001 - max: 0.01 + min: 1e-4 + max: 1e-3 num: 2 distribution: uniform @@ -43,8 +41,14 @@ Shared params: gamma_reg: min: 0.01 - max: 10_000 - num: 10 + max: 1e4 + num: 3 + distribution: loguniform + + mu_clip: + min: 0.01 + max: 1e4 + num: 3 distribution: loguniform @@ -55,9 +59,10 @@ jigen_feedback: aname: jigen trainer: fbopt ini_setpoint_ratio: 0.99 + mu_init: 1e-6 shared: - k_i_gain - - mu_init + - mu_clip jigen_feedforward: aname: jigen From ff0faa0296fd7ac27104163f1b7a7b93702e2d58 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 14:36:09 +0200 Subject: [PATCH 575/762] remove snakemake fodler --- submit_slurm_via_cpu_node.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/submit_slurm_via_cpu_node.sh b/submit_slurm_via_cpu_node.sh index fbc6a733f..55230fa6a 100644 --- a/submit_slurm_via_cpu_node.sh +++ b/submit_slurm_via_cpu_node.sh @@ -1,3 +1,4 @@ +rm -f -R ./snakemake DIR=$(pwd) echo $DIR bash ./sbatch4submit_slurm_cpu_node.sh $DIR $1 $2 From ecd1a1bb608d881b786d8909044a24253ad8b19f Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 14:37:06 +0200 Subject: [PATCH 576/762] renove snakemake --- run_benchmark_slurm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/run_benchmark_slurm.sh b/run_benchmark_slurm.sh index 3294c1b10..4c62f86c5 100755 --- a/run_benchmark_slurm.sh +++ b/run_benchmark_slurm.sh @@ -19,4 +19,5 @@ echo "Configuration file: $CONFIGFILE" echo "starting seed is: $DOMAINLAB_CUDA_START_SEED" echo "verbose log: $logfile" # Helmholtz +rm -f -R ./snakemake snakemake --profile "examples/yaml/slurm" --keep-going --keep-incomplete --notemp --cores 3 -s "domainlab/exp_protocol/benchmark.smk" --configfile "$CONFIGFILE" 2>&1 | tee "$logfile" From f7732ff61e73b5fa90342cb152a5c462d2442633 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 14:51:11 +0200 Subject: [PATCH 577/762] mkdir -p --- sbatch4submit_slurm_cpu_node.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbatch4submit_slurm_cpu_node.sh b/sbatch4submit_slurm_cpu_node.sh index 9c61cc92f..5afb7a1aa 100755 --- a/sbatch4submit_slurm_cpu_node.sh +++ b/sbatch4submit_slurm_cpu_node.sh @@ -6,7 +6,7 @@ BASHRC="~/.bashrc" # source ~/.bash_profile JOB_NAME="fbopt" PATH_CODE=$1 PATH_OUT_BASE="${PATH_CODE}/job_logs" -mkdir $PATH_OUT_BASE +mkdir -p $PATH_OUT_BASE PATH_YAML=$2 START_SEED=$3 From dfd64cc383b18338ca26da942f796bee014d026e Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 25 Oct 2023 14:59:56 +0200 Subject: [PATCH 578/762] fix typo --- run_benchmark_slurm.sh | 2 +- submit_slurm_via_cpu_node.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/run_benchmark_slurm.sh b/run_benchmark_slurm.sh index 4c62f86c5..52c13151e 100755 --- a/run_benchmark_slurm.sh +++ b/run_benchmark_slurm.sh @@ -19,5 +19,5 @@ echo "Configuration file: $CONFIGFILE" echo "starting seed is: $DOMAINLAB_CUDA_START_SEED" echo "verbose log: $logfile" # Helmholtz -rm -f -R ./snakemake +rm -f -R .snakemake snakemake --profile "examples/yaml/slurm" --keep-going --keep-incomplete --notemp --cores 3 -s "domainlab/exp_protocol/benchmark.smk" --configfile "$CONFIGFILE" 2>&1 | tee "$logfile" diff --git a/submit_slurm_via_cpu_node.sh b/submit_slurm_via_cpu_node.sh index 55230fa6a..664988c03 100644 --- a/submit_slurm_via_cpu_node.sh +++ b/submit_slurm_via_cpu_node.sh @@ -1,4 +1,4 @@ -rm -f -R ./snakemake +rm -f -R .snakemake DIR=$(pwd) echo $DIR bash ./sbatch4submit_slurm_cpu_node.sh $DIR $1 $2 From 04835468b723b89eb867b85f7b50845894396bf4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 09:44:38 +0200 Subject: [PATCH 579/762] gen plot --- sh_genplot.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh_genplot.sh b/sh_genplot.sh index 93c4cdbda..a1b1ecfad 100644 --- a/sh_genplot.sh +++ b/sh_genplot.sh @@ -1 +1,2 @@ -python main_out.py --gen_plots $1 --outp_dir . +mkdir $2 +python main_out.py --gen_plots $1 --outp_dir $2 From 45da629c52af57f9cd39a11b37d82ab221c8fdbd Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 10:17:51 +0200 Subject: [PATCH 580/762] typo in code --- domainlab/algos/trainers/fbopt_mu_controller.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index e7e685960..3032e274a 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -60,7 +60,7 @@ def __init__(self, trainer, **kwargs): self.writer = SummaryWriter(comment=str_job_id) self.coeff_ma = trainer.aconf.coeff_ma - def get_setpoing4r(self): + def get_setpoint4r(self): """ get setpoint list """ @@ -124,7 +124,7 @@ def cal_activation(self): """ calculate activation on exponential shoulder """ - setpoint = self.get_setpoing4r() + setpoint = self.get_setpoint4r() activation = [self.k_i_control * val if setpoint[i] > 0 else self.k_i_control * (-val) for i, val in enumerate(self.delta_epsilon_r)] @@ -148,7 +148,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, logger.info(f"before controller: current mu: {self.mmu}") logger.info(f"epo reg loss: {epo_reg_loss}") logger.info(f"name reg loss:{list_str_multiplier_na}") - self.cal_delta4control(epo_reg_loss, self.get_setpoing4r()) + self.cal_delta4control(epo_reg_loss, self.get_setpoint4r()) activation = self.cal_activation() # overshoot handling activation = self.tackle_overshoot( @@ -169,7 +169,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, self.writer.add_scalar( f'delta/{key}', self.delta_epsilon_r[ind], miter) for i, (reg_dyn, reg_set) in \ - enumerate(zip(epo_reg_loss, self.get_setpoing4r())): + enumerate(zip(epo_reg_loss, self.get_setpoint4r())): self.writer.add_scalar( f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) self.writer.add_scalar( From 46328ee02ea7284e3768d43550e43a9562d8cc84 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 11:04:38 +0200 Subject: [PATCH 581/762] set k_i_control to 50% of initial saturation value --- domainlab/algos/trainers/fbopt_mu_controller.py | 11 +++++++++++ domainlab/algos/trainers/train_fbopt_b.py | 1 + 2 files changed, 12 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 3032e274a..c6ff027d2 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -48,6 +48,7 @@ def __init__(self, trainer, **kwargs): args=self.trainer.aconf) self.k_i_control = trainer.aconf.k_i_gain + self.k_i_gain_ratio = None self.overshoot_rewind = trainer.aconf.overshoot_rewind == "yes" self.delta_epsilon_r = None # NOTE: this value will be set according to initial evaluation of @@ -60,6 +61,16 @@ def __init__(self, trainer, **kwargs): self.writer = SummaryWriter(comment=str_job_id) self.coeff_ma = trainer.aconf.coeff_ma + def set_k_i_gain(self): + if self.k_i_gain_ratio is None: + return + k_i_gain_saturate = [a/b \ + for a, b in zip(self.activation_clip, self.delta_epsilon_r)] + k_i_gain_saturate_min = min(k_i_gain_saturate) + # NOTE: here we override the commandline arguments specification + # for k_i_control, so k_i_control is not a hyperparameter anymore + self.k_i_control = 0.5 * k_i_gain_saturate_min # FIXME + def get_setpoint4r(self): """ get setpoint list diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 9bc64785e..f28bdc626 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -93,6 +93,7 @@ def before_tr(self): [ele * self.aconf.ini_setpoint_ratio if ele > 0 else ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) # setpoing w.r.t. random initialization of neural network + self.hyper_scheduler.set_k_i_gain() @property def list_str_multiplier_na(self): From 91c61c9a0ebe31366ea55467b10fc325c90d9251 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 11:22:50 +0200 Subject: [PATCH 582/762] hyperparameter k_i_gain_ratio to replace k_i_gain --- domainlab/algos/trainers/args_fbopt.py | 4 ++++ domainlab/algos/trainers/fbopt_mu_controller.py | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index e108c3fd2..f966d076b 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -11,6 +11,10 @@ def add_args2parser_fbopt(parser): parser.add_argument('--k_i_gain', type=float, default=0.001, help='PID control gain for integrator') + parser.add_argument('--k_i_gain_ratio', type=float, default=None, + help='set k_i_gain to be ratio of \ + initial saturation k_i_gain') + parser.add_argument('--mu_clip', type=float, default=1e4, help='maximum value of mu') diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index c6ff027d2..113dc8132 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -61,15 +61,24 @@ def __init__(self, trainer, **kwargs): self.writer = SummaryWriter(comment=str_job_id) self.coeff_ma = trainer.aconf.coeff_ma - def set_k_i_gain(self): + def set_k_i_gain(self, epo_reg_loss): if self.k_i_gain_ratio is None: return - k_i_gain_saturate = [a/b \ - for a, b in zip(self.activation_clip, self.delta_epsilon_r)] + # NOTE: do not use self.cal_delta4control!!!! which will change + # class member variables self.delta_epsilon_r! + list_setpoint = self.get_setpoint4r() + if_list_sign_agree(epo_reg_loss, list_setpoint) + delta_epsilon_r = [a - b for a, b in zip(epo_reg_loss, list_setpoint)] + + # to calculate self.delta_epsilon_r + k_i_gain_saturate = [a / b for a, b in + zip(self.activation_clip, delta_epsilon_r)] k_i_gain_saturate_min = min(k_i_gain_saturate) # NOTE: here we override the commandline arguments specification # for k_i_control, so k_i_control is not a hyperparameter anymore - self.k_i_control = 0.5 * k_i_gain_saturate_min # FIXME + self.k_i_control = self.k_i_gain_ratio * k_i_gain_saturate_min + # FIXME: change this to 1-self.ini_setpoint_ratio, i.e. the more + # difficult the initial setpoint is, the bigger the k_i_gain should be def get_setpoint4r(self): """ From b1ea31ba6774b89dc388cc6a458cc42fa57ff57e Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 11:33:48 +0200 Subject: [PATCH 583/762] fill in pars for function --- domainlab/algos/trainers/train_fbopt_b.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index f28bdc626..d08e45216 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -93,7 +93,7 @@ def before_tr(self): [ele * self.aconf.ini_setpoint_ratio if ele > 0 else ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], self.epo_task_loss_tr) # setpoing w.r.t. random initialization of neural network - self.hyper_scheduler.set_k_i_gain() + self.hyper_scheduler.set_k_i_gain(self.epo_reg_loss_tr) @property def list_str_multiplier_na(self): From c58d092b97459041e870f228333d53e3ffbe9c4d Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 11:36:41 +0200 Subject: [PATCH 584/762] script for test --- run_fbopt_mnist_diva_autoki.sh | 7 +++++++ run_fbopt_mnist_jigen_autoki.sh | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 run_fbopt_mnist_diva_autoki.sh create mode 100644 run_fbopt_mnist_jigen_autoki.sh diff --git a/run_fbopt_mnist_diva_autoki.sh b/run_fbopt_mnist_diva_autoki.sh new file mode 100644 index 000000000..98d1fbe94 --- /dev/null +++ b/run_fbopt_mnist_diva_autoki.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py + +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=500 --mu_init=0.000001 --gamma_y=1.0 --k_i_gain_ratio=0.5 diff --git a/run_fbopt_mnist_jigen_autoki.sh b/run_fbopt_mnist_jigen_autoki.sh new file mode 100644 index 000000000..f11dfd5a3 --- /dev/null +++ b/run_fbopt_mnist_jigen_autoki.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py + +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 --k_i_gain_ratio=0.5 From f56bfd7f6a9c1143970fdae0057e531b535f690f Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 11:39:55 +0200 Subject: [PATCH 585/762] print new k_i_gain --- domainlab/algos/trainers/fbopt_mu_controller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 113dc8132..a85ef3bee 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -2,6 +2,7 @@ update hyper-parameters during training """ import os +import warnings from torch.utils.tensorboard import SummaryWriter @@ -77,6 +78,8 @@ def set_k_i_gain(self, epo_reg_loss): # NOTE: here we override the commandline arguments specification # for k_i_control, so k_i_control is not a hyperparameter anymore self.k_i_control = self.k_i_gain_ratio * k_i_gain_saturate_min + warnings.warn(f"hyperparameter k_i_gain disabled! \ + replace with {self.k_i_control}") # FIXME: change this to 1-self.ini_setpoint_ratio, i.e. the more # difficult the initial setpoint is, the bigger the k_i_gain should be From a35261d1741bd9cb4c3798db0443540769dbb291 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 12:31:50 +0200 Subject: [PATCH 586/762] benchmark auto ki --- .../pacs_jigen_fbopt_alone_autoki.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml new file mode 100644 index 000000000..411800cda --- /dev/null +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -0,0 +1,79 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_jigen_fbopt_alone + +sampling_seed: 0 + +startseed: 0 +endseed: 3 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 200 + epos_min: 20 + es: 1 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + pperm: 0.5 + + +Shared params: + k_i_gain: + min: 0.0001 + max: 0.01 + num: 3 + distribution: loguniform + + k_i_gain_ratio: + min: 0.1 + max: 0.9 + num: 8 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00005 + num: 3 + distribution: loguniform + + pperm: + min: 0.1 + max: 0.9 + num: 3 + distribution: uniform + + gamma_reg: + min: 0.01 + max: 10_000 + num: 10 + distribution: loguniform + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + - 0.9 + +# Test fbopt with different hyperparameter configurations + +jigen_feedback: + aname: jigen + trainer: fbopt + ini_setpoint_ratio: 0.99 + + shared: + - k_i_gain_ratio From 22c391fc346b23498fb48f5aa22720003c818972 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 12:35:17 +0200 Subject: [PATCH 587/762] change duration from 2 to 3 days --- sbatch4submit_slurm_cpu_node.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbatch4submit_slurm_cpu_node.sh b/sbatch4submit_slurm_cpu_node.sh index 5afb7a1aa..cc7b7611d 100755 --- a/sbatch4submit_slurm_cpu_node.sh +++ b/sbatch4submit_slurm_cpu_node.sh @@ -17,7 +17,7 @@ echo "#!/bin/bash #SBATCH -o ${PATH_OUT_BASE}/${JOB_NAME}.out #SBATCH -e ${PATH_OUT_BASE}/${JOB_NAME}.err #SBATCH -p cpu_p -#SBATCH -t 2-00:00:00 +#SBATCH -t 3-00:00:00 #SBATCH -c 20 #SBATCH --mem=32G #SBATCH --qos=cpu_normal From f899cd0b6a26743b44be01a5c8858c4070020de4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 14:40:58 +0200 Subject: [PATCH 588/762] separate script for different lengh queue --- sbatch4submit_slurm_cpu_10days.sh | 32 +++++++++++++++++++ ...ode.sh => sbatch4submit_slurm_cpu_3days.sh | 2 +- submit_slurm_via_cpu_10days.sh | 4 +++ submit_slurm_via_cpu_3days.sh | 4 +++ submit_slurm_via_cpu_node.sh | 4 --- 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100755 sbatch4submit_slurm_cpu_10days.sh rename sbatch4submit_slurm_cpu_node.sh => sbatch4submit_slurm_cpu_3days.sh (97%) create mode 100644 submit_slurm_via_cpu_10days.sh create mode 100644 submit_slurm_via_cpu_3days.sh delete mode 100644 submit_slurm_via_cpu_node.sh diff --git a/sbatch4submit_slurm_cpu_10days.sh b/sbatch4submit_slurm_cpu_10days.sh new file mode 100755 index 000000000..1d5bb4db0 --- /dev/null +++ b/sbatch4submit_slurm_cpu_10days.sh @@ -0,0 +1,32 @@ +# change the following two lines if needed +VENV="domainlab_py39" +BASHRC="~/.bashrc" # source ~/.bash_profile + +## +JOB_NAME="domainlab" +PATH_CODE=$1 +PATH_OUT_BASE="${PATH_CODE}/job_logs" +mkdir -p $PATH_OUT_BASE +PATH_YAML=$2 +START_SEED=$3 + + +job_file="${PATH_OUT_BASE}/${JOB_NAME}.cmd" +echo "#!/bin/bash +#SBATCH -J ${JOB_NAME} +#SBATCH -o ${PATH_OUT_BASE}/${JOB_NAME}.out +#SBATCH -e ${PATH_OUT_BASE}/${JOB_NAME}.err +#SBATCH -p cpu_p +#SBATCH -t 10-00:00:00 +#SBATCH -c 20 +#SBATCH --mem=32G +#SBATCH --qos=cpu_long +#SBATCH --no-requeue +#SBATCH --nice=10000 + +source ${BASHRC} +conda activate ${VENV} + +${PATH_CODE}/run_benchmark_slurm.sh ${PATH_CODE}/${PATH_YAML} ${START_SEED} +" > ${job_file} +sbatch ${job_file} diff --git a/sbatch4submit_slurm_cpu_node.sh b/sbatch4submit_slurm_cpu_3days.sh similarity index 97% rename from sbatch4submit_slurm_cpu_node.sh rename to sbatch4submit_slurm_cpu_3days.sh index cc7b7611d..7e46869cd 100755 --- a/sbatch4submit_slurm_cpu_node.sh +++ b/sbatch4submit_slurm_cpu_3days.sh @@ -3,7 +3,7 @@ VENV="domainlab_py39" BASHRC="~/.bashrc" # source ~/.bash_profile ## -JOB_NAME="fbopt" +JOB_NAME="domainlab" PATH_CODE=$1 PATH_OUT_BASE="${PATH_CODE}/job_logs" mkdir -p $PATH_OUT_BASE diff --git a/submit_slurm_via_cpu_10days.sh b/submit_slurm_via_cpu_10days.sh new file mode 100644 index 000000000..eada249b4 --- /dev/null +++ b/submit_slurm_via_cpu_10days.sh @@ -0,0 +1,4 @@ +rm -f -R .snakemake +DIR=$(pwd) +echo $DIR +bash ./sbatch4submit_slurm_cpu_10days.sh $DIR $1 $2 diff --git a/submit_slurm_via_cpu_3days.sh b/submit_slurm_via_cpu_3days.sh new file mode 100644 index 000000000..adff5e0a5 --- /dev/null +++ b/submit_slurm_via_cpu_3days.sh @@ -0,0 +1,4 @@ +rm -f -R .snakemake +DIR=$(pwd) +echo $DIR +bash ./sbatch4submit_slurm_cpu_3days.sh $DIR $1 $2 diff --git a/submit_slurm_via_cpu_node.sh b/submit_slurm_via_cpu_node.sh deleted file mode 100644 index 664988c03..000000000 --- a/submit_slurm_via_cpu_node.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm -f -R .snakemake -DIR=$(pwd) -echo $DIR -bash ./sbatch4submit_slurm_cpu_node.sh $DIR $1 $2 From 2b878a26a3ccc16e2a29d1c5606b287eb95da08d Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 14:50:03 +0200 Subject: [PATCH 589/762] es1 --- run_fbopt_mnist_diva_autoki.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist_diva_autoki.sh b/run_fbopt_mnist_diva_autoki.sh index 98d1fbe94..dee4712ff 100644 --- a/run_fbopt_mnist_diva_autoki.sh +++ b/run_fbopt_mnist_diva_autoki.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=500 --mu_init=0.000001 --gamma_y=1.0 --k_i_gain_ratio=0.5 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=1 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 From 8881fe79579ea12ec98529403de180591d197485 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 15:10:07 +0200 Subject: [PATCH 590/762] yaml --- examples/benchmark/pacs_jigen_fbopt_alone.yaml | 8 +++----- run_fbopt_mnist_diva_autoki.sh | 2 +- run_fbopt_mnist_jigen_autoki.sh | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone.yaml b/examples/benchmark/pacs_jigen_fbopt_alone.yaml index 5dad6b291..bc32a6771 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone.yaml @@ -15,7 +15,8 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - es: 5 + epos_min: 20 + es: 1 bs: 64 san_check: False npath: examples/nets/resnet50domainbed.py @@ -67,11 +68,8 @@ jigen_feedback: aname: jigen trainer: fbopt ini_setpoint_ratio: 0.99 - exp_shoulder_clip: 10 - mu_clip: 10_000 coeff_ma: 0.5 - + mu_init: 1e-6 shared: - k_i_gain - - mu_init - coeff_ma_output_state diff --git a/run_fbopt_mnist_diva_autoki.sh b/run_fbopt_mnist_diva_autoki.sh index dee4712ff..f07caab3f 100644 --- a/run_fbopt_mnist_diva_autoki.sh +++ b/run_fbopt_mnist_diva_autoki.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=1 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 diff --git a/run_fbopt_mnist_jigen_autoki.sh b/run_fbopt_mnist_jigen_autoki.sh index f11dfd5a3..8cddf4d58 100644 --- a/run_fbopt_mnist_jigen_autoki.sh +++ b/run_fbopt_mnist_jigen_autoki.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 --k_i_gain_ratio=0.5 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=1 --mu_init=1e-6 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 --k_i_gain_ratio=0.9 From 5568e2f1db496ac58b8c920b1dce0e03158d1b8b Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 15:52:27 +0200 Subject: [PATCH 591/762] do not use title in plot --- domainlab/utils/generate_fbopt_phase_portrait.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 43ead88a3..a6067c495 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -94,7 +94,7 @@ def two_curves_combined(event_files, colors, plot1, plot2, plt.plot(y) plt.xlabel("time") plt.ylabel("loss") - plt.title("timecourse") + # plt.title("timecourse") if label1 is None: label1=plot1 if label2 is None: label2=plot2 plt.legend([label1, label2]) @@ -119,7 +119,7 @@ def curves_combined(event_files, colors, plot1, label1=None, output_dir="."): plt.xlabel("time") if label1 is None: label1=plot1 plt.ylabel(label1) - plt.title("timecourse") + # plt.title("timecourse") label11 = label1.replace(os.sep, "_") From 2c107212f0605398235cb19df711b7f92ae639f3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 16:28:39 +0200 Subject: [PATCH 592/762] refine --- domainlab/utils/generate_fbopt_phase_portrait.py | 14 ++++++++------ ..._diva.sh => script_generate_all_figures_diva.sh | 0 2 files changed, 8 insertions(+), 6 deletions(-) rename generate_all_figures_diva.sh => script_generate_all_figures_diva.sh (100%) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index a6067c495..db7418602 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -82,7 +82,7 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, def two_curves_combined(event_files, colors, plot1, plot2, - label1=None, label2=None, output_dir="."): + label1=None, label2=None, output_dir=".", title=None): """ FIXME: colors parameter is not used """ @@ -94,7 +94,8 @@ def two_curves_combined(event_files, colors, plot1, plot2, plt.plot(y) plt.xlabel("time") plt.ylabel("loss") - # plt.title("timecourse") + if title is not None: + plt.title(title) if label1 is None: label1=plot1 if label2 is None: label2=plot2 plt.legend([label1, label2]) @@ -108,7 +109,7 @@ def two_curves_combined(event_files, colors, plot1, plot2, f'timecourse_{label11}_{label22}.png'), dpi=300) -def curves_combined(event_files, colors, plot1, label1=None, output_dir="."): +def plot_single_curve(event_files, colors, plot1, label1=None, output_dir="."): """ FIXME: colors parameter is not used """ @@ -135,6 +136,7 @@ def curves_combined(event_files, colors, plot1, label1=None, output_dir="."): parser.add_argument('-plot2', "--plot2", default=None, type=str) parser.add_argument('-label1', "--label1", default=None, type=str) parser.add_argument('-label2', "--label2", default=None, type=str) + parser.add_argument('-title', "--title", default=None, type=str) parser.add_argument('--output_dir', default='.', type=str) parser.add_argument('--phase_portrait', action='store_true', help="if True plots a phase portrait,\ @@ -164,6 +166,6 @@ def curves_combined(event_files, colors, plot1, label1=None, output_dir="."): output_dir=args.output_dir) else: # one curve per plot - curves_combined(event_files, colors, - plot1=args.plot1, label1=args.label1, - output_dir=args.output_dir) + plot_single_curve(event_files, colors, + plot1=args.plot1, label1=args.label1, + output_dir=args.output_dir) diff --git a/generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh similarity index 100% rename from generate_all_figures_diva.sh rename to script_generate_all_figures_diva.sh From d7dee81078a16eb45aec9a216d208fce8a8d9ac1 Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:38:32 -0400 Subject: [PATCH 593/762] minor changes for figures --- .../utils/generate_fbopt_phase_portrait.py | 50 +++++++++---------- run_pacs_diva_fbopt.sh | 2 +- script_generate_all_figures_diva.sh | 22 ++++---- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index db7418602..736a2c83f 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -47,7 +47,7 @@ def get_xy_from_event_file(event_file, plot1, plot2=None, def phase_portrait_combined(event_files, colors, plot1, plot2, - label1=None, label2=None, output_dir="."): + legend1=None, legend2=None, output_dir="."): """ combined phase portait for multiple (at least one) Tensorboard event files in the same plot @@ -68,21 +68,21 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, plt.plot(x[0], y[0], 'ko') plt.scatter(x, y, s=1, c='black') - if label1 is None: label1=plot1 - if label2 is None: label2=plot2 - plt.xlabel(label1) - plt.ylabel(label2) + if legend1 is None: legend1=plot1 + if legend2 is None: legend2=plot2 + plt.xlabel(legend1) + plt.ylabel(legend2) plt.title("phase portrait") if not os.path.exists(output_dir): os.makedirs(output_dir) - label22 = label2.split(os.sep)[-1] + legend22 = legend2.split(os.sep)[-1] plt.savefig(os.path.join(output_dir, - f'phase_portrait_combined_{label22}.png'), dpi=300) + f'phase_portrait_combined_{legend22}.png'), dpi=300) def two_curves_combined(event_files, colors, plot1, plot2, - label1=None, label2=None, output_dir=".", title=None): + legend1=None, legend2=None, output_dir=".", title=None): """ FIXME: colors parameter is not used """ @@ -96,20 +96,20 @@ def two_curves_combined(event_files, colors, plot1, plot2, plt.ylabel("loss") if title is not None: plt.title(title) - if label1 is None: label1=plot1 - if label2 is None: label2=plot2 - plt.legend([label1, label2]) + if legend1 is None: legend1=plot1 + if legend2 is None: legend2=plot2 + plt.legend([legend1, legend2]) - label11 = label1.replace(os.sep, "_") - label22 = label2.replace(os.sep, "_") + legend11 = legend1.replace(os.sep, "_") + legend22 = legend2.replace(os.sep, "_") if not os.path.exists(output_dir): os.makedirs(output_dir) plt.savefig(os.path.join(output_dir, - f'timecourse_{label11}_{label22}.png'), dpi=300) + f'timecourse_{legend11}_{legend22}.png'), dpi=300) -def plot_single_curve(event_files, colors, plot1, label1=None, output_dir="."): +def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): """ FIXME: colors parameter is not used """ @@ -118,24 +118,24 @@ def plot_single_curve(event_files, colors, plot1, label1=None, output_dir="."): x, _ = get_xy_from_event_file(event_files[event_i], plot1=plot1) plt.plot(x) plt.xlabel("time") - if label1 is None: label1=plot1 - plt.ylabel(label1) + if legend1 is None: legend1=plot1 + plt.ylabel(legend1) # plt.title("timecourse") - label11 = label1.replace(os.sep, "_") + legend11 = legend1.replace(os.sep, "_") if not os.path.exists(output_dir): os.makedirs(output_dir) plt.savefig(os.path.join(output_dir, - f'timecourse_{label11}.png'), dpi=300) + f'timecourse_{legend11}.png'), dpi=300) if __name__ == "__main__": parser = argparse.ArgumentParser(description='plot') parser.add_argument('-plot1', "--plot1", default=None, type=str) parser.add_argument('-plot2', "--plot2", default=None, type=str) - parser.add_argument('-label1', "--label1", default=None, type=str) - parser.add_argument('-label2', "--label2", default=None, type=str) + parser.add_argument('-legend1', "--legend1", default=None, type=str) + parser.add_argument('-legend2', "--legend2", default=None, type=str) parser.add_argument('-title', "--title", default=None, type=str) parser.add_argument('--output_dir', default='.', type=str) parser.add_argument('--phase_portrait', action='store_true', @@ -155,17 +155,17 @@ def plot_single_curve(event_files, colors, plot1, label1=None, output_dir="."): if args.phase_portrait: phase_portrait_combined(event_files, colors, plot1=args.plot1, plot2=args.plot2, - label1=args.label1, label2=args.label2, + legend1=args.legend1, legend2=args.legend2, output_dir=args.output_dir) else: if args.plot2: # two curves per plot two_curves_combined(event_files, colors, plot1=args.plot1, plot2=args.plot2, - label1=args.label1, label2=args.label2, - output_dir=args.output_dir) + legend1=args.legend1, legend2=args.legend2, + output_dir=args.output_dir, title=args.title) else: # one curve per plot plot_single_curve(event_files, colors, - plot1=args.plot1, label1=args.label1, + plot1=args.plot1, legend1=args.legend1, output_dir=args.output_dir) diff --git a/run_pacs_diva_fbopt.sh b/run_pacs_diva_fbopt.sh index 4b835c2d6..a68803ab0 100644 --- a/run_pacs_diva_fbopt.sh +++ b/run_pacs_diva_fbopt.sh @@ -3,4 +3,4 @@ # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=sketch --bs=64 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath=examples/nets/resnet50domainbed.py --gamma_y=1.0 --mu_init=1e-6 --lr=5e-5 --zx_dim=0 +python main_out.py --te_d=sketch --bs=32 --aname=diva --trainer=fbopt --epos=200 --es=200 --npath_dom=examples/nets/resnet50domainbed.py --tpath=examples/tasks/task_pacs_path_list.py --npath=examples/nets/resnet50domainbed.py --gamma_y=1.0 --mu_init=1e-6 --lr=5e-5 --zx_dim=0 diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 2161f671c..f0c9fac16 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -1,27 +1,27 @@ #!/bin/bash # Phase portraits -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dyngamma_d" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dyngamma_d" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dyngamma_d" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dyngamma_d" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynmu_recon" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dynmu_recon" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynmu_recon" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dynmu_recon" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_d" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_d" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_d" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_d" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_x" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_x" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_x" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_x" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_y" --plot1="loss_task/ell" --label2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_y" --label1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_y" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_y" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait # Plot R and the corresponding set point curves (both in the same figure) -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --label1="loss dynamic corresponding to multiplier dyn_gamma_d" --label2="corresponding setpoint_gamma_d" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss dynamic corresponding to multiplier dyn_gamma_d" --legend2="corresponding setpoint_gamma_d" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --label1="loss dynamic corresponding to multiplier dyn_mu_recon" --label2="corresponding setpoint_mu_recon" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="loss dynamic corresponding to multiplier dyn_mu_recon" --legend2="corresponding setpoint_mu_recon" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --label1="loss dynamic corresponding to multiplier dyn_beta_d" --label2="corresponding setpoint_beta_d" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="loss dynamic corresponding to multiplier dyn_beta_d" --legend2="corresponding setpoint_beta_d" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --label1="loss dynamic corresponding to multiplier dyn_beta_x" --label2="corresponding setpoint_beta_x" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="loss dynamic corresponding to multiplier dyn_beta_x" --legend2="corresponding setpoint_beta_x" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --label1="loss dynamic corresponding to multiplier dyn_beta_y" --label2="corresponding setpoint_beta_y" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="loss dynamic corresponding to multiplier dyn_beta_y" --legend2="corresponding setpoint_beta_y" --output_dir="./figures_diva" # Other plots (one curve per figure) @@ -29,5 +29,5 @@ values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_ # Loop over the array for val in "${values[@]}" do - python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="$val" --label1="$val" --output_dir="./figures_diva" + python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="$val" --legend1="$val" --output_dir="./figures_diva" done From a23984de4443979b7788e7cd72bea3e16a9d11ff Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:46:09 -0400 Subject: [PATCH 594/762] fixed legend for diva figures --- script_generate_all_figures_diva.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index f0c9fac16..57b6618f9 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -13,21 +13,21 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell # Plot R and the corresponding set point curves (both in the same figure) -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss dynamic corresponding to multiplier dyn_gamma_d" --legend2="corresponding setpoint_gamma_d" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss (gamma_d)" --legend2="setpoint" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="loss dynamic corresponding to multiplier dyn_mu_recon" --legend2="corresponding setpoint_mu_recon" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="loss dynamic corresponding to multiplier dyn_beta_d" --legend2="corresponding setpoint_beta_d" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL (beta_d)" --legend2="setpoint" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="loss dynamic corresponding to multiplier dyn_beta_x" --legend2="corresponding setpoint_beta_x" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="loss dynamic corresponding to multiplier dyn_beta_y" --legend2="corresponding setpoint_beta_y" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir="./figures_diva" -# Other plots (one curve per figure) -values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_x' 'controller_gain/gamma_d' 'controller_gain/mu_recon' 'dyn_mu/beta_d' 'delta/beta_d' 'dyn_mu/beta_y' 'delta/beta_y' 'dyn_mu/beta_x' 'delta/beta_x' 'dyn_mu/gamma_d' 'delta/gamma_d' 'dyn_mu/mu_recon' 'delta/mu_recon' 'loss_task/penalized' 'loss_task/ell' 'acc/te' 'acc/val' 'acc/sel' 'acc/setpoint') -# Loop over the array -for val in "${values[@]}" -do - python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="$val" --legend1="$val" --output_dir="./figures_diva" -done +# # Other plots (one curve per figure) +# values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_x' 'controller_gain/gamma_d' 'controller_gain/mu_recon' 'dyn_mu/beta_d' 'delta/beta_d' 'dyn_mu/beta_y' 'delta/beta_y' 'dyn_mu/beta_x' 'delta/beta_x' 'dyn_mu/gamma_d' 'delta/gamma_d' 'dyn_mu/mu_recon' 'delta/mu_recon' 'loss_task/penalized' 'loss_task/ell' 'acc/te' 'acc/val' 'acc/sel' 'acc/setpoint') +# # Loop over the array +# for val in "${values[@]}" +# do +# python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="$val" --legend1="$val" --output_dir="./figures_diva" +# done From 568f800fbcac06ee3a2dd33861b9096b864292f5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 16:59:15 +0200 Subject: [PATCH 595/762] scrot draw diva --- script_generate_all_figures_diva.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 57b6618f9..c9f06c3d6 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -1,15 +1,15 @@ #!/bin/bash # Phase portraits -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dyngamma_d" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dyngamma_d" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynmu_recon" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dynmu_recon" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_d" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_d" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_x" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_x" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_y" --plot1="loss_task/ell" --legend2="x-axis=loss_ell task vs y-axis=loss r/dynbeta_y" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait # Plot R and the corresponding set point curves (both in the same figure) From 1676185f2194634228e7cd0acfd3b455a293eaaf Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:55:33 -0400 Subject: [PATCH 596/762] fix legend colors in diva figures --- domainlab/utils/generate_fbopt_phase_portrait.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 736a2c83f..984080cc1 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -90,8 +90,8 @@ def two_curves_combined(event_files, colors, plot1, plot2, for event_i in range(len(event_files)): x, y = get_xy_from_event_file(event_files[event_i], plot1=plot1, plot2=plot2) - plt.plot(x) - plt.plot(y) + plt.plot(x, color="blue") + plt.plot(y, color="red") plt.xlabel("time") plt.ylabel("loss") if title is not None: From 64695d286144386b31a78c3c66c047da72070a92 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 17:03:15 +0200 Subject: [PATCH 597/762] . --- script_generate_all_figures_diva.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index c9f06c3d6..ab6f921c5 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -24,10 +24,10 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir="./figures_diva" -# # Other plots (one curve per figure) -# values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_x' 'controller_gain/gamma_d' 'controller_gain/mu_recon' 'dyn_mu/beta_d' 'delta/beta_d' 'dyn_mu/beta_y' 'delta/beta_y' 'dyn_mu/beta_x' 'delta/beta_x' 'dyn_mu/gamma_d' 'delta/gamma_d' 'dyn_mu/mu_recon' 'delta/mu_recon' 'loss_task/penalized' 'loss_task/ell' 'acc/te' 'acc/val' 'acc/sel' 'acc/setpoint') -# # Loop over the array -# for val in "${values[@]}" -# do -# python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="$val" --legend1="$val" --output_dir="./figures_diva" -# done + # Other plots (one curve per figure) + values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_x' 'controller_gain/gamma_d' 'controller_gain/mu_recon' 'dyn_mu/beta_d' 'delta/beta_d' 'dyn_mu/beta_y' 'delta/beta_y' 'dyn_mu/beta_x' 'delta/beta_x' 'dyn_mu/gamma_d' 'delta/gamma_d' 'dyn_mu/mu_recon' 'delta/mu_recon' 'loss_task/penalized' 'loss_task/ell' 'acc/te' 'acc/val' 'acc/sel' 'acc/setpoint') + # Loop over the array + for val in "${values[@]}" + do + python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="$val" --legend1="$val" --output_dir="./figures_diva" + done From 599d1ce78552e9ef7242c6ae354abae60d3f9fe3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 17:09:00 +0200 Subject: [PATCH 598/762] remove y lable, rename xlable --- domainlab/utils/generate_fbopt_phase_portrait.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 984080cc1..2942bd455 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -92,8 +92,8 @@ def two_curves_combined(event_files, colors, plot1, plot2, plot1=plot1, plot2=plot2) plt.plot(x, color="blue") plt.plot(y, color="red") - plt.xlabel("time") - plt.ylabel("loss") + plt.xlabel("epoch") + # plt.ylabel("loss") if title is not None: plt.title(title) if legend1 is None: legend1=plot1 From d0119e436c428c7e24cdf8d8d7db95c3d0fa5b70 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 17:43:43 +0200 Subject: [PATCH 599/762] . --- script_jigen_plot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script_jigen_plot.sh b/script_jigen_plot.sh index ad8e4c325..e8197cb66 100644 --- a/script_jigen_plot.sh +++ b/script_jigen_plot.sh @@ -1,5 +1,5 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_ -alpha" --plot1="loss_task/ell" --label2="regularization loss jigen" --label1="classification loss" --output_dir="." --phase_portrait +alpha" --plot1="loss_task/ell" --legend2="regularization loss jigen" --legend1="classification loss" --output_dir="." --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_alpha" --plot1="lossrs/setpoint_alpha" --label2="regularization loss jigen" --label1="setpoint" --output_dir="." +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_alpha" --plot1="lossrs/setpoint_alpha" --legend2="regularization loss jigen" --legend1="setpoint" --output_dir="." From 51d48c573c9bdca4ecd7959a09bd8831211454d2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 26 Oct 2023 17:45:19 +0200 Subject: [PATCH 600/762] . --- domainlab/utils/generate_fbopt_phase_portrait.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 2942bd455..a86bc80fc 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -66,6 +66,7 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, fc=colors[event_i], ec=colors[event_i], alpha=0.4) plt.plot(x[0], y[0], 'ko') + # FIXME: change c to vector of steps, range(len(x)) plt.scatter(x, y, s=1, c='black') if legend1 is None: legend1=plot1 From cf0d6c4f2c99a7a1885149a606dd9bda0f803fd5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 10:55:33 +0200 Subject: [PATCH 601/762] autoki diva --- .../pacs_diva_fbopt_alone_es1_autoki.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml new file mode 100644 index 000000000..09901af72 --- /dev/null +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -0,0 +1,107 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 500 + epos_min: 20 + es: 1 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + + mu_clip: + distribution: categorical + datatype: float + values: + - 10 + - 1000 + - 1 + - 100 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: uniform + + k_i_gain_ratio: + min: 0.1 + max: 1 + num: 10 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + aname: diva + trainer: fbopt + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + str_diva_multiplier_type: gammad_recon + coeff_ma_output_state: 0.1 + mu_init: 1e-6 + shared: + - k_i_gain_ratio From 33dd359e348fde12653c9931c816a1fccf55899d Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 11:02:54 +0200 Subject: [PATCH 602/762] yaml --- ...va_fbopt_alone_es1_autoki_output_ma_9.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml new file mode 100644 index 000000000..559de9865 --- /dev/null +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -0,0 +1,107 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone + +sampling_seed: 0 + +startseed: 0 +endseed: 2 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_path_list.py + dmem: False + lr: 5e-5 + epos: 500 + epos_min: 20 + es: 1 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + + mu_clip: + distribution: categorical + datatype: float + values: + - 10 + - 1000 + - 1 + - 100 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: uniform + + k_i_gain_ratio: + min: 0.1 + max: 1 + num: 10 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + aname: diva + trainer: fbopt + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + str_diva_multiplier_type: gammad_recon + coeff_ma_output_state: 0.9 + mu_init: 1e-6 + shared: + - k_i_gain_ratio From 5ba7392e643803f7da43e30bb471eabbec371c2e Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 16:07:50 +0200 Subject: [PATCH 603/762] beter plot --- domainlab/algos/trainers/fbopt_mu_controller.py | 2 +- domainlab/utils/generate_fbopt_phase_portrait.py | 16 +++++++++++----- run_fbopt_mnist_jigen_autoki.sh | 2 +- script_jigen_plot.sh | 5 ++--- 4 files changed, 15 insertions(+), 10 deletions(-) mode change 100644 => 100755 script_jigen_plot.sh diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index a85ef3bee..04ba0cb42 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -199,7 +199,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) self.writer.add_scalars( - f'loss_rds/loss_{list_str_multiplier_na[i]} with setpoint', + f'loss_rds/loss_{list_str_multiplier_na[i]}_w_setpoint', {f'lossr/loss_{list_str_multiplier_na[i]}': reg_dyn, f'lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, }, miter) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index a86bc80fc..0d6003aa7 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -1,5 +1,6 @@ import glob import os +import numpy as np import argparse import matplotlib.pyplot as plt @@ -61,13 +62,18 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, assert len(x) == len(y) for i in range(len(x) - 1): plt.arrow(x[i], y[i], (x[i + 1] - x[i]), (y[i + 1] - y[i]), - head_width=0.2, head_length=0.2, - length_includes_head=True, + head_width=0.15, head_length=0.2, + length_includes_head=False, fc=colors[event_i], ec=colors[event_i], alpha=0.4) - + # the combination of head_width and head_length make the arrow + # more visible + # length_includes_head=False will put arrow out of point, which let + # point more visible, otherwise arrow will cover point + colors = ['red', 'green', 'blue', 'yellow', 'purple'] plt.plot(x[0], y[0], 'ko') - # FIXME: change c to vector of steps, range(len(x)) - plt.scatter(x, y, s=1, c='black') + + list_color = [colors[i % len(colors)] for i, h in enumerate(x)] + plt.scatter(x, y, s=1, c=np.array(list_color)) if legend1 is None: legend1=plot1 if legend2 is None: legend2=plot2 diff --git a/run_fbopt_mnist_jigen_autoki.sh b/run_fbopt_mnist_jigen_autoki.sh index 8cddf4d58..cd74a1c3d 100644 --- a/run_fbopt_mnist_jigen_autoki.sh +++ b/run_fbopt_mnist_jigen_autoki.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=1 --mu_init=1e-6 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 --k_i_gain_ratio=0.9 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=1 --epos_min=500 --mu_init=1e-6 --coeff_ma_output_state=0.99 --k_i_gain_ratio=0.99 diff --git a/script_jigen_plot.sh b/script_jigen_plot.sh old mode 100644 new mode 100755 index e8197cb66..6d770a266 --- a/script_jigen_plot.sh +++ b/script_jigen_plot.sh @@ -1,5 +1,4 @@ -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_ -alpha" --plot1="loss_task/ell" --legend2="regularization loss jigen" --legend1="classification loss" --output_dir="." --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_alpha" --plot1="loss_task/ell" --legend2="regularization loss jigen" --legend1="classification loss" --output_dir="." --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_alpha" --plot1="lossrs/setpoint_alpha" --legend2="regularization loss jigen" --legend1="setpoint" --output_dir="." +python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrs/setpoint_alpha" --plot2="lossrd/dyn_alpha" --legend2="regularization loss jigen" --legend1="setpoint" --output_dir="." From cb86c44740bc563fb5a6307ff005326082a4cfe4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 16:17:44 +0200 Subject: [PATCH 604/762] better plot --- domainlab/algos/trainers/fbopt_mu_controller.py | 3 +-- run_fbopt_mnist_diva_autoki.sh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 04ba0cb42..3193ae225 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -204,8 +204,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, f'lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, }, miter) self.writer.add_scalar( - f'x-axis=loss_ell task vs y-axis=loss \ - r/dyn{list_str_multiplier_na[i]}', + f'x_ell_y_r/loss_{list_str_multiplier_na[i]}', reg_dyn, epo_task_loss) self.writer.add_scalar('loss_task/penalized', epo_loss_tr, miter) self.writer.add_scalar('loss_task/ell', epo_task_loss, miter) diff --git a/run_fbopt_mnist_diva_autoki.sh b/run_fbopt_mnist_diva_autoki.sh index f07caab3f..4b0272e26 100644 --- a/run_fbopt_mnist_diva_autoki.sh +++ b/run_fbopt_mnist_diva_autoki.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.5 --coeff_ma_output_state=0.9 From 3cea9bdc9b430f2c103c426737239670334c5fd0 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 16:29:54 +0200 Subject: [PATCH 605/762] . --- examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml index 411800cda..8cbd05064 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -74,6 +74,8 @@ jigen_feedback: aname: jigen trainer: fbopt ini_setpoint_ratio: 0.99 + mu_init: 1e-6 shared: - k_i_gain_ratio + - coeff_ma_output_state From e6cac852b9d1a198bfc3c42318a48d9fd5400214 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 16:36:40 +0200 Subject: [PATCH 606/762] more ki gain --- examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml index 8cbd05064..3fcf21640 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/pacs_jigen_fbopt_alone sampling_seed: 0 startseed: 0 -endseed: 3 +endseed: 6 test_domains: - sketch @@ -38,8 +38,8 @@ Shared params: k_i_gain_ratio: min: 0.1 - max: 0.9 - num: 8 + max: 1 + num: 10 distribution: uniform mu_init: From f029f14409e8d8810011f8dc7abf4550da7e4b75 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 16:58:39 +0200 Subject: [PATCH 607/762] yaml --- .../pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml | 4 +++- run_fbopt_mnist_diva_autoki.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml index 559de9865..c8a2bb5ee 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone sampling_seed: 0 startseed: 0 -endseed: 2 +endseed: 10 test_domains: - sketch @@ -48,6 +48,7 @@ Shared params: values: - 0.1 - 0.5 + - 0.8 mu_clip: distribution: categorical @@ -105,3 +106,4 @@ diva_fbopt_full: mu_init: 1e-6 shared: - k_i_gain_ratio + - coeff_ma_output_state diff --git a/run_fbopt_mnist_diva_autoki.sh b/run_fbopt_mnist_diva_autoki.sh index 4b0272e26..f07caab3f 100644 --- a/run_fbopt_mnist_diva_autoki.sh +++ b/run_fbopt_mnist_diva_autoki.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.5 --coeff_ma_output_state=0.9 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 From 41168f9a7505a9712a6a1c09154c68a2fddb231b Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 17:01:10 +0200 Subject: [PATCH 608/762] 2.2 --- .../benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml index c8a2bb5ee..92360b01c 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -102,7 +102,6 @@ diva_fbopt_full: gamma_y: 1.0 ini_setpoint_ratio: 0.99 str_diva_multiplier_type: gammad_recon - coeff_ma_output_state: 0.9 mu_init: 1e-6 shared: - k_i_gain_ratio From 4d8f8e207ec92fb662a22e108fa21794ca3e600c Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 27 Oct 2023 17:07:46 +0200 Subject: [PATCH 609/762] . --- .../benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml index 92360b01c..2a0532ef7 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone +output_dir: zoutput/benchmarks/pacs_diva_fbopt_autoki_oct27 sampling_seed: 0 From 16da3dd6a5dfbb133284aa9fc84a6ddb17593951 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 30 Oct 2023 09:18:30 +0100 Subject: [PATCH 610/762] diva yaml mnisT --- .../benchmark/mnist_diva_fbopt_and_baselines.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index e8d9458f2..b62374bbe 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -15,8 +15,8 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 500 - epos_min: 20 + epos: 1000 + epos_min: 500 es: 5 bs: 64 zx_dim: 0 @@ -45,6 +45,12 @@ Shared params: num: 2 distribution: loguniform + k_i_gain_ratio: + min: 0.1 + max: 1 + num: 5 + distribution: uniform + mu_init: min: 0.000001 max: 0.00001 @@ -85,7 +91,7 @@ diva_fbopt_a: exp_shoulder_clip: 1 mu_init: 1e-6 shared: - - k_i_gain + - k_i_gain_ratio - mu_clip diva_feedforward_a: From 87389df81a910794fda197090aa3acc6bc403143 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 30 Oct 2023 09:25:11 +0100 Subject: [PATCH 611/762] improve epos_min jigenauto ki --- examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml index 3fcf21640..e43fb5d1f 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 200 - epos_min: 20 + epos_min: 50 es: 1 bs: 64 san_check: False From 125d142a4277710e689019a2096107cdf28d2590 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 31 Oct 2023 11:29:06 +0100 Subject: [PATCH 612/762] force setpoint to be met as an option fix issue # 604 --- domainlab/algos/observers/b_obvisitor.py | 6 +++++- domainlab/algos/trainers/args_fbopt.py | 17 +++++++++++++---- tests/test_fbopt.py | 8 ++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index 26650ea9c..3fca52d8a 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -28,6 +28,7 @@ def __init__(self, model_sel, device, exp=None): self.metric_te = None self.metric_val = None self.perf_metric = None + self.flag_setpoint_changed_once = False if exp is not None: self.set_exp(exp) @@ -61,6 +62,9 @@ def update(self, epoch, flag_info=False): logger.info("persisted") flag_stop = self.model_sel.if_stop() flag_enough = epoch > self.host_trainer.aconf.epos_min + self.flag_setpoint_changed_once |= flag_info + if self.host_trainer.aconf.force_setpoint_change_once: + return flag_stop & flag_enough & self.flag_setpoint_changed_once return flag_stop & flag_enough def accept(self, trainer): @@ -158,4 +162,4 @@ def clean_up(self): to be called by a decorator """ if not self.keep_model: - self.exp.clean_up() \ No newline at end of file + self.exp.clean_up() diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index f966d076b..16ce6df5a 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -28,7 +28,8 @@ def add_args2parser_fbopt(parser): help='exponential moving average') parser.add_argument('--coeff_ma_output_state', type=float, default=0.1, - help='state exponential moving average of reguarlization loss') + help='state exponential moving average of \ + reguarlization loss') parser.add_argument('--coeff_ma_setpoint', type=float, default=0.9, help='setpoint average coeff for previous setpoint') @@ -40,13 +41,20 @@ def add_args2parser_fbopt(parser): help='before training start, evaluate reg loss, \ setpoint will be 0.9 of this loss') + parser.add_argument('--force_setpoint_change_once', action='store_true', + default=False, + help='train until the setpoint changed at least once \ + up to maximum epos specified') + parser.add_argument('--no_tensorboard', action='store_true', default=False, help='disable tensorboard') - parser.add_argument('--no_setpoint_update', action='store_true', default=False, + parser.add_argument('--no_setpoint_update', action='store_true', + default=False, help='disable setpoint update') - parser.add_argument('--tr_with_init_mu', action='store_true', default=False, + parser.add_argument('--tr_with_init_mu', action='store_true', + default=False, help='disable setpoint update') parser.add_argument('--overshoot_rewind', type=str, default="yes", @@ -55,7 +63,8 @@ def add_args2parser_fbopt(parser): parser.add_argument('--setpoint_rewind', type=str, default="no", help='setpoing_rewind, for benchmark, use yes or no') - parser.add_argument('--str_diva_multiplier_type', type=str, default="gammad_recon", + parser.add_argument('--str_diva_multiplier_type', type=str, + default="gammad_recon", help='which penalty to tune') return parser diff --git a/tests/test_fbopt.py b/tests/test_fbopt.py index 909e125b2..3e100acd8 100644 --- a/tests/test_fbopt.py +++ b/tests/test_fbopt.py @@ -25,3 +25,11 @@ def test_diva_fbopt(): """ args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=diva --gamma_y=1.0 --trainer=fbopt --nname=alexnet --epos=3" utils_test_algo(args) + +def test_forcesetpoint_fbopt(): + """ + diva + """ + args = "--te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=10 --es=0 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 --force_setpoint_change_once" + utils_test_algo(args) + From d3524c3173e35e1d4089edf1c677e17290cfd6d8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 31 Oct 2023 11:32:31 +0100 Subject: [PATCH 613/762] force setpoing in script --- run_fbopt_mnist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 5e9d770fb..c8fd1143d 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=50 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=0 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 --force_setpoint_change_once From 9c32106029d3a21915bfd983dcf2e78416d6d29d Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 31 Oct 2023 14:31:02 +0100 Subject: [PATCH 614/762] more epochs --- examples/benchmark/mnist_diva_fbopt_and_baselines.yaml | 2 +- run_fbopt_mnist_diva_autoki.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index b62374bbe..8182e1c6a 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -15,7 +15,7 @@ domainlab_args: tr_d: [1, 2] dmem: False lr: 0.001 - epos: 1000 + epos: 5000 epos_min: 500 es: 5 bs: 64 diff --git a/run_fbopt_mnist_diva_autoki.sh b/run_fbopt_mnist_diva_autoki.sh index f07caab3f..d9f42152a 100644 --- a/run_fbopt_mnist_diva_autoki.sh +++ b/run_fbopt_mnist_diva_autoki.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 --coeff_ma_output_state=0 --coeff_ma_setpoint=0 --epos_min=1000 --force_setpoint_change_once From a2553b38fe6b6896d58c374c27cf56c039974c9e Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 31 Oct 2023 14:46:32 +0100 Subject: [PATCH 615/762] jigen --- .../benchmark/pacs_jigen_fbopt_alone_autoki.yaml | 16 +++++++++++++--- run_fbopt_mnist_diva_autoki.sh | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml index e43fb5d1f..20fe08230 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -14,8 +14,9 @@ domainlab_args: tpath: examples/tasks/task_pacs_path_list.py dmem: False lr: 5e-5 - epos: 200 + epos: 500 epos_min: 50 + force_setpoint_change_once: True es: 1 bs: 64 san_check: False @@ -39,7 +40,7 @@ Shared params: k_i_gain_ratio: min: 0.1 max: 1 - num: 10 + num: 5 distribution: uniform mu_init: @@ -60,11 +61,19 @@ Shared params: num: 10 distribution: loguniform + coeff_ma_setpoint: + distribution: categorical + datatype: float + values: + - 0.0 + - 0.5 + - 0.9 + coeff_ma_output_state: distribution: categorical datatype: float values: - - 0.1 + - 0.0 - 0.5 - 0.9 @@ -79,3 +88,4 @@ jigen_feedback: shared: - k_i_gain_ratio - coeff_ma_output_state + - coeff_ma_setpoint diff --git a/run_fbopt_mnist_diva_autoki.sh b/run_fbopt_mnist_diva_autoki.sh index d9f42152a..ac74076ae 100644 --- a/run_fbopt_mnist_diva_autoki.sh +++ b/run_fbopt_mnist_diva_autoki.sh @@ -4,4 +4,4 @@ # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 --coeff_ma_output_state=0 --coeff_ma_setpoint=0 --epos_min=1000 --force_setpoint_change_once +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=diva --trainer=fbopt --nname=conv_bn_pool_2 --epos=5000 --es=5 --mu_init=1e-6 --gamma_y=1.0 --k_i_gain_ratio=0.9 --coeff_ma_output_state=0 --coeff_ma_setpoint=0 --epos_min=1000 --force_setpoint_change_once From e161df5577bfe92a61a961cbe9ddf3f4eb9191b4 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 31 Oct 2023 14:48:07 +0100 Subject: [PATCH 616/762] Update pacs_jigen_fbopt_alone_autoki.yaml --- examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml index 20fe08230..50486d26d 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/pacs_jigen_fbopt_alone sampling_seed: 0 startseed: 0 -endseed: 6 +endseed: 3 test_domains: - sketch From 350d352fc44c2b4beafa3374f50f79d5edb8a411 Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Tue, 31 Oct 2023 11:26:01 -0400 Subject: [PATCH 617/762] https://github.com/marrlab/DomainLab/issues/601 --- domainlab/utils/generate_fbopt_phase_portrait.py | 13 ++++++++++--- script_generate_all_figures_diva.sh | 10 +++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 0d6003aa7..398e8c621 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -48,7 +48,8 @@ def get_xy_from_event_file(event_file, plot1, plot2=None, def phase_portrait_combined(event_files, colors, plot1, plot2, - legend1=None, legend2=None, output_dir="."): + legend1=None, legend2=None, plot_len=None, + output_dir="."): """ combined phase portait for multiple (at least one) Tensorboard event files in the same plot @@ -60,7 +61,12 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, plot1=plot1, plot2=plot2) assert len(x) == len(y) - for i in range(len(x) - 1): + if plot_len is None: + plot_len = len(x) + # truncate x and y to the desired length: + x, y = x[:plot_len], y[:plot_len] + + for i in range(plot_len - 1): plt.arrow(x[i], y[i], (x[i + 1] - x[i]), (y[i + 1] - y[i]), head_width=0.15, head_length=0.2, length_includes_head=False, @@ -143,6 +149,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): parser.add_argument('-plot2', "--plot2", default=None, type=str) parser.add_argument('-legend1', "--legend1", default=None, type=str) parser.add_argument('-legend2', "--legend2", default=None, type=str) + parser.add_argument('-plot_len', "--plot_len", default=None, type=int) parser.add_argument('-title', "--title", default=None, type=str) parser.add_argument('--output_dir', default='.', type=str) parser.add_argument('--phase_portrait', action='store_true', @@ -163,7 +170,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): phase_portrait_combined(event_files, colors, plot1=args.plot1, plot2=args.plot2, legend1=args.legend1, legend2=args.legend2, - output_dir=args.output_dir) + plot_len=args.plot_len, output_dir=args.output_dir) else: if args.plot2: # two curves per plot diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index ab6f921c5..3a4dce58b 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -1,15 +1,15 @@ #!/bin/bash # Phase portraits -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="loss_task/ell" --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait # Plot R and the corresponding set point curves (both in the same figure) From 30a5b5071c4bb47872ef2e491edb102ace981bf9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 31 Oct 2023 16:40:50 +0100 Subject: [PATCH 618/762] pacs with aut --- examples/tasks/task_pacs_aug.py | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 examples/tasks/task_pacs_aug.py diff --git a/examples/tasks/task_pacs_aug.py b/examples/tasks/task_pacs_aug.py new file mode 100644 index 000000000..bc0b14c2c --- /dev/null +++ b/examples/tasks/task_pacs_aug.py @@ -0,0 +1,58 @@ +""" +full data(images), as well as the txt file indicating the filenames of images can be +download from +- (https://domaingeneralization.github.io/#data) +- or (https://drive.google.com/drive/folders/0B6x7gtvErXgfUU1WcGY5SzdwZVk?resourcekey=0-2fvpQY_QSyJf2uIECzqPuQ) +""" + +from torchvision import transforms +from domainlab.tasks.task_pathlist import mk_node_task_path_list +from domainlab.tasks.utils_task import ImSize + +# change this to absolute directory where you have the raw images from PACS, +G_PACS_RAW_PATH = "data/pacs/PACS" +# domainlab repository contain already the file names in data/pacs_split folder of domainlab + +def get_task(na=None): + node = mk_node_task_path_list( + isize=ImSize(3, 224, 224), + list_str_y=["dog", "elephant", "giraffe", "guitar", + "horse", "house", "person"], + dict_class_label_ind2name={"1": "dog", + "2": "elephant", + "3": "giraffe", + "4": "guitar", + "5": "horse", + "6": "house", + "7": "person"}, + dict_d2filepath_list_img_tr={ + "art_painting": "data/pacs_split/art_painting_train_kfold.txt", + "cartoon": "data/pacs_split/cartoon_train_kfold.txt", + "photo": "data/pacs_split/photo_train_kfold.txt", + "sketch": "data/pacs_split/sketch_train_kfold.txt"}, + + dict_d2filepath_list_img_te={ + "art_painting": "data/pacs_split/art_painting_test_kfold.txt", + "cartoon": "data/pacs_split/cartoon_test_kfold.txt", + "photo": "data/pacs_split/photo_test_kfold.txt", + "sketch": "data/pacs_split/sketch_test_kfold.txt"}, + + dict_d2filepath_list_img_val={ + "art_painting": "data/pacs_split/art_painting_crossval_kfold.txt", + "cartoon": "data/pacs_split/cartoon_crossval_kfold.txt", + "photo": "data/pacs_split/photo_crossval_kfold.txt", + "sketch": "data/pacs_split/sketch_crossval_kfold.txt"}, + + dict_domain2imgroot={ + 'art_painting': G_PACS_RAW_PATH, + 'cartoon': G_PACS_RAW_PATH, + 'photo': G_PACS_RAW_PATH, + 'sketch': G_PACS_RAW_PATH}, + img_trans_tr=transforms.Compose( + [transforms.Resize((224, 224)), + transforms.ToTensor()]), + img_trans_te=transforms.Compose( + [transforms.Resize((224, 224)), + transforms.ToTensor()]) + ) + return node From 4f29ec45adfad9fca8c4f4fded2e6edcf9c1f7df Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 31 Oct 2023 16:48:33 +0100 Subject: [PATCH 619/762] fix issue #610 --- examples/tasks/task_pacs_aug.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/tasks/task_pacs_aug.py b/examples/tasks/task_pacs_aug.py index bc0b14c2c..6cc9a6767 100644 --- a/examples/tasks/task_pacs_aug.py +++ b/examples/tasks/task_pacs_aug.py @@ -49,10 +49,18 @@ def get_task(na=None): 'photo': G_PACS_RAW_PATH, 'sketch': G_PACS_RAW_PATH}, img_trans_tr=transforms.Compose( - [transforms.Resize((224, 224)), - transforms.ToTensor()]), + [transforms.RandomResizedCrop(224, scale=(0.7, 1.0)), + transforms.RandomHorizontalFlip(), + transforms.ColorJitter(0.3, 0.3, 0.3, 0.3), + transforms.RandomGrayscale(), + transforms.ToTensor(), + transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), + ]), img_trans_te=transforms.Compose( [transforms.Resize((224, 224)), - transforms.ToTensor()]) + transforms.ToTensor(), + transforms.Normalize( + mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) + ]) ) return node From b7d8528818de3e3afc2da2b467d5978ab534af7d Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 31 Oct 2023 16:54:07 +0100 Subject: [PATCH 620/762] jigen yaml --- .../pacs_jigen_fbopt_and_baselines_aug.yaml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml new file mode 100644 index 000000000..15ab74d2d --- /dev/null +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -0,0 +1,96 @@ +mode: grid + +output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full + +sampling_seed: 0 + +startseed: 0 +endseed: 3 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_aug.py + dmem: False + lr: 5e-5 + epos: 500 + epos_min: 20 + es: 1 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + pperm: 0.5 + + +Shared params: + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: loguniform + + k_i_gain_ratio: + min: 0.1 + max: 1 + num: 4 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00005 + num: 2 + distribution: loguniform + + pperm: + min: 0.1 + max: 0.9 + num: 3 + distribution: uniform + + gamma_reg: + min: 0.01 + max: 10_000 + num: 4 + distribution: loguniform + + mu_clip: + distribution: categorical + datatype: float + values: + - 1 + - 10 + - 100 + - 1000 + +# Test fbopt with different hyperparameter configurations + +jigen_feedback: + aname: jigen + trainer: fbopt + ini_setpoint_ratio: 0.99 + mu_init: 1e-6 + shared: + - k_i_gain_ratio + - mu_clip + +jigen_feedforward: + aname: jigen + trainer: hyperscheduler + shared: + - gamma_reg + +jigen_fixed_penalty: + aname: jigen + trainer: basic + shared: + - gamma_reg + +erm: + aname: deepall From c2d501542a42997621b545fca05b0e9ee847d9bc Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Tue, 31 Oct 2023 12:08:54 -0400 Subject: [PATCH 621/762] set arrow head size dynamically --- domainlab/utils/generate_fbopt_phase_portrait.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 398e8c621..b58d2ff83 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -66,15 +66,19 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, # truncate x and y to the desired length: x, y = x[:plot_len], y[:plot_len] + head_w_glob = min((max(x) - min(x)) / 100.0, (max(y) - min(y)) / 100.0) for i in range(plot_len - 1): + xy_dist = np.sqrt((x[i + 1] - x[i])**2 + (y[i + 1] - y[i])**2) + head_l = xy_dist / 30.0 + head_w = min(head_l, head_w_glob) plt.arrow(x[i], y[i], (x[i + 1] - x[i]), (y[i + 1] - y[i]), - head_width=0.15, head_length=0.2, - length_includes_head=False, - fc=colors[event_i], ec=colors[event_i], alpha=0.4) + head_width=head_w, head_length=head_l, + length_includes_head=True, + fc=colors[event_i], ec=colors[event_i], alpha=0.8) # the combination of head_width and head_length make the arrow - # more visible - # length_includes_head=False will put arrow out of point, which let - # point more visible, otherwise arrow will cover point + # more visible. + # length_includes_head=False makes the arrow stick too far out + # beyond of the point, which let; so, True is used. colors = ['red', 'green', 'blue', 'yellow', 'purple'] plt.plot(x[0], y[0], 'ko') From b085b29d9d79fa0c0b5b871d726b78bea38511e7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 1 Nov 2023 11:03:46 +0100 Subject: [PATCH 622/762] yaml --- .../pacs_jigen_fbopt_alone_autoki.yaml | 3 ++- .../pacs_jigen_fbopt_and_baselines_aug.yaml | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml index 50486d26d..06562a5d0 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -27,7 +27,8 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 - pperm: 0.5 + pperm: 0.1 + # pperm correspond to 1-bias_wholeimage in https://github.com/fmcarlucci/JigenDG Shared params: diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml index 15ab74d2d..6cad963b9 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -13,7 +13,6 @@ test_domains: domainlab_args: tpath: examples/tasks/task_pacs_aug.py dmem: False - lr: 5e-5 epos: 500 epos_min: 20 es: 1 @@ -26,10 +25,16 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 - pperm: 0.5 + pperm: 0.1 Shared params: + lr: + distribution: categorical + values: + - 5e-5 + - 1e-3 + k_i_gain: min: 0.0001 max: 0.01 @@ -56,7 +61,7 @@ Shared params: gamma_reg: min: 0.01 - max: 10_000 + max: 10 num: 4 distribution: loguniform @@ -64,10 +69,10 @@ Shared params: distribution: categorical datatype: float values: - - 1 + - 0.01 + - 0.1 + - 1.0 - 10 - - 100 - - 1000 # Test fbopt with different hyperparameter configurations @@ -79,18 +84,21 @@ jigen_feedback: shared: - k_i_gain_ratio - mu_clip + - lr jigen_feedforward: aname: jigen trainer: hyperscheduler shared: - gamma_reg + - lr jigen_fixed_penalty: aname: jigen trainer: basic shared: - gamma_reg + - lr erm: aname: deepall From 822b42dcfcb7536b7a058f8d66498259d87e4383 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 1 Nov 2023 14:08:02 +0100 Subject: [PATCH 623/762] force_setpoint_change_once --- examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml index 6cad963b9..c434159de 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -81,6 +81,7 @@ jigen_feedback: trainer: fbopt ini_setpoint_ratio: 0.99 mu_init: 1e-6 + force_setpoint_change_once: True shared: - k_i_gain_ratio - mu_clip From 9e9c37d16722c8f1f3a318a1512437a57768b7c7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 1 Nov 2023 15:38:45 +0100 Subject: [PATCH 624/762] increae iteratino jigen --- examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml index c434159de..ce2424a80 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -14,7 +14,7 @@ domainlab_args: tpath: examples/tasks/task_pacs_aug.py dmem: False epos: 500 - epos_min: 20 + epos_min: 200 es: 1 bs: 64 san_check: False From 2cfebe1b929e22ce00740e19220b7f8bd24d5a59 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 2 Nov 2023 15:28:02 +0100 Subject: [PATCH 625/762] basline jigen --- examples/benchmark/pacs_jigen_baslines4fbopt.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml index 2cc493318..db5c1af91 100644 --- a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -11,7 +11,7 @@ test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py + tpath: examples/tasks/task_pacs_aug.py dmem: False lr: 5e-5 epos: 200 @@ -26,7 +26,6 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 - pperm: 0.5 Shared params: @@ -50,8 +49,8 @@ Shared params: gamma_reg: min: 0.01 - max: 10_000 - num: 10 + max: 10 + num: 5 distribution: loguniform # Test fbopt with different hyperparameter configurations @@ -62,12 +61,14 @@ jigen_feedforward: trainer: hyperscheduler shared: - gamma_reg + - pperm jigen_fixed_penalty: aname: jigen trainer: basic shared: - gamma_reg + - pperm erm: aname: deepall From 107f595ebabc6aed9e43695622d6284c7df2e640 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 2 Nov 2023 15:30:05 +0100 Subject: [PATCH 626/762] enable san check --- examples/benchmark/pacs_jigen_baslines4fbopt.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml index db5c1af91..0a711846a 100644 --- a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -18,7 +18,7 @@ domainlab_args: epos_min: 20 es: 1 bs: 64 - san_check: False + san_check: True npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py From 946986e4ece3d908807f5d761b9f593bf53e3b17 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 2 Nov 2023 15:43:24 +0100 Subject: [PATCH 627/762] force feedforwrad in feedback --- domainlab/algos/trainers/args_fbopt.py | 4 ++++ domainlab/algos/trainers/train_fbopt_b.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 16ce6df5a..2039ce2d4 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -41,6 +41,10 @@ def add_args2parser_fbopt(parser): help='before training start, evaluate reg loss, \ setpoint will be 0.9 of this loss') + parser.add_argument('--force_feedforward', action='store_true', + default=False, + help='use feedforward scheduler') + parser.add_argument('--force_setpoint_change_once', action='store_true', default=False, help='train until the setpoint changed at least once \ diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index d08e45216..a82201382 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -5,6 +5,7 @@ import torch from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.fbopt_mu_controller import HyperSchedulerFeedback +from domainlab.algos.trainers.hyper_scheduler import HyperSchedulerWarmup def list_divide(list_val, scalar): @@ -82,7 +83,10 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.flag_setpoint_updated = False - self.set_scheduler(scheduler=HyperSchedulerFeedback) + if self.aconf.force_feedforward: + self.set_scheduler(scheduler=HyperSchedulerWarmup) + else: + self.set_scheduler(scheduler=HyperSchedulerFeedback) self.set_model_with_mu() # very small value if self.aconf.tr_with_init_mu: From 0ca02c6dc28014822ae38946dfb0606bd3967002 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 2 Nov 2023 16:54:21 +0100 Subject: [PATCH 628/762] use aug in diva --- .../pacs_diva_fbopt_and_baselines.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index f18cf72a7..969798ae5 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -5,17 +5,17 @@ output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_baselines sampling_seed: 0 startseed: 0 -endseed: 6 +endseed: 3 test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py + tpath: examples/tasks/task_pacs_aug.py dmem: False lr: 5e-5 - epos: 200 - epos_min: 20 + epos: 500 + epos_min: 100 es: 1 bs: 64 san_check: False @@ -43,6 +43,13 @@ Shared params: num: 3 distribution: uniform + k_i_gain_ratio: + min: 0.1 + max: 1 + num: 3 + distribution: uniform + + mu_init: min: 0.000001 max: 0.9 @@ -82,7 +89,7 @@ diva_fbopt_a: coeff_ma_output_state: 0.1 mu_init: 1e-6 shared: - - k_i_gain + - k_i_gain_ratio - mu_clip diva_feedforward_full: From d6056702b1bdbafbdf5dafb7f578148d30a510cd Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 2 Nov 2023 17:20:15 +0100 Subject: [PATCH 629/762] . --- run_fbopt_mnist_feedforward.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 run_fbopt_mnist_feedforward.sh diff --git a/run_fbopt_mnist_feedforward.sh b/run_fbopt_mnist_feedforward.sh new file mode 100644 index 000000000..d7c56fa1d --- /dev/null +++ b/run_fbopt_mnist_feedforward.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py + +python main_out.py --te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --aname=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=2000 --epos_min=100 --es=1 --force_feedforward From 6fd6107f17e0188208e095ac6c0b0c40b5325f1b Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 3 Nov 2023 16:06:14 +0100 Subject: [PATCH 630/762] . --- examples/benchmark/pacs_jigen_baslines4fbopt.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml index 0a711846a..0ee438d73 100644 --- a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -14,8 +14,8 @@ domainlab_args: tpath: examples/tasks/task_pacs_aug.py dmem: False lr: 5e-5 - epos: 200 - epos_min: 20 + epos: 500 + epos_min: 100 es: 1 bs: 64 san_check: True From 0f1e8510d49017719901f7ac04f7aa858ce212e5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 3 Nov 2023 16:08:36 +0100 Subject: [PATCH 631/762] . --- examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml index ce2424a80..898915475 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/benchmark_fbopt_pacs_full +output_dir: zoutput/benchmarks/pacs_aug_jigen sampling_seed: 0 From 439e6deecb7492e32fc52ed73e97eb846f2e158b Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 3 Nov 2023 17:04:50 +0100 Subject: [PATCH 632/762] Update pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml --- .../benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml index 2a0532ef7..a2b563b0f 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 500 - epos_min: 20 + epos_min: 200 es: 1 bs: 64 san_check: False From 77c9f66964eeb54ccae7c97a735bfae3c2ae0c62 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 3 Nov 2023 17:05:36 +0100 Subject: [PATCH 633/762] Update pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml --- .../pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml index a2b563b0f..f7a2aa5e9 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -67,9 +67,9 @@ Shared params: k_i_gain_ratio: min: 0.1 - max: 1 + max: 10 num: 10 - distribution: uniform + distribution: loguniform mu_init: min: 0.000001 From 20d62d333eb665182a87b30b06acca32786778fa Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 3 Nov 2023 17:14:34 +0100 Subject: [PATCH 634/762] . --- .../pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml index f7a2aa5e9..c69aaf61d 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/pacs_diva_fbopt_autoki_oct27 +output_dir: zoutput/benchmarks/pacs_diva_fbopt_autoki_aug sampling_seed: 0 @@ -11,7 +11,7 @@ test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py + tpath: examples/tasks/task_pacs_aug.py dmem: False lr: 5e-5 epos: 500 From c272ec5116b3275ddddbf5f61e62ff00f287bb17 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 10:25:12 +0100 Subject: [PATCH 635/762] new command for list errors --- sh_list_error.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh_list_error.sh b/sh_list_error.sh index e4b5ebe7e..fc989cdc3 100644 --- a/sh_list_error.sh +++ b/sh_list_error.sh @@ -1,2 +1,2 @@ # find $1 -type f -print0 | xargs -0 grep -li error -grep -wnr "error" $1 +grep -B 20 -wnr "error" --group-separator="========================" $1 From c44a529a8e30cec5cd4c64dc76818461ec8d0f10 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 10:51:31 +0100 Subject: [PATCH 636/762] 200 epochs for diva --- examples/benchmark/pacs_diva_fbopt_and_baselines.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index 969798ae5..de969ffdc 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_baselines +output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_baselines_aug sampling_seed: 0 @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 500 - epos_min: 100 + epos_min: 200 es: 1 bs: 64 san_check: False From 3b580e24c9aa7db7e73a470aa0a28c0fd7dbcef9 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 11:13:36 +0100 Subject: [PATCH 637/762] sbmit comamnd update --- sbatch4submit_slurm_cpu_10days.sh | 2 +- sbatch4submit_slurm_cpu_3days.sh | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sbatch4submit_slurm_cpu_10days.sh b/sbatch4submit_slurm_cpu_10days.sh index 1d5bb4db0..aefacae97 100755 --- a/sbatch4submit_slurm_cpu_10days.sh +++ b/sbatch4submit_slurm_cpu_10days.sh @@ -3,7 +3,7 @@ VENV="domainlab_py39" BASHRC="~/.bashrc" # source ~/.bash_profile ## -JOB_NAME="domainlab" +JOB_NAME="submit10d" PATH_CODE=$1 PATH_OUT_BASE="${PATH_CODE}/job_logs" mkdir -p $PATH_OUT_BASE diff --git a/sbatch4submit_slurm_cpu_3days.sh b/sbatch4submit_slurm_cpu_3days.sh index 7e46869cd..cbbd89639 100755 --- a/sbatch4submit_slurm_cpu_3days.sh +++ b/sbatch4submit_slurm_cpu_3days.sh @@ -3,21 +3,24 @@ VENV="domainlab_py39" BASHRC="~/.bashrc" # source ~/.bash_profile ## -JOB_NAME="domainlab" +JOB_NAME="submit" PATH_CODE=$1 -PATH_OUT_BASE="${PATH_CODE}/job_logs" +PATH_OUT_BASE="${PATH_CODE}/submit_job_logs" mkdir -p $PATH_OUT_BASE PATH_YAML=$2 START_SEED=$3 - +ACTIVE_TIME="3-00:00:00" job_file="${PATH_OUT_BASE}/${JOB_NAME}.cmd" + + +# echo the following line to ${job_file} echo "#!/bin/bash #SBATCH -J ${JOB_NAME} #SBATCH -o ${PATH_OUT_BASE}/${JOB_NAME}.out #SBATCH -e ${PATH_OUT_BASE}/${JOB_NAME}.err #SBATCH -p cpu_p -#SBATCH -t 3-00:00:00 +#SBATCH -t ${ACTIVE_TIME} #SBATCH -c 20 #SBATCH --mem=32G #SBATCH --qos=cpu_normal @@ -29,4 +32,6 @@ conda activate ${VENV} ${PATH_CODE}/run_benchmark_slurm.sh ${PATH_CODE}/${PATH_YAML} ${START_SEED} " > ${job_file} +# end of echo + sbatch ${job_file} From 849d3c26d8b23c84c4c05d436f74d21114a20c70 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 11:40:25 +0100 Subject: [PATCH 638/762] no flip for jigen --- examples/benchmark/pacs_jigen_baslines4fbopt.yaml | 2 +- examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml index 0ee438d73..ab7ae8a57 100644 --- a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -11,7 +11,7 @@ test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_aug.py + tpath: examples/tasks/task_pacs_aug_noflip.py dmem: False lr: 5e-5 epos: 500 diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml index 898915475..8f4a09093 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -11,7 +11,7 @@ test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_aug.py + tpath: examples/tasks/task_pacs_aug_noflip.py dmem: False epos: 500 epos_min: 200 From 738c667fea56099782c5222543e6dde52ebfbeeb Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 12:16:52 +0100 Subject: [PATCH 639/762] hduva --- ...pacs_hduva_fbopt_alone_es1_autoki_aug.yaml | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml diff --git a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml new file mode 100644 index 000000000..3f4650228 --- /dev/null +++ b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml @@ -0,0 +1,106 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_hduva_fbopt_alone_aug + +sampling_seed: 0 + +startseed: 0 +endseed: 10 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_aug.py + dmem: False + lr: 5e-5 + epos: 500 + epos_min: 200 + es: 1 + bs: 64 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + - 0.8 + + mu_clip: + distribution: categorical + datatype: float + values: + - 10 + - 1000 + - 1 + - 100 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: uniform + + k_i_gain_ratio: + min: 0.1 + max: 10 + num: 10 + distribution: loguniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + aname: hduva + trainer: fbopt + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + mu_init: 1e-6 + shared: + - k_i_gain_ratio From 33f937790c574bdc2ff62db7604872de5d51735f Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 12:23:54 +0100 Subject: [PATCH 640/762] jigen no flip yaml --- .../benchmark/pacs_jigen_fbopt_alone.yaml | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone.yaml b/examples/benchmark/pacs_jigen_fbopt_alone.yaml index bc32a6771..527c8a240 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone.yaml @@ -11,14 +11,14 @@ test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py + tpath: examples/tasks/task_pacs_aug_noflip.py dmem: False lr: 5e-5 - epos: 200 - epos_min: 20 + epos: 500 + epos_min: 200 es: 1 bs: 64 - san_check: False + san_check: True npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py @@ -26,7 +26,6 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 - pperm: 0.5 Shared params: @@ -36,6 +35,14 @@ Shared params: num: 3 distribution: loguniform + k_i_gain_ratio: + min: 0.1 + max: 10 + num: 3 + distribution: loguniform + + + mu_init: min: 0.000001 max: 0.00005 @@ -44,7 +51,7 @@ Shared params: pperm: min: 0.1 - max: 0.9 + max: 0.7 num: 3 distribution: uniform @@ -71,5 +78,5 @@ jigen_feedback: coeff_ma: 0.5 mu_init: 1e-6 shared: - - k_i_gain - - coeff_ma_output_state + - k_i_gain_ratio + - pperm From 01b229ee00727432bfa61f680fac8a70857499aa Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 12:28:25 +0100 Subject: [PATCH 641/762] add missing attribute for hduva list of names for reg loss --- domainlab/models/model_hduva.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index 6d311bc57..7981f2413 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -170,6 +170,13 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): return [loss_recon_x, zx_p_minus_q, zy_p_minus_zy_q, zd_p_minus_q, topic_p_minus_q], \ [self.mu_recon, -self.beta_x, -self.beta_y, -self.beta_d, -self.beta_t] + @property + def list_str_multiplier_na(self): + """ + list of multipliers name + """ + return ["mu_recon", "beta_x", "beta_y", "beta_d", "beta_t"] + def extract_semantic_features(self, tensor_x): """ :param tensor_x: From f87d141396d08ec623f88e186ec0cef82832e38d Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 13:25:18 +0100 Subject: [PATCH 642/762] less bs for hduva --- examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml index 3f4650228..75ef3e9c3 100644 --- a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml +++ b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml @@ -17,7 +17,7 @@ domainlab_args: epos: 500 epos_min: 200 es: 1 - bs: 64 + bs: 16 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py From d1600669bab4e6bbfcec864acdd24d00ccd2b287 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 13:44:38 +0100 Subject: [PATCH 643/762] add erm to no flip augmentation --- examples/benchmark/pacs_jigen_fbopt_alone.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/benchmark/pacs_jigen_fbopt_alone.yaml b/examples/benchmark/pacs_jigen_fbopt_alone.yaml index 527c8a240..fa8f865a3 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone.yaml @@ -80,3 +80,6 @@ jigen_feedback: shared: - k_i_gain_ratio - pperm + +erm: + aname: deepall From 20856572324c879ab142d1ed4a833b5dee4b26ce Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 6 Nov 2023 14:04:29 +0100 Subject: [PATCH 644/762] find hyperindx from slurm id --- sh_list_job_via_slurm_id.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 sh_list_job_via_slurm_id.sh diff --git a/sh_list_job_via_slurm_id.sh b/sh_list_job_via_slurm_id.sh new file mode 100644 index 000000000..d8e2272ce --- /dev/null +++ b/sh_list_job_via_slurm_id.sh @@ -0,0 +1 @@ +find zoutput/slurm_logs/run_experiment/ | grep -i "$1" From c2c4fc2c99b6a7aa58d87b973fe84e38a0573604 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 7 Nov 2023 15:08:27 +0100 Subject: [PATCH 645/762] fix issue #528 print model multiplier from model instead of scheduler --- domainlab/algos/trainers/train_fbopt_b.py | 4 ++++ domainlab/models/model_diva.py | 11 +++++++++++ domainlab/models/model_hduva.py | 13 ++++++++++++- domainlab/models/model_jigen.py | 10 ++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index a82201382..4176a77b3 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -6,6 +6,7 @@ from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.fbopt_mu_controller import HyperSchedulerFeedback from domainlab.algos.trainers.hyper_scheduler import HyperSchedulerWarmup +from domainlab.utils.logger import Logger def list_divide(list_val, scalar): @@ -129,6 +130,9 @@ def tr_epoch(self, epoch, flag_info=False): self.list_str_multiplier_na, miter=epoch) self.set_model_with_mu() + if hasattr(self.model, "dict_multiplier"): + logger = Logger.get_logger() + logger.info(f"current multiplier: {self.model.dict_multiplier}") flag = super().tr_epoch(epoch, self.flag_setpoint_updated) # is it good to update setpoint after we know the new value of each loss? diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index dfb8acdb6..a011bc6c6 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -114,6 +114,17 @@ def list_str_multiplier_na(self): """ return ["mu_recon", "beta_d", "beta_x", "beta_y", "gamma_d"] + @property + def dict_multiplier(self): + """ + list of multipliers name + """ + return {"mu_recon": self.mu_recon, + "beta_d": self.beta_d, + "beta_x": self.beta_x, + "beta_y": self.beta_y, + "gamma_d": self.gamma_d} + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): q_zd, zd_q, q_zx, zx_q, q_zy, zy_q = self.encoder(tensor_x) logit_d = self.net_classif_d(zd_q) diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index 7981f2413..08779f49d 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -173,10 +173,21 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): @property def list_str_multiplier_na(self): """ - list of multipliers name + list of multipliers name which matches the order from cal_reg_loss """ return ["mu_recon", "beta_x", "beta_y", "beta_d", "beta_t"] + @property + def dict_multiplier(self): + """ + dictionary of multipliers name + """ + return {"mu_recon": self.mu_recon, + "beta_d": self.beta_d, + "beta_x": self.beta_x, + "beta_y": self.beta_y, + "beta_t": self.beta_t} + def extract_semantic_features(self, tensor_x): """ :param tensor_x: diff --git a/domainlab/models/model_jigen.py b/domainlab/models/model_jigen.py index 7c55cf4f0..db38bbadc 100644 --- a/domainlab/models/model_jigen.py +++ b/domainlab/models/model_jigen.py @@ -67,8 +67,18 @@ def __init__(self, list_str_y, list_str_d, @property def list_str_multiplier_na(self): + """ + list of multipliers which match the order in cal_reg_loss + """ return ["alpha"] + @property + def dict_multiplier(self): + """ + dictionary of multipliers + """ + return {"alpha": self.alpha} + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): """ JiGen don't need domain label but a pre-defined permutation index From 82afc2a26c498e4827e0ac81b0684b0d33e22e2f Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 9 Nov 2023 16:42:30 +0100 Subject: [PATCH 646/762] smalelr batch size --- examples/benchmark/pacs_diva_fbopt_and_baselines.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index de969ffdc..5ed48a685 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -17,7 +17,7 @@ domainlab_args: epos: 500 epos_min: 200 es: 1 - bs: 64 + bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py From b5dcff53b471bc6ada88a952224fcfc2bbe77a67 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 10 Nov 2023 16:53:54 +0100 Subject: [PATCH 647/762] fix issue # 636 --- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 09901af72..60dd20fec 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -15,15 +15,15 @@ domainlab_args: dmem: False lr: 5e-5 epos: 500 - epos_min: 20 + epos_min: 200 es: 1 - bs: 64 + bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py - zx_dim: 0 + zx_dim: 16 zy_dim: 64 zd_dim: 64 @@ -101,7 +101,8 @@ diva_fbopt_full: gamma_y: 1.0 ini_setpoint_ratio: 0.99 str_diva_multiplier_type: gammad_recon - coeff_ma_output_state: 0.1 + coeff_ma_output_state: 0 + coeff_ma_setpoint: 0 mu_init: 1e-6 shared: - k_i_gain_ratio From d226b28738ecab7cbc2f28b99c29047d3de662d1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 10 Nov 2023 16:55:17 +0100 Subject: [PATCH 648/762] . --- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 60dd20fec..df8435644 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone_zx sampling_seed: 0 From 4e4dac1b963a6f2a9634fd2b296a6a448d8004e6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 15 Nov 2023 16:57:29 +0100 Subject: [PATCH 649/762] hduva basleine --- examples/benchmark/pacs_hduva_baselines.yaml | 111 +++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 examples/benchmark/pacs_hduva_baselines.yaml diff --git a/examples/benchmark/pacs_hduva_baselines.yaml b/examples/benchmark/pacs_hduva_baselines.yaml new file mode 100644 index 000000000..b6fa503b1 --- /dev/null +++ b/examples/benchmark/pacs_hduva_baselines.yaml @@ -0,0 +1,111 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_hduva_fbopt_alone_aug + +sampling_seed: 0 + +startseed: 0 +endseed: 10 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_aug.py + dmem: False + lr: 5e-5 + epos: 500 + epos_min: 200 + es: 1 + bs: 16 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + - 0.8 + + mu_clip: + distribution: categorical + datatype: float + values: + - 10 + - 1000 + - 1 + - 100 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: uniform + + k_i_gain_ratio: + min: 0.1 + max: 10 + num: 10 + distribution: loguniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +hduva_beta_warmup: + aname: hduva + shared: + - gamma_y + +hduva_fbopt_full: + aname: hduva + trainer: fbopt + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + mu_init: 1e-6 + shared: + - k_i_gain_ratio From 85c69a04204a99e66693b5e284081039443c90ef Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 15 Nov 2023 16:59:45 +0100 Subject: [PATCH 650/762] . --- examples/benchmark/pacs_hduva_baselines.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_hduva_baselines.yaml b/examples/benchmark/pacs_hduva_baselines.yaml index b6fa503b1..b9365f261 100644 --- a/examples/benchmark/pacs_hduva_baselines.yaml +++ b/examples/benchmark/pacs_hduva_baselines.yaml @@ -1,6 +1,6 @@ mode: grid -output_dir: zoutput/benchmarks/pacs_hduva_fbopt_alone_aug +output_dir: zoutput/benchmarks/pacs_hduva_fbopt_and_baselines sampling_seed: 0 From f6b0f806274d15a78fa5ea173d18edae446ee1d2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 16 Nov 2023 16:13:24 +0100 Subject: [PATCH 651/762] doc --- domainlab/models/model_diva.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index a011bc6c6..06d1b9e7f 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -117,7 +117,7 @@ def list_str_multiplier_na(self): @property def dict_multiplier(self): """ - list of multipliers name + list of multipliers name, which correspond to cal_reg_loss """ return {"mu_recon": self.mu_recon, "beta_d": self.beta_d, From 01810c7189ddbdf320c2538c457e3437e33aff93 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 16 Nov 2023 17:18:27 +0100 Subject: [PATCH 652/762] not sure if we really need wrapper --- domainlab/algos/builder_match_hduva.py | 4 ++-- domainlab/models/model_wrapper_matchdg4vae.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/builder_match_hduva.py b/domainlab/algos/builder_match_hduva.py index 1c1c77bfe..612a578db 100644 --- a/domainlab/algos/builder_match_hduva.py +++ b/domainlab/algos/builder_match_hduva.py @@ -63,10 +63,10 @@ def init_business(self, exp): beta_y=args.beta_y, beta_d=args.beta_d) - model = ModelWrapMatchDGVAE(model, list_str_y=task.list_str_y) + # model = ModelWrapMatchDGVAE(model, list_str_y=task.list_str_y) model = model.to(device) - ctr_model = ModelWrapMatchDGVAE(model_ctr, list_str_y=task.list_str_y) + # ctr_model = ModelWrapMatchDGVAE(model_ctr, list_str_y=task.list_str_y) ctr_model = ctr_model.to(device) model_sel = MSelOracleVisitor(MSelValPerf(max_es=args.es)) diff --git a/domainlab/models/model_wrapper_matchdg4vae.py b/domainlab/models/model_wrapper_matchdg4vae.py index 20634f378..ea2b62221 100644 --- a/domainlab/models/model_wrapper_matchdg4vae.py +++ b/domainlab/models/model_wrapper_matchdg4vae.py @@ -27,3 +27,9 @@ def extract_semantic_feat(self, tensor_x): """ feat = self.net.extract_semantic_features(tensor_x) return feat + + def hyper_init(self, functor_scheduler, trainer=None): + self.net.hyper_init(functor_scheduler, trainer) + + def hyper_update(self, epoch, fun_scheduler): + self.net.hyper_update(epoch, fun_scheduler) From 088cc9c5cfa3fac6a226ba2cba4beb02c41cdcbe Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 16 Nov 2023 17:28:28 +0100 Subject: [PATCH 653/762] removed wrapper, memory too small --- domainlab/algos/builder_match_hduva.py | 3 ++- domainlab/models/model_hduva.py | 3 +++ test_match_duva.sh | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test_match_duva.sh diff --git a/domainlab/algos/builder_match_hduva.py b/domainlab/algos/builder_match_hduva.py index 612a578db..44ca2f2e4 100644 --- a/domainlab/algos/builder_match_hduva.py +++ b/domainlab/algos/builder_match_hduva.py @@ -67,7 +67,8 @@ def init_business(self, exp): model = model.to(device) # ctr_model = ModelWrapMatchDGVAE(model_ctr, list_str_y=task.list_str_y) - ctr_model = ctr_model.to(device) + # ctr_model = ctr_model.to(device) + ctr_model = model_ctr.to(device) model_sel = MSelOracleVisitor(MSelValPerf(max_es=args.es)) observer = ObVisitor(model_sel, diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index 08779f49d..8dc83899e 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -195,4 +195,7 @@ def extract_semantic_features(self, tensor_x): zy_q_loc = self.encoder.infer_zy_loc(tensor_x) return zy_q_loc + def extract_semantic_feat(self, tensor_x): + return self.extract_semantic_features(tensor_x) + return ModelHDUVA diff --git a/test_match_duva.sh b/test_match_duva.sh new file mode 100644 index 000000000..86926284a --- /dev/null +++ b/test_match_duva.sh @@ -0,0 +1,4 @@ +python main_out.py --te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=matchhduva \ + --epochs_ctr=3 --epos=6 --npath=examples/nets/resnet.py --gamma_y=7e5 \ + --npath_topic_distrib_img2topic=examples/nets/resnet.py \ + --npath_encoder_sandwich_layer_img2h4zd=examples/nets/resnet.py From 3230af0f9a0d256e0ae06a224ae8364e0c350ed4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 16 Nov 2023 17:34:34 +0100 Subject: [PATCH 654/762] . --- test_match_duva.sh | 10 ++++++---- test_match_duva_vlcs.sh | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 test_match_duva_vlcs.sh diff --git a/test_match_duva.sh b/test_match_duva.sh index 86926284a..39816019e 100644 --- a/test_match_duva.sh +++ b/test_match_duva.sh @@ -1,4 +1,6 @@ -python main_out.py --te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=matchhduva \ - --epochs_ctr=3 --epos=6 --npath=examples/nets/resnet.py --gamma_y=7e5 \ - --npath_topic_distrib_img2topic=examples/nets/resnet.py \ - --npath_encoder_sandwich_layer_img2h4zd=examples/nets/resnet.py +python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --debug --bs=2 --aname=matchhduva \ + --epochs_ctr=3 --epos=6 --nname=conv_bn_pool_2 --gamma_y=7e5 \ + --nname_topic_distrib_img2topic=conv_bn_pool_2 \ + --nname_encoder_sandwich_layer_img2h4zd=conv_bn_pool_2 + + diff --git a/test_match_duva_vlcs.sh b/test_match_duva_vlcs.sh new file mode 100644 index 000000000..86926284a --- /dev/null +++ b/test_match_duva_vlcs.sh @@ -0,0 +1,4 @@ +python main_out.py --te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=matchhduva \ + --epochs_ctr=3 --epos=6 --npath=examples/nets/resnet.py --gamma_y=7e5 \ + --npath_topic_distrib_img2topic=examples/nets/resnet.py \ + --npath_encoder_sandwich_layer_img2h4zd=examples/nets/resnet.py From a5d252dc6515568f135fe87f6c1e165c32907b38 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 17 Nov 2023 10:11:20 +0100 Subject: [PATCH 655/762] lower mu clip hduva --- .../benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml index 75ef3e9c3..b1add4f40 100644 --- a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml +++ b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml @@ -15,8 +15,8 @@ domainlab_args: dmem: False lr: 5e-5 epos: 500 - epos_min: 200 - es: 1 + epos_min: 100 + es: 10 bs: 16 san_check: False npath: examples/nets/resnet50domainbed.py @@ -102,5 +102,6 @@ diva_fbopt_full: gamma_y: 1.0 ini_setpoint_ratio: 0.99 mu_init: 1e-6 + mu_clip: 10 shared: - k_i_gain_ratio From 8a4e4647c8283b36e71038701637fe242f2b5a84 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 17 Nov 2023 14:01:00 +0100 Subject: [PATCH 656/762] defautl extrac feat to cal logit --- domainlab/models/a_model_classif.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/domainlab/models/a_model_classif.py b/domainlab/models/a_model_classif.py index ae1814b95..c9102ccb7 100644 --- a/domainlab/models/a_model_classif.py +++ b/domainlab/models/a_model_classif.py @@ -60,6 +60,13 @@ def evaluate(self, loader_te, device): logger = Logger.get_logger() logger.info(f"before training, model accuracy: {acc}") + def extract_semantic_feat(self, tensor_x): + """ + by default, use the logit as extracted feature if the current method + is not being overriden by child class + """ + return self.cal_logit_y(tensor_x) + @abc.abstractmethod def cal_logit_y(self, tensor_x): """ @@ -199,4 +206,4 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): """ device = tensor_x.device bsize = tensor_x.shape[0] - return [torch.zeros(bsize, 1).to(device)], [0.0] \ No newline at end of file + return [torch.zeros(bsize, 1).to(device)], [0.0] From 37aa8d5c8a80bcdb1a9aaabd94dad8168e924e80 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 17 Nov 2023 15:05:05 +0100 Subject: [PATCH 657/762] doc --- domainlab/algos/builder_matchdg.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/algos/builder_matchdg.py b/domainlab/algos/builder_matchdg.py index 42bd7deff..bf556ab1a 100644 --- a/domainlab/algos/builder_matchdg.py +++ b/domainlab/algos/builder_matchdg.py @@ -62,6 +62,8 @@ def init_business(self, exp): i_c=task.isize.i_c, i_h=task.isize.i_h, i_w=task.isize.i_w) + # different than model, ctr_model has no classification so it has + # different wrapper ctr_model = ModelWrapMatchDGNet(ctr_net, list_str_y=task.list_str_y) ctr_model = ctr_model.to(device) From 845dcd3e83044eb3656ddfe7f9ffbf775c19be80 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 17 Nov 2023 16:24:18 +0100 Subject: [PATCH 658/762] no need for warp --- domainlab/algos/builder_match_hduva.py | 24 ++++++------------------ domainlab/models/model_hduva.py | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/domainlab/algos/builder_match_hduva.py b/domainlab/algos/builder_match_hduva.py index 1c1c77bfe..287211dc8 100644 --- a/domainlab/algos/builder_match_hduva.py +++ b/domainlab/algos/builder_match_hduva.py @@ -1,6 +1,8 @@ """ hduva with matchdg """ +import copy + from domainlab.algos.a_algo_builder import NodeAlgoBuilder from domainlab.algos.msels.c_msel_val import MSelValPerf from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor @@ -47,27 +49,13 @@ def init_business(self, exp): beta_x=args.beta_x, beta_y=args.beta_y, beta_d=args.beta_d) + model_ctr = copy.deepcopy(model) - model_ctr = mk_hduva()(node, - zd_dim=args.zd_dim, - zy_dim=args.zy_dim, - zx_dim=args.zx_dim, - device=device, - topic_dim=args.topic_dim, - list_str_y=task.list_str_y, - list_d_tr=task.list_domain_tr, - gamma_d=args.gamma_d, - gamma_y=args.gamma_y, - beta_t=args.beta_t, - beta_x=args.beta_x, - beta_y=args.beta_y, - beta_d=args.beta_d) - - model = ModelWrapMatchDGVAE(model, list_str_y=task.list_str_y) + # model = ModelWrapMatchDGVAE(model, list_str_y=task.list_str_y) model = model.to(device) - ctr_model = ModelWrapMatchDGVAE(model_ctr, list_str_y=task.list_str_y) - ctr_model = ctr_model.to(device) + # ctr_model = ModelWrapMatchDGVAE(model_ctr, list_str_y=task.list_str_y) + ctr_model = model_ctr.to(device) model_sel = MSelOracleVisitor(MSelValPerf(max_es=args.es)) observer = ObVisitor(model_sel, diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index 08779f49d..c8dc32430 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -146,8 +146,18 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): # from torch.distributions import kl_divergence # zy KL divergence - p_zy = self.net_p_zy(tensor_y) - zy_p_minus_zy_q = g_inst_component_loss_agg(p_zy.log_prob(zy_q) - qzy.log_prob(zy_q), 1) + + if (tensor_y.shape[-1] == 1) | (len(tensor_y.shape) == 1): + tensor_y_onehot = torch.nn.functional.one_hot( + tensor_y, + num_classes=len(self.list_str_y)) + tensor_y_onehot = tensor_y_onehot.to(torch.float32) + else: + tensor_y_onehot = tensor_y + + p_zy = self.net_p_zy(tensor_y_onehot) + zy_p_minus_zy_q = g_inst_component_loss_agg( + p_zy.log_prob(zy_q) - qzy.log_prob(zy_q), 1) # zx KL divergence zx_p_minus_q = torch.zeros_like(zy_p_minus_zy_q) @@ -188,7 +198,7 @@ def dict_multiplier(self): "beta_y": self.beta_y, "beta_t": self.beta_t} - def extract_semantic_features(self, tensor_x): + def extract_semantic_feat(self, tensor_x): """ :param tensor_x: """ From 7f82bc9c26c3ff4f70b8f564a4923837728a3098 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 17 Nov 2023 16:40:03 +0100 Subject: [PATCH 659/762] remove redundancy --- domainlab/models/model_hduva.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index 7a522ec83..c8dc32430 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -205,7 +205,4 @@ def extract_semantic_feat(self, tensor_x): zy_q_loc = self.encoder.infer_zy_loc(tensor_x) return zy_q_loc - def extract_semantic_feat(self, tensor_x): - return self.extract_semantic_features(tensor_x) - return ModelHDUVA From 23d2c511cc2f405924cdf6da1e6f897dead12349 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 17 Nov 2023 17:09:15 +0100 Subject: [PATCH 660/762] matchduva --- examples/benchmark/pacs_hduva_matchdg.yaml | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 examples/benchmark/pacs_hduva_matchdg.yaml diff --git a/examples/benchmark/pacs_hduva_matchdg.yaml b/examples/benchmark/pacs_hduva_matchdg.yaml new file mode 100644 index 000000000..1bd5421f5 --- /dev/null +++ b/examples/benchmark/pacs_hduva_matchdg.yaml @@ -0,0 +1,111 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_hduva_fbopt_alone_aug + +sampling_seed: 0 + +startseed: 0 +endseed: 10 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_aug.py + dmem: False + lr: 5e-5 + epos: 500 + epos_min: 100 + es: 10 + bs: 16 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + zx_dim: 0 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + - 0.8 + + mu_clip: + distribution: categorical + datatype: float + values: + - 10 + - 1000 + - 1 + - 100 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: uniform + + k_i_gain_ratio: + min: 0.1 + max: 10 + num: 10 + distribution: loguniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_reg: + min: 0.01 + max: 10 + distribution: loguniform + num: 3 + + + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +match_duva: + aname: matchhduva + shared: + - gamma_y + - gamma_reg From c73885e6f73991ce534e8adeaac9dd252db8d75c Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 22 Nov 2023 18:15:49 +0100 Subject: [PATCH 661/762] . --- examples/benchmark/pacs_hduva_matchdg.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/benchmark/pacs_hduva_matchdg.yaml b/examples/benchmark/pacs_hduva_matchdg.yaml index 1bd5421f5..2ae03aa94 100644 --- a/examples/benchmark/pacs_hduva_matchdg.yaml +++ b/examples/benchmark/pacs_hduva_matchdg.yaml @@ -106,6 +106,7 @@ Shared params: match_duva: aname: matchhduva + epochs_ctr: 10 shared: - gamma_y - gamma_reg From eb3890aa868d5cf186ab43cd9266aa5cab39db4e Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 23 Nov 2023 13:58:00 +0100 Subject: [PATCH 662/762] import --- domainlab/algos/builder_fbopt_dial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/builder_fbopt_dial.py b/domainlab/algos/builder_fbopt_dial.py index ef4b4ea66..d18c374e3 100644 --- a/domainlab/algos/builder_fbopt_dial.py +++ b/domainlab/algos/builder_fbopt_dial.py @@ -6,7 +6,7 @@ from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor from domainlab.algos.observers.b_obvisitor import ObVisitor from domainlab.algos.trainers.zoo_trainer import TrainerChainNodeGetter -from domainlab.algos.trainers.train_fbopt import TrainerFbOpt +from domainlab.algos.trainers.train_fbopt_b import TrainerFbOpt from domainlab.algos.trainers.train_dial import TrainerDIAL from domainlab.compos.zoo_nn import FeatExtractNNBuilderChainNodeGetter from domainlab.models.model_deep_all import mk_deepall From 049031717f691ced4836acbceec9b54dd32840c7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 23 Nov 2023 14:02:19 +0100 Subject: [PATCH 663/762] . --- test_fbopt_dial.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 test_fbopt_dial.sh diff --git a/test_fbopt_dial.sh b/test_fbopt_dial.sh new file mode 100644 index 000000000..417c73a4b --- /dev/null +++ b/test_fbopt_dial.sh @@ -0,0 +1 @@ +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=fboptdial --nname=alexnet From 04af111d6984db6acb710ba1c92875a9c29c6b37 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 23 Nov 2023 14:05:46 +0100 Subject: [PATCH 664/762] correct observer api --- domainlab/algos/builder_fbopt_dial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/builder_fbopt_dial.py b/domainlab/algos/builder_fbopt_dial.py index d18c374e3..a18d29e63 100644 --- a/domainlab/algos/builder_fbopt_dial.py +++ b/domainlab/algos/builder_fbopt_dial.py @@ -25,7 +25,7 @@ def init_business(self, exp): args = exp.args device = get_device(args) model_sel = MSelOracleVisitor(MSelValPerf(max_es=args.es)) - observer = ObVisitor(exp, model_sel, device) + observer = ObVisitor(model_sel, device, exp=exp) builder = FeatExtractNNBuilderChainNodeGetter( args, arg_name_of_net="nname", From 322bf5ac32750c2c8ebda1a0ddeb2fc69a9898f4 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 23 Nov 2023 15:27:39 +0100 Subject: [PATCH 665/762] as_model in mk_opt --- domainlab/algos/trainers/a_trainer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 485ae5ba1..4a4c7f04c 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -10,7 +10,7 @@ def mk_opt(model, aconf): """ create optimizer """ - optimizer = optim.Adam(model.parameters(), lr=aconf.lr) + optimizer = optim.Adam(model.as_model().parameters(), lr=aconf.lr) return optimizer @@ -93,7 +93,7 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True): self.flag_update_hyper_per_batch = False self.epo_loss_tr = None self.hyper_scheduler = None - self.optimizer = mk_opt(self.model.as_model(), self.aconf) + self.reset() self.flag_initialized = True def reset(self): From 6f3fd847416bb601c7d63998e578d7b9b025c11f Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 23 Nov 2023 15:30:56 +0100 Subject: [PATCH 666/762] . --- domainlab/algos/trainers/a_trainer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 4a4c7f04c..81913d52b 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -183,6 +183,7 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): use trainer as a model, this is the default behavior, if we want to have decorated behavior of regularization loss, then this default behavior has to be changed. """ + # FIXME: each trainer should implement this return self.get_model().cal_reg_loss(tensor_x, tensor_y, tensor_d) def cal_task_loss(self, tensor_x, tensor_y): From 4ac2c2f442a62e9cd4603f473c5b15628ce53a75 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 27 Nov 2023 10:04:30 +0100 Subject: [PATCH 667/762] fbot has to use as_model explicitly --- domainlab/algos/trainers/train_fbopt_b.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 4176a77b3..91ae04da5 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -117,7 +117,7 @@ def set_model_with_mu(self): """ set model multipliers """ - self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) + self.model.as_model().hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) def tr_epoch(self, epoch, flag_info=False): """ From 9f73eabaf4b095f8b22fe99ead892e05491d62cd Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 27 Nov 2023 10:59:51 +0100 Subject: [PATCH 668/762] dial diva --- domainlab/algos/builder_fbopt_dial.py | 35 ++++----------------------- domainlab/algos/trainers/a_trainer.py | 4 +-- test_fbopt_dial.sh | 2 +- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/domainlab/algos/builder_fbopt_dial.py b/domainlab/algos/builder_fbopt_dial.py index a18d29e63..81b5c3eae 100644 --- a/domainlab/algos/builder_fbopt_dial.py +++ b/domainlab/algos/builder_fbopt_dial.py @@ -1,19 +1,11 @@ """ builder for feedback optimization of dial """ -from domainlab.algos.a_algo_builder import NodeAlgoBuilder -from domainlab.algos.msels.c_msel_val import MSelValPerf -from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor -from domainlab.algos.observers.b_obvisitor import ObVisitor -from domainlab.algos.trainers.zoo_trainer import TrainerChainNodeGetter +from domainlab.algos.builder_diva import NodeAlgoBuilderDIVA from domainlab.algos.trainers.train_fbopt_b import TrainerFbOpt -from domainlab.algos.trainers.train_dial import TrainerDIAL -from domainlab.compos.zoo_nn import FeatExtractNNBuilderChainNodeGetter -from domainlab.models.model_deep_all import mk_deepall -from domainlab.utils.utils_cuda import get_device -class NodeAlgoBuilderFbOptDial(NodeAlgoBuilder): +class NodeAlgoBuilderFbOptDial(NodeAlgoBuilderDIVA): """ builder for feedback optimization for dial """ @@ -21,25 +13,8 @@ def init_business(self, exp): """ return trainer, model, observer """ - task = exp.task - args = exp.args - device = get_device(args) - model_sel = MSelOracleVisitor(MSelValPerf(max_es=args.es)) - observer = ObVisitor(model_sel, device, exp=exp) - - builder = FeatExtractNNBuilderChainNodeGetter( - args, arg_name_of_net="nname", - arg_path_of_net="npath")() # request, # @FIXME, constant string - - net = builder.init_business(flag_pretrain=True, dim_out=task.dim_y, - remove_last_layer=False, args=args, - i_c=task.isize.i_c, - i_h=task.isize.i_h, - i_w=task.isize.i_w) - - model = mk_deepall()(net, list_str_y=task.list_str_y) - trainer_in = TrainerDIAL() - trainer_in.init_business(model, task, observer, device, args) + trainer_in, model, observer, device = super().init_business(exp) + trainer_in.init_business(model, exp.task, observer, device, exp.args) trainer = TrainerFbOpt() - trainer.init_business(trainer_in, task, observer, device, args) + trainer.init_business(trainer_in, exp.task, observer, device, exp.args) return trainer, model, observer, device diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 81913d52b..f516ed875 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -158,11 +158,11 @@ def is_myjob(self, request): def get_model(self): """ - treat trainer as a model + recursively get the "real" model from trainer """ if "trainer" not in str(type(self.model)).lower(): return self.model - return self.model.model + return self.model.get_model() def as_model(self): """ diff --git a/test_fbopt_dial.sh b/test_fbopt_dial.sh index 417c73a4b..e6ac6197d 100644 --- a/test_fbopt_dial.sh +++ b/test_fbopt_dial.sh @@ -1 +1 @@ -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=fboptdial --nname=alexnet +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=fboptdial --trainer=dial --nname=alexnet From b2ef5672c1bc4172420d367e6b8d6f950dc47828 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 27 Nov 2023 11:27:02 +0100 Subject: [PATCH 669/762] delete unecenarY --- domainlab/algos/trainers/a_trainer.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index f516ed875..cfccaf74a 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -173,11 +173,6 @@ def as_model(self): """ return self.get_model() - def get_dict_model_params(self): - """ - """ - return dict(self.as_model().named_parameters()) - def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): """ use trainer as a model, this is the default behavior, if we want to have decorated From 2e3cb62e7c28050746431f918ed1ebbde44b979e Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 27 Nov 2023 11:44:31 +0100 Subject: [PATCH 670/762] seems working --- domainlab/algos/trainers/a_trainer.py | 14 ++++++++++++++ domainlab/algos/trainers/train_dial.py | 7 ++++++- domainlab/algos/trainers/train_fbopt_b.py | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index cfccaf74a..3a7cbbc95 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -186,3 +186,17 @@ def cal_task_loss(self, tensor_x, tensor_y): depute to the inner most trainer's model """ return self.get_model().cal_task_loss(tensor_x, tensor_y) + + def hyper_update(self, epoch, fun_scheduler): + """ + delegate hyper_update to model + :param epoch: + :param fun_scheduler: + """ + self.as_model().hyper_update(epoch, fun_scheduler) + + def hyper_init(self, functor_scheduler, trainer=None): + """ + delegate hyper_init to model + """ + return self.as_model().hyper_init(functor_scheduler, trainer) diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index e8ec05437..d7166203a 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -72,4 +72,9 @@ def tr_epoch(self, epoch): return flag_stop def hyper_init(self, functor_scheduler, trainer): - return functor_scheduler(trainer=trainer, gamma_reg=self.gamma_reg) + """ + initialize both trainer's multiplier and model's multiplier + """ + fun_scheduler = super().hyper_init(functor_scheduler, trainer) + return fun_scheduler + # FIXME: register also the trainer hyperpars: return functor_scheduler(trainer=trainer, gamma_reg=self.gamma_reg) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 91ae04da5..50b18eeb4 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -46,7 +46,7 @@ def eval_r_loss(self): ERM loss on all available training data # TODO: normalize loss via batchsize """ - self.model.eval() + self.model.as_model().eval() # mock the model hyper-parameter to be from dict4mu epo_reg_loss = [] epo_task_loss = 0 From 83a3b12a6b19cb82c008a9453724b3ba43f7a428 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 27 Nov 2023 11:56:44 +0100 Subject: [PATCH 671/762] use cpu --- test_fbopt_dial.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test_fbopt_dial.sh b/test_fbopt_dial.sh index e6ac6197d..26ecaac3e 100644 --- a/test_fbopt_dial.sh +++ b/test_fbopt_dial.sh @@ -1 +1,2 @@ +export CUDA_VISIBLE_DEVICES="" python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=fboptdial --trainer=dial --nname=alexnet From d56f5a0aa4e36ed864a6df625267edfc36d03094 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 28 Nov 2023 11:53:11 +0100 Subject: [PATCH 672/762] redefine self.model --- domainlab/algos/trainers/a_trainer.py | 28 ++++++++++++++++++++------ domainlab/algos/trainers/train_dial.py | 1 + test_fbopt_dial.sh | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 3a7cbbc95..167598e19 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -30,7 +30,7 @@ def __init__(self, successor_node=None): :param successor_node: """ super().__init__(successor_node) - self.model = None + self._model = None self.task = None self.observer = None self.device = None @@ -61,6 +61,10 @@ def __init__(self, successor_node=None): self.mu_iter_start = 0 self.flag_setpoint_updated = False + @property + def model(self): + return self.get_model() + @property def str_metric4msel(self): """ @@ -73,7 +77,7 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True): model, task, observer, device, aconf """ # @FIXME: aconf and args should be separated - self.model = model + self._model = model self.task = task self.observer = observer self.device = device @@ -160,9 +164,9 @@ def get_model(self): """ recursively get the "real" model from trainer """ - if "trainer" not in str(type(self.model)).lower(): - return self.model - return self.model.get_model() + if "trainer" not in str(type(self._model)).lower(): + return self._model + return self._model.get_model() def as_model(self): """ @@ -173,13 +177,18 @@ def as_model(self): """ return self.get_model() + def cal_loss(self, tensor_x, tensor_y, tensor_d, others=None): + # FIXME: other not used + return self.get_model().cal_loss(tensor_x, tensor_y, tensor_d) + def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): """ use trainer as a model, this is the default behavior, if we want to have decorated behavior of regularization loss, then this default behavior has to be changed. """ # FIXME: each trainer should implement this - return self.get_model().cal_reg_loss(tensor_x, tensor_y, tensor_d) + reg_loss_model = self.get_model().cal_reg_loss(tensor_x, tensor_y, tensor_d) + return reg_loss_model def cal_task_loss(self, tensor_x, tensor_y): """ @@ -200,3 +209,10 @@ def hyper_init(self, functor_scheduler, trainer=None): delegate hyper_init to model """ return self.as_model().hyper_init(functor_scheduler, trainer) + + @property + def list_str_multiplier_na(self): + return self.get_model().list_str_multiplier_na + + def train(self): + self.get_model().train() diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index d7166203a..793696109 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -40,6 +40,7 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): """ Let trainer behave like a model, so that other trainer could use it """ + return super().cal_reg_loss(tensor_x, tensor_y, tensor_d) self.model.train() tensor_x_adv = self.gen_adversarial(self.device, tensor_x, tensor_y) tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) diff --git a/test_fbopt_dial.sh b/test_fbopt_dial.sh index 26ecaac3e..db77fd557 100644 --- a/test_fbopt_dial.sh +++ b/test_fbopt_dial.sh @@ -1,2 +1,2 @@ export CUDA_VISIBLE_DEVICES="" -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=fboptdial --trainer=dial --nname=alexnet +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --aname=fboptdial --trainer=dial --nname=alexnet --nname_dom=alexnet --gamma_y=1e6 --gamma_d=1e6 From 08eb8b65d9b51ce045ced0b3aa5b61b99ecc1cb8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 28 Nov 2023 12:06:12 +0100 Subject: [PATCH 673/762] delete all unnecessary wraper function --- domainlab/algos/trainers/a_trainer.py | 40 --------------------------- 1 file changed, 40 deletions(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 167598e19..2f3fa9db6 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -176,43 +176,3 @@ def as_model(self): self.get_model().do_something() """ return self.get_model() - - def cal_loss(self, tensor_x, tensor_y, tensor_d, others=None): - # FIXME: other not used - return self.get_model().cal_loss(tensor_x, tensor_y, tensor_d) - - def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): - """ - use trainer as a model, this is the default behavior, if we want to have decorated - behavior of regularization loss, then this default behavior has to be changed. - """ - # FIXME: each trainer should implement this - reg_loss_model = self.get_model().cal_reg_loss(tensor_x, tensor_y, tensor_d) - return reg_loss_model - - def cal_task_loss(self, tensor_x, tensor_y): - """ - depute to the inner most trainer's model - """ - return self.get_model().cal_task_loss(tensor_x, tensor_y) - - def hyper_update(self, epoch, fun_scheduler): - """ - delegate hyper_update to model - :param epoch: - :param fun_scheduler: - """ - self.as_model().hyper_update(epoch, fun_scheduler) - - def hyper_init(self, functor_scheduler, trainer=None): - """ - delegate hyper_init to model - """ - return self.as_model().hyper_init(functor_scheduler, trainer) - - @property - def list_str_multiplier_na(self): - return self.get_model().list_str_multiplier_na - - def train(self): - self.get_model().train() From 3dda45926fe502df0a63b570a28c656a57fd5ea5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 28 Nov 2023 12:32:00 +0100 Subject: [PATCH 674/762] remove further uncessiary wrapper --- domainlab/algos/observers/b_obvisitor.py | 2 +- domainlab/algos/trainers/a_trainer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index cfcb876b9..a1c10ffa0 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -74,7 +74,7 @@ def accept(self, trainer): accept invitation as a visitor """ self.host_trainer = trainer - self.perf_metric = self.host_trainer.model.as_model().create_perf_obj(self.task) + self.perf_metric = self.host_trainer.model.create_perf_obj(self.task) self.model_sel.accept(trainer, self) def after_all(self): diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 2f3fa9db6..89bd145b0 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -104,7 +104,7 @@ def reset(self): """ make a new optimizer to clear internal state """ - self.optimizer = mk_opt(self.model.as_model(), self.aconf) + self.optimizer = mk_opt(self.model, self.aconf) @abc.abstractmethod def tr_epoch(self, epoch): From 3a91cf42ec3092800c95641a5122d74584fe8f22 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 28 Nov 2023 13:49:38 +0100 Subject: [PATCH 675/762] add model setter --- domainlab/algos/trainers/a_trainer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 89bd145b0..291cd1e75 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -65,6 +65,10 @@ def __init__(self, successor_node=None): def model(self): return self.get_model() + @model.setter + def model(self, model): + self._model = model + @property def str_metric4msel(self): """ From 9ad5b8b208d9a452183440328b00d054346c0e1e Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 28 Nov 2023 16:25:12 +0100 Subject: [PATCH 676/762] dial only task loss as regularization --- domainlab/algos/trainers/train_dial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index 793696109..5cac916b5 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -63,7 +63,7 @@ def tr_epoch(self, epoch): loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d) # @FIXME tensor_x_adv = self.gen_adversarial(self.device, tensor_x, vec_y) tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) - loss_dial, *_ = self.model.cal_loss(tensor_x_batch_adv_no_grad, vec_y, vec_d) # @FIXME + loss_dial, *_ = self.model.cal_task_loss(tensor_x_batch_adv_no_grad, vec_y, vec_d) # @FIXME loss = loss.sum() + self.aconf.gamma_reg * loss_dial.sum() loss.backward() self.optimizer.step() From 51ec54ad978e8b4ed7d555a89b33608986a3236c Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 29 Nov 2023 10:01:05 +0100 Subject: [PATCH 677/762] model to device --- domainlab/algos/trainers/a_trainer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 291cd1e75..6099ee99d 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -95,6 +95,7 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True): if flag_accept: self.observer.accept(self) + self.model = self.model.to(device) # self.num_batches = len(self.loader_tr) self.flag_update_hyper_per_epoch = False From 21de8a28abacbaf7042a43f46cb34de59cf618c1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 29 Nov 2023 11:50:33 +0100 Subject: [PATCH 678/762] cal task loss correct api --- domainlab/algos/trainers/train_dial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index 5cac916b5..e989fc104 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -63,7 +63,7 @@ def tr_epoch(self, epoch): loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d) # @FIXME tensor_x_adv = self.gen_adversarial(self.device, tensor_x, vec_y) tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) - loss_dial, *_ = self.model.cal_task_loss(tensor_x_batch_adv_no_grad, vec_y, vec_d) # @FIXME + loss_dial, *_ = self.model.cal_task_loss(tensor_x_batch_adv_no_grad, vec_y) loss = loss.sum() + self.aconf.gamma_reg * loss_dial.sum() loss.backward() self.optimizer.step() From 81059da3c398e8fb258009eead5727d0209c9496 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 29 Nov 2023 12:07:54 +0100 Subject: [PATCH 679/762] better format --- domainlab/algos/trainers/train_dial.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index e989fc104..7ec121bd7 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -36,21 +36,14 @@ def gen_adversarial(self, device, img_natural, vec_y): img_adv = torch.clamp(img_adv, 0.0, 1.0) return img_adv - def cal_reg_loss(self, tensor_x, tensor_y, tensor_d): + def _cal_reg_loss(self, tensor_x, tensor_y, tensor_d): """ Let trainer behave like a model, so that other trainer could use it """ return super().cal_reg_loss(tensor_x, tensor_y, tensor_d) - self.model.train() tensor_x_adv = self.gen_adversarial(self.device, tensor_x, tensor_y) tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) - loss_dial = self.model.cal_loss(tensor_x_batch_adv_no_grad, tensor_y, tensor_d) - # FIXME: dial is different from other regularizer, - # no matter if self.model is a trainer or complex model like diva? - # self.model should return cal_loss, and loss_dial is the same function evaluated - # on the augmented data - # However, if we want to tune all the multipliers, we should return all reg losses in the decorator chain, - # but the current implementation is enough to be used for deepall/ERM + loss_dial = self.model.cal_task_loss(tensor_x_batch_adv_no_grad, tensor_y) return [loss_dial], [self.gamma_reg] def tr_epoch(self, epoch): @@ -60,11 +53,9 @@ def tr_epoch(self, epoch): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) self.optimizer.zero_grad() - loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d) # @FIXME - tensor_x_adv = self.gen_adversarial(self.device, tensor_x, vec_y) - tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) - loss_dial, *_ = self.model.cal_task_loss(tensor_x_batch_adv_no_grad, vec_y) - loss = loss.sum() + self.aconf.gamma_reg * loss_dial.sum() + loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d) + loss_dial, mu = self._cal_reg_loss(tensor_x, tensor_y, tensor_d) + loss = loss.sum() + mu * loss_dial.sum() loss.backward() self.optimizer.step() self.epo_loss_tr += loss.detach().item() From bc899ebe85be600ab27bef66b035345ced171daf Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 30 Nov 2023 10:20:56 +0100 Subject: [PATCH 680/762] delete redundancy --- domainlab/algos/trainers/a_trainer.py | 9 +-------- domainlab/algos/trainers/train_dial.py | 20 +------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index 5bcbdb9f8..e32fb1bd2 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -61,13 +61,6 @@ def __init__(self, successor_node=None): self.mu_iter_start = 0 self.flag_setpoint_updated = False - @property - def model(self): - return self.get_model() - - @model.setter - def model(self, model): - self._model = model @property def model(self): @@ -207,4 +200,4 @@ def _cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): """ interface for each trainer to implement """ - return [], [] \ No newline at end of file + return [], [] diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index 7436cfa61..825020adf 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -47,24 +47,6 @@ def _cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): loss_dial = self.model.cal_task_loss(tensor_x_batch_adv_no_grad, tensor_y) return [loss_dial], [self.aconf.gamma_reg] - def tr_epoch(self, epoch): - self.model.train() - self.epo_loss_tr = 0 - for ind_batch, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr): - tensor_x, vec_y, vec_d = \ - tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) - self.optimizer.zero_grad() - loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d) # @FIXME - tensor_x_adv = self.gen_adversarial(self.device, tensor_x, vec_y) - tensor_x_batch_adv_no_grad = Variable(tensor_x_adv, requires_grad=False) - loss_dial, *_ = self.model.cal_task_loss(tensor_x_batch_adv_no_grad, vec_y) - loss = loss.sum() + self.aconf.gamma_reg * loss_dial.sum() - loss.backward() - self.optimizer.step() - self.epo_loss_tr += loss.detach().item() - self.after_batch(epoch, ind_batch) - flag_stop = self.observer.update(epoch) # notify observer - return flag_stop def hyper_init(self, functor_scheduler, trainer): """ @@ -72,4 +54,4 @@ def hyper_init(self, functor_scheduler, trainer): """ fun_scheduler = super().hyper_init(functor_scheduler, trainer) return fun_scheduler - # FIXME: register also the trainer hyperpars: return functor_scheduler(trainer=trainer, gamma_reg=self.gamma_reg) \ No newline at end of file + # FIXME: register also the trainer hyperpars: return functor_scheduler(trainer=trainer, gamma_reg=self.gamma_reg) From 237ba5bfaa3deb8758159093dd044200c3f28e15 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 1 Dec 2023 20:37:51 +0100 Subject: [PATCH 681/762] flag_info=False --- domainlab/algos/trainers/train_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_basic.py b/domainlab/algos/trainers/train_basic.py index 7a8927769..4138c6cfd 100644 --- a/domainlab/algos/trainers/train_basic.py +++ b/domainlab/algos/trainers/train_basic.py @@ -34,7 +34,7 @@ def before_epoch(self): self.epo_reg_loss_tr = [0.0 for _ in range(10)] self.epo_task_loss_tr = 0 - def tr_epoch(self, epoch): + def tr_epoch(self, epoch, flag_info=False): self.before_epoch() for ind_batch, (tensor_x, tensor_y, tensor_d, *others) in \ enumerate(self.loader_tr): @@ -100,4 +100,4 @@ def tr_batch(self, tensor_x, tensor_y, tensor_d, others, ind_batch, epoch): self.epo_loss_tr += loss.detach().item() self.epo_task_loss_tr += loss_task.sum().detach().item() self.after_batch(epoch, ind_batch) - self.counter_batch += 1 \ No newline at end of file + self.counter_batch += 1 From dd09077566d29be39517f9cb667a6484cc83fe55 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 1 Dec 2023 23:06:40 +0100 Subject: [PATCH 682/762] after repoch with flag_info --- domainlab/algos/trainers/train_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_basic.py b/domainlab/algos/trainers/train_basic.py index 4138c6cfd..9e65d58cc 100644 --- a/domainlab/algos/trainers/train_basic.py +++ b/domainlab/algos/trainers/train_basic.py @@ -40,9 +40,9 @@ def tr_epoch(self, epoch, flag_info=False): enumerate(self.loader_tr): self.tr_batch(tensor_x, tensor_y, tensor_d, others, ind_batch, epoch) - return self.after_epoch(epoch) + return self.after_epoch(epoch, flag_info) - def after_epoch(self, epoch): + def after_epoch(self, epoch, flag_info): """ observer collect information """ From 4d8e4344d857412d22c5115f2dc88ed850bc27c6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 4 Dec 2023 10:28:21 +0100 Subject: [PATCH 683/762] use others in fbopt --- domainlab/algos/trainers/train_fbopt_b.py | 6 +++--- domainlab/exp/exp_utils.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 50b18eeb4..a11467cc8 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -53,11 +53,11 @@ def eval_r_loss(self): epo_p_loss = 0 counter = 0.0 with torch.no_grad(): - for _, (tensor_x, vec_y, vec_d, *_) in enumerate(self.loader_tr_no_drop): + for _, (tensor_x, vec_y, vec_d, *others) in enumerate(self.loader_tr_no_drop): tensor_x, vec_y, vec_d = \ tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) - tuple_reg_loss = self.model.cal_reg_loss(tensor_x, vec_y, vec_d) - p_loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d) + tuple_reg_loss = self.model.cal_reg_loss(tensor_x, vec_y, vec_d, others) + p_loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d, others) # NOTE: first [0] extract the loss, second [0] get the list list_b_reg_loss = tuple_reg_loss[0] list_b_reg_loss_sumed = [ele.sum().detach().item() for ele in list_b_reg_loss] diff --git a/domainlab/exp/exp_utils.py b/domainlab/exp/exp_utils.py index f6a272cf7..9ec3c6cbf 100644 --- a/domainlab/exp/exp_utils.py +++ b/domainlab/exp/exp_utils.py @@ -103,7 +103,7 @@ def load(self, suffix=None): model = copy.deepcopy(self.host.trainer.model) model.load_state_dict(torch.load(path, map_location="cpu")) return model - + def clean_up(self): self.host.clean_up() From 3d63caa3e93fb68c3ab5ff9b68dee878e41a98ed Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 4 Dec 2023 11:41:35 +0100 Subject: [PATCH 684/762] remove as_model --- domainlab/algos/observers/b_obvisitor.py | 4 ++-- domainlab/algos/trainers/train_fbopt_b.py | 4 ++-- domainlab/models/a_model.py | 14 ++++---------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index 373891b18..73d4f669a 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -35,13 +35,13 @@ def str_metric4msel(self): string representing the metric used for persisting models on the disk """ return self.host_trainer.str_metric4msel - + def reset(self): """ reset observer via reset model selector """ self.model_sel.reset() - + def update(self, epoch, flag_info=False): logger = Logger.get_logger() logger.info(f"epoch: {epoch}") diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index a11467cc8..a97875bc6 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -46,7 +46,7 @@ def eval_r_loss(self): ERM loss on all available training data # TODO: normalize loss via batchsize """ - self.model.as_model().eval() + self.model.eval() # mock the model hyper-parameter to be from dict4mu epo_reg_loss = [] epo_task_loss = 0 @@ -117,7 +117,7 @@ def set_model_with_mu(self): """ set model multipliers """ - self.model.as_model().hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) + self._model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) def tr_epoch(self, epoch, flag_info=False): """ diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index 1b79056d9..6da0aaa04 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -19,7 +19,7 @@ def set_params(self, dict_params): # but I dont know another method to set neural network weights without using load_state_dict # FIXME: dict_params lack some keys compared to self.state_dict(), why? self.load_state_dict(dict_params, strict=False) - + def __init__(self): super().__init__() self._decoratee = None @@ -104,12 +104,6 @@ def _extend_loss(self, tensor_x, tensor_y, tensor_d, others=None): tensor_x, tensor_y, tensor_d, others) return None, None - def as_model(self): - """ - redundant method to be consistent with trainer - """ - return self - def forward(self, tensor_x, tensor_y, tensor_d, others=None): """forward. @@ -127,7 +121,7 @@ def save(self, suffix=None): return self.visitor.save(self, suffix) return - + def load(self, suffix=None): """ load model from disk @@ -135,6 +129,6 @@ def load(self, suffix=None): if self.visitor is None: return None return self.visitor.load(suffix) - + def set_saver(self, visitor): - self.visitor = visitor \ No newline at end of file + self.visitor = visitor From 74f6d1102cb3d7ff17bcc384bbdcced627cb4489 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 4 Dec 2023 12:56:45 +0100 Subject: [PATCH 685/762] identifies the thread_lock problem from writer, next step is to refactor mdoel.load --- domainlab/algos/trainers/fbopt_mu_controller.py | 7 +++++-- domainlab/algos/trainers/train_fbopt_b.py | 2 +- domainlab/models/model_dann.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 3193ae225..083295e45 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -44,7 +44,6 @@ def __init__(self, trainer, **kwargs): self.mmu = kwargs # force initial value of mu self.mmu = {key: self.init_mu for key, val in self.mmu.items()} - self.set_point_controller = FbOptSetpointController( args=self.trainer.aconf) @@ -52,15 +51,19 @@ def __init__(self, trainer, **kwargs): self.k_i_gain_ratio = None self.overshoot_rewind = trainer.aconf.overshoot_rewind == "yes" self.delta_epsilon_r = None + # NOTE: this value will be set according to initial evaluation of # neural network self.activation_clip = trainer.aconf.exp_shoulder_clip + self.coeff_ma = trainer.aconf.coeff_ma + # NOTE: + # print(copy.deepcopy(self.model)) + # TypeError: cannot pickle '_thread.lock' object if trainer.aconf.no_tensorboard: self.writer = StubSummaryWriter() else: str_job_id = os.environ.get('SLURM_JOB_ID', '') self.writer = SummaryWriter(comment=str_job_id) - self.coeff_ma = trainer.aconf.coeff_ma def set_k_i_gain(self, epo_reg_loss): if self.k_i_gain_ratio is None: diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index a97875bc6..3c2fd5207 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -117,7 +117,7 @@ def set_model_with_mu(self): """ set model multipliers """ - self._model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) + self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) def tr_epoch(self, epoch, flag_info=False): """ diff --git a/domainlab/models/model_dann.py b/domainlab/models/model_dann.py index 125a66acd..f9f2da10d 100644 --- a/domainlab/models/model_dann.py +++ b/domainlab/models/model_dann.py @@ -58,7 +58,7 @@ def __init__(self, list_str_y, list_d_tr, self.net_encoder = net_encoder self.net_classifier = net_classifier self.net_discriminator = net_discriminator - + @property def list_str_multiplier_na(self): return ["alpha"] @@ -73,7 +73,7 @@ def hyper_update(self, epoch, fun_scheduler): def hyper_init(self, functor_scheduler, trainer=None): """hyper_init. - :param functor_scheduler: + :param functor_scheduler: name of the scheduler class """ return functor_scheduler(trainer=trainer, alpha=self.alpha) From d2fe043a78bb77788948e6ea3990bc744e0583e1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 4 Dec 2023 13:27:59 +0100 Subject: [PATCH 686/762] exp pre deepcopy to avoid thread lock --- domainlab/exp/exp_main.py | 7 ++++--- domainlab/exp/exp_utils.py | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/domainlab/exp/exp_main.py b/domainlab/exp/exp_main.py index a55114cab..d5b4af885 100755 --- a/domainlab/exp/exp_main.py +++ b/domainlab/exp/exp_main.py @@ -34,7 +34,7 @@ def __init__(self, args, task=None, model=None, observer=None, visitor=AggWriter algo_builder = AlgoBuilderChainNodeGetter(self.args.aname, self.args.apath)() # request # the critical logic below is to avoid circular dependence between task initialization # and trainer initialization: - + # jigen algorithm builder has method dset_decoration_args_algo, which could AOP # into the task intilization process if args.san_check: @@ -44,14 +44,15 @@ def __init__(self, args, task=None, model=None, observer=None, visitor=AggWriter self.trainer, self.model, observer_default, device = algo_builder.init_business(self) if model is not None: self.model = model - self.visitor = visitor(self) # visitor depends on task initialization first - self.model.set_saver(self.visitor) self.epochs = self.args.epos self.epoch_counter = 1 if observer is None: observer = observer_default if not self.trainer.flag_initialized: self.trainer.init_business(self.model, self.task, observer, device, args) + self.visitor = visitor(self) # visitor depends on task initialization first + # visitor must be initialized last after trainer is initialized + self.model.set_saver(self.visitor) def execute(self, num_epochs=None): """ diff --git a/domainlab/exp/exp_utils.py b/domainlab/exp/exp_utils.py index 9ec3c6cbf..2c7f2b6f4 100644 --- a/domainlab/exp/exp_utils.py +++ b/domainlab/exp/exp_utils.py @@ -43,6 +43,7 @@ def __init__(self, host): ExpModelPersistVisitor.model_suffix) Path(os.path.dirname(self.model_path)).mkdir(parents=True, exist_ok=True) + self.model = copy.deepcopy(self.host.trainer.model) def mk_model_na(self, tag=None, dd_cut=19): """ @@ -100,9 +101,12 @@ def load(self, suffix=None): path = self.model_path if suffix is not None: path = "_".join([self.model_path, suffix]) - model = copy.deepcopy(self.host.trainer.model) - model.load_state_dict(torch.load(path, map_location="cpu")) - return model + # due to tensorboard writer in trainer.scheduler, + # copy.deepcopy(self.host.trainer.model) will cause thread lock + # see https://github.com/marrlab/DomainLab/issues/673 + self.model.load_state_dict(torch.load(path, map_location="cpu")) + #FIXME: without deep copy, it will cause accuracy inconsistent problems + return copy.deepcopy(self.model) def clean_up(self): self.host.clean_up() From 37456f1d75fb85879f7b52a9ce44db8025518f06 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 7 Dec 2023 13:28:48 +0100 Subject: [PATCH 687/762] change new name for warmup linear --- domainlab/algos/trainers/train_fbopt_b.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 3c2fd5207..21bb43981 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -5,7 +5,7 @@ import torch from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.fbopt_mu_controller import HyperSchedulerFeedback -from domainlab.algos.trainers.hyper_scheduler import HyperSchedulerWarmup +from domainlab.algos.trainers.hyper_scheduler import HyperSchedulerWarmupLinear from domainlab.utils.logger import Logger @@ -85,7 +85,7 @@ def before_batch(self, epoch, ind_batch): def before_tr(self): self.flag_setpoint_updated = False if self.aconf.force_feedforward: - self.set_scheduler(scheduler=HyperSchedulerWarmup) + self.set_scheduler(scheduler=HyperSchedulerWarmupLinear) else: self.set_scheduler(scheduler=HyperSchedulerFeedback) From b733aab7010b051a87fd29fec3b94f1d0126c020 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 18 Dec 2023 11:25:04 +0100 Subject: [PATCH 688/762] erm --- examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml | 2 +- examples/benchmark/mnist_dann_fbopt.yaml | 2 +- examples/benchmark/mnist_diva_fbopt_alone.yaml | 2 +- examples/benchmark/mnist_diva_fbopt_and_baselines.yaml | 2 +- examples/benchmark/mnist_jigen_fbopt_and_others.yaml | 2 +- examples/benchmark/pacs_diva_fbopt_and_baselines.yaml | 2 +- examples/benchmark/pacs_diva_others.yaml | 2 +- examples/benchmark/pacs_jigen_baslines4fbopt.yaml | 2 +- examples/benchmark/pacs_jigen_fbopt_alone.yaml | 2 +- examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml | 2 +- examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml | 2 +- run_erm.sh | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml b/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml index bc2208d86..d5ab246ea 100644 --- a/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml +++ b/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml @@ -49,4 +49,4 @@ jigen: # name erm: - model: deepall + model: erm diff --git a/examples/benchmark/mnist_dann_fbopt.yaml b/examples/benchmark/mnist_dann_fbopt.yaml index 8964ef31e..9417fbdd3 100644 --- a/examples/benchmark/mnist_dann_fbopt.yaml +++ b/examples/benchmark/mnist_dann_fbopt.yaml @@ -59,4 +59,4 @@ dann_fbopt: - mu_init erm: - model: deepall + model: erm diff --git a/examples/benchmark/mnist_diva_fbopt_alone.yaml b/examples/benchmark/mnist_diva_fbopt_alone.yaml index fbaa70dc2..b35e39b84 100644 --- a/examples/benchmark/mnist_diva_fbopt_alone.yaml +++ b/examples/benchmark/mnist_diva_fbopt_alone.yaml @@ -89,4 +89,4 @@ diva_fbopt_a: - mu_clip erm: - model: deepall + model: erm diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index b1a728991..089c80caf 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -119,4 +119,4 @@ diva_fixed_penalty: - gamma_y erm: - model: deepall + model: erm diff --git a/examples/benchmark/mnist_jigen_fbopt_and_others.yaml b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml index 7d82e22af..aa03a3040 100644 --- a/examples/benchmark/mnist_jigen_fbopt_and_others.yaml +++ b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml @@ -77,4 +77,4 @@ jigen_fixed_penalty: - gamma_reg erm: - model: deepall + model: erm diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index 7ae0b1bae..7f92fab31 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -117,4 +117,4 @@ diva_fixed_penalty: - gamma_y erm: - model: deepall + model: erm diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml index e6075ee41..822a71d43 100644 --- a/examples/benchmark/pacs_diva_others.yaml +++ b/examples/benchmark/pacs_diva_others.yaml @@ -88,4 +88,4 @@ diva_fixed_penalty: - gamma_y erm: - model: deepall + model: erm diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml index 23ed4781a..b654c608f 100644 --- a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -71,4 +71,4 @@ jigen_fixed_penalty: - pperm erm: - model: deepall + model: erm diff --git a/examples/benchmark/pacs_jigen_fbopt_alone.yaml b/examples/benchmark/pacs_jigen_fbopt_alone.yaml index 77ab0ee1d..446492f61 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone.yaml @@ -82,4 +82,4 @@ jigen_feedback: - pperm erm: - model: deepall + model: erm diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml index daf9db911..78bf6f5b2 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml @@ -87,4 +87,4 @@ jigen_fixed_penalty: - gamma_reg erm: - model: deepall + model: erm diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml index a949eb65a..ee9d4c465 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -102,4 +102,4 @@ jigen_fixed_penalty: - lr erm: - model: deepall + model: erm diff --git a/run_erm.sh b/run_erm.sh index 44c9beeea..f5285811f 100644 --- a/run_erm.sh +++ b/run_erm.sh @@ -1 +1 @@ -python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --model=deepall --nname=conv_bn_pool_2 --epos=10 +python main_out.py --te_d=1 --tr_d 0 3 --task=mnistcolor10 --bs=16 --model=erm --nname=conv_bn_pool_2 --epos=10 From 233c311d7770db0d9b0885e6c638461920829e64 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 22 Dec 2023 10:56:43 +0100 Subject: [PATCH 689/762] merge hduva nn name change --- examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml | 4 ++-- examples/benchmark/mnist_diva_fbopt_alone.yaml | 4 ++-- examples/benchmark/mnist_diva_fbopt_and_baselines.yaml | 4 ++-- examples/benchmark/pacs_dann_fbopt.yaml | 4 ++-- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 4 ++-- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 4 ++-- .../pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml | 4 ++-- examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml | 4 ++-- examples/benchmark/pacs_diva_fbopt_and_baselines.yaml | 4 ++-- examples/benchmark/pacs_diva_others.yaml | 4 ++-- examples/benchmark/pacs_hduva_baselines.yaml | 4 ++-- examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml | 4 ++-- examples/benchmark/pacs_hduva_matchdg.yaml | 4 ++-- examples/benchmark/pacs_jigen_baslines4fbopt.yaml | 4 ++-- examples/benchmark/pacs_jigen_fbopt_alone.yaml | 4 ++-- examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml | 4 ++-- examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml | 4 ++-- examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml | 4 ++-- run_fbopt_hduva | 2 +- run_fbopt_hduva_cpu.sh | 2 +- test_match_duva.sh | 4 ++-- test_match_duva_vlcs.sh | 4 ++-- 22 files changed, 42 insertions(+), 42 deletions(-) diff --git a/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml b/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml index d5ab246ea..28c6705e3 100644 --- a/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml +++ b/examples/benchmark/benchmark_pacs_resnet_grid_jigen.yaml @@ -19,8 +19,8 @@ domainlab_args: es: 1 bs: 32 npath: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py san_check: False diff --git a/examples/benchmark/mnist_diva_fbopt_alone.yaml b/examples/benchmark/mnist_diva_fbopt_alone.yaml index b35e39b84..7ab074716 100644 --- a/examples/benchmark/mnist_diva_fbopt_alone.yaml +++ b/examples/benchmark/mnist_diva_fbopt_alone.yaml @@ -24,8 +24,8 @@ domainlab_args: zd_dim: 32 nname: conv_bn_pool_2 nname_dom: conv_bn_pool_2 - nname_topic_distrib_img2topic: conv_bn_pool_2 - nname_encoder_sandwich_layer_img2h4zd: conv_bn_pool_2 + nname_encoder_x2topic_h: conv_bn_pool_2 + nname_encoder_sandwich_x2h4zd: conv_bn_pool_2 san_check: False coeff_ma: 0.5 no_tensorboard: False diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index 089c80caf..8cd4008fb 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -24,8 +24,8 @@ domainlab_args: zd_dim: 32 nname: conv_bn_pool_2 nname_dom: conv_bn_pool_2 - nname_topic_distrib_img2topic: conv_bn_pool_2 - nname_encoder_sandwich_layer_img2h4zd: conv_bn_pool_2 + nname_encoder_x2topic_h: conv_bn_pool_2 + nname_encoder_sandwich_x2h4zd: conv_bn_pool_2 san_check: False coeff_ma: 0.5 no_tensorboard: False diff --git a/examples/benchmark/pacs_dann_fbopt.yaml b/examples/benchmark/pacs_dann_fbopt.yaml index 3a33ba466..b5c743033 100644 --- a/examples/benchmark/pacs_dann_fbopt.yaml +++ b/examples/benchmark/pacs_dann_fbopt.yaml @@ -18,8 +18,8 @@ domainlab_args: bs: 64 san_check: True npath: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py exp_shoulder_clip: 10 mu_clip: 10_000 coeff_ma: 0.5 diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index a9c2319a2..0d5bfd072 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 7a1e1da6e..129e392cf 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 16 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml index 98b1c1dca..8e21dbfe7 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml b/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml index fdcd0048e..730696f69 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index 7f92fab31..10df43448 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml index 822a71d43..2699687d8 100644 --- a/examples/benchmark/pacs_diva_others.yaml +++ b/examples/benchmark/pacs_diva_others.yaml @@ -20,8 +20,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_hduva_baselines.yaml b/examples/benchmark/pacs_hduva_baselines.yaml index 5e9be6ffb..e40759681 100644 --- a/examples/benchmark/pacs_hduva_baselines.yaml +++ b/examples/benchmark/pacs_hduva_baselines.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml index fe71c9bdc..1422a302c 100644 --- a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml +++ b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_hduva_matchdg.yaml b/examples/benchmark/pacs_hduva_matchdg.yaml index 7aa472ce5..1b12d0143 100644 --- a/examples/benchmark/pacs_hduva_matchdg.yaml +++ b/examples/benchmark/pacs_hduva_matchdg.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml index b654c608f..b28be8632 100644 --- a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: True npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_jigen_fbopt_alone.yaml b/examples/benchmark/pacs_jigen_fbopt_alone.yaml index 446492f61..3107894ed 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: True npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml index b12d36b75..0405e6731 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -22,8 +22,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml index 78bf6f5b2..5fac934ce 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml @@ -21,8 +21,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml index ee9d4c465..4fb01259b 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -20,8 +20,8 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_topic_distrib_img2topic: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_layer_img2h4zd: examples/nets/resnet50domainbed.py + npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py + npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 diff --git a/run_fbopt_hduva b/run_fbopt_hduva index ddb97b4e4..c1add075f 100644 --- a/run_fbopt_hduva +++ b/run_fbopt_hduva @@ -1 +1 @@ -python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --bs=8 --model=hduva --trainer=fbopt --nname=conv_bn_pool_2 --gamma_y=7e5 --nname_topic_distrib_img2topic=conv_bn_pool_2 --nname_encoder_sandwich_layer_img2h4zd=conv_bn_pool_2 --gamma_y=3 --epos=2 +python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --bs=8 --model=hduva --trainer=fbopt --nname=conv_bn_pool_2 --gamma_y=7e5 --nname_encoder_x2topic_h=conv_bn_pool_2 --nname_encoder_sandwich_x2h4zd=conv_bn_pool_2 --gamma_y=3 --epos=2 diff --git a/run_fbopt_hduva_cpu.sh b/run_fbopt_hduva_cpu.sh index b82e6d4eb..54b7d5995 100644 --- a/run_fbopt_hduva_cpu.sh +++ b/run_fbopt_hduva_cpu.sh @@ -1,2 +1,2 @@ export CUDA_VISIBLE_DEVICES="" -python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --bs=8 --model=hduva --trainer=fbopt --nname=conv_bn_pool_2 --gamma_y=7e5 --nname_topic_distrib_img2topic=conv_bn_pool_2 --nname_encoder_sandwich_layer_img2h4zd=conv_bn_pool_2 --gamma_y=3 --epos=2 +python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --bs=8 --model=hduva --trainer=fbopt --nname=conv_bn_pool_2 --gamma_y=7e5 --nname_encoder_x2topic_h=conv_bn_pool_2 --nname_encoder_sandwich_x2h4zd=conv_bn_pool_2 --gamma_y=3 --epos=2 diff --git a/test_match_duva.sh b/test_match_duva.sh index 4b26e541c..c67c93ea2 100644 --- a/test_match_duva.sh +++ b/test_match_duva.sh @@ -1,6 +1,6 @@ python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --debug --bs=2 --model=matchhduva \ --epochs_ctr=3 --epos=6 --nname=conv_bn_pool_2 --gamma_y=7e5 \ - --nname_topic_distrib_img2topic=conv_bn_pool_2 \ - --nname_encoder_sandwich_layer_img2h4zd=conv_bn_pool_2 + --nname_encoder_x2topic_h=conv_bn_pool_2 \ + --nname_encoder_sandwich_x2h4zd=conv_bn_pool_2 diff --git a/test_match_duva_vlcs.sh b/test_match_duva_vlcs.sh index 779f6100c..a47e76c36 100644 --- a/test_match_duva_vlcs.sh +++ b/test_match_duva_vlcs.sh @@ -1,4 +1,4 @@ python main_out.py --te_d=caltech --task=mini_vlcs --debug --bs=2 --model=matchhduva \ --epochs_ctr=3 --epos=6 --npath=examples/nets/resnet.py --gamma_y=7e5 \ - --npath_topic_distrib_img2topic=examples/nets/resnet.py \ - --npath_encoder_sandwich_layer_img2h4zd=examples/nets/resnet.py + --npath_encoder_x2topic_h=examples/nets/resnet.py \ + --npath_encoder_sandwich_x2h4zd=examples/nets/resnet.py From eab26f894395366dd5918182e195d303f4386606 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 16 Jan 2024 16:20:21 +0100 Subject: [PATCH 690/762] first not working commit to combine diva with matchdg --- domainlab/algos/trainers/train_fbopt_b.py | 5 ++++- domainlab/algos/trainers/train_matchdg.py | 2 +- run_fbopt_match_diva.sh | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 run_fbopt_match_diva.sh diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 21bb43981..ca8554d7f 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -134,7 +134,10 @@ def tr_epoch(self, epoch, flag_info=False): logger = Logger.get_logger() logger.info(f"current multiplier: {self.model.dict_multiplier}") - flag = super().tr_epoch(epoch, self.flag_setpoint_updated) + if self._decoratee is not None: + flag = self._decoratee.tr_epoch(epoch, self.flag_setpoint_updated) + else: + flag = super().tr_epoch(epoch, self.flag_setpoint_updated) # is it good to update setpoint after we know the new value of each loss? self.flag_setpoint_updated = self.hyper_scheduler.update_setpoint( self.epo_reg_loss_tr, self.epo_task_loss_tr) diff --git a/domainlab/algos/trainers/train_matchdg.py b/domainlab/algos/trainers/train_matchdg.py index 98afc3126..8d634335a 100644 --- a/domainlab/algos/trainers/train_matchdg.py +++ b/domainlab/algos/trainers/train_matchdg.py @@ -38,7 +38,7 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True, self.tuple_tensor_ref_domain2each_y = None self.tuple_tensor_refdomain2each = None - def tr_epoch(self, epoch): + def tr_epoch(self, epoch, flag_info=False): """ # data in one batch comes from two sources: one part from loader, # the other part from match tensor diff --git a/run_fbopt_match_diva.sh b/run_fbopt_match_diva.sh new file mode 100644 index 000000000..c1547567c --- /dev/null +++ b/run_fbopt_match_diva.sh @@ -0,0 +1,6 @@ +#!/bin/bash +export CUDA_VISIBLE_DEVICES="" +# although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error +# so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring +# pytest -s tests/test_fbopt.py +python main_out.py --te_d=caltech --task=mini_vlcs --bs=8 --model=diva --trainer=fbopt_matchdg --nname=alexnet --nname_dom=alexnet --gamma_d=3 --gamma_y=3 --epos=200 --es=100 From a3e36fe8ee8c128313865870171e4101199ff86b Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 17 Jan 2024 12:41:00 +0100 Subject: [PATCH 691/762] fix syntax --- domainlab/arg_parser.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/domainlab/arg_parser.py b/domainlab/arg_parser.py index c45672997..cc281950c 100644 --- a/domainlab/arg_parser.py +++ b/domainlab/arg_parser.py @@ -146,7 +146,6 @@ def mk_parser_main(): dest="bm_dir", help="Aggregates and plots partial data of a snakemake \ benchmark. Requires the benchmark config file. \ -<<<<<<< HEAD Other arguments will be ignored.") parser.add_argument('--gen_plots', type=str, @@ -205,8 +204,7 @@ def mk_parser_main(): single space, will be parsed to be list of \ strings; if not provided then all available \ domains that are not assigned to \ - the test set will be used as training domains", - ) + the test set will be used as training domains') arg_group_task.add_argument( "--san_check", From 100c6876d5703df6b5f39f1901deade8919b6985 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 17 Jan 2024 12:55:09 +0100 Subject: [PATCH 692/762] fix diva --- domainlab/models/model_diva.py | 1 - 1 file changed, 1 deletion(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index adf8ea10b..fb55e9fe1 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -156,7 +156,6 @@ def _cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): _, d_target = tensor_d.max(dim=1) -<<<<<<< HEAD lc_d = F.cross_entropy(logit_d, d_target, reduction=g_str_cross_entropy_agg) return [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ [self.mu_recon, -self.beta_d, -self.beta_x, -self.beta_y, self.gamma_d] From a3f3559ec5f1fef9b536f3c06d2731fb95226d1c Mon Sep 17 00:00:00 2001 From: nutan Date: Wed, 17 Jan 2024 17:25:55 +0100 Subject: [PATCH 693/762] code style --- README.md | 4 +- domainlab/algos/builder_diva.py | 32 ++- domainlab/algos/builder_fbopt_dial.py | 1 + domainlab/algos/builder_jigen1.py | 4 +- domainlab/algos/msels/a_model_sel.py | 6 +- .../algos/msels/c_msel_setpoint_delay.py | 14 +- domainlab/algos/msels/c_msel_tr_loss.py | 2 +- domainlab/algos/msels/c_msel_val.py | 2 +- domainlab/algos/msels/c_msel_val_top_k.py | 29 +- domainlab/algos/observers/b_obvisitor.py | 8 +- .../algos/observers/c_obvisitor_cleanup.py | 2 +- domainlab/algos/trainers/a_trainer.py | 3 +- domainlab/algos/trainers/args_fbopt.py | 176 ++++++++---- .../algos/trainers/compos/matchdg_match.py | 1 + .../algos/trainers/fbopt_mu_controller.py | 146 +++++----- .../algos/trainers/fbopt_setpoint_ada.py | 109 ++++--- domainlab/algos/trainers/train_basic.py | 8 +- domainlab/algos/trainers/train_dial.py | 1 - domainlab/algos/trainers/train_fbopt_b.py | 64 +++-- domainlab/algos/trainers/zoo_trainer.py | 3 +- domainlab/algos/zoo_algos.py | 2 +- domainlab/arg_parser.py | 272 +++++++++++------- domainlab/exp_protocol/run_experiment.py | 6 +- domainlab/models/a_model.py | 1 + domainlab/models/model_diva.py | 77 +++-- domainlab/models/model_hduva.py | 58 ++-- domainlab/tasks/b_task.py | 4 +- .../utils/generate_fbopt_phase_portrait.py | 185 +++++++----- examples/benchmark/mnist_dann_fbopt.yaml | 2 +- .../benchmark/mnist_diva_fbopt_alone.yaml | 2 +- .../mnist_diva_fbopt_and_baselines.yaml | 2 +- .../mnist_jigen_fbopt_and_others.yaml | 2 +- .../benchmark/pacs_diva_fbopt_alone_es1.yaml | 2 +- .../pacs_diva_fbopt_alone_es1_autoki.yaml | 2 +- ...va_fbopt_alone_es1_autoki_output_ma_9.yaml | 2 +- .../pacs_diva_fbopt_alone_fixed.yaml | 2 +- examples/benchmark/pacs_hduva_baselines.yaml | 2 +- ...pacs_hduva_fbopt_alone_es1_autoki_aug.yaml | 2 +- examples/benchmark/pacs_hduva_matchdg.yaml | 2 +- .../benchmark/pacs_jigen_baslines4fbopt.yaml | 2 +- .../pacs_jigen_fbopt_alone_autoki.yaml | 2 +- .../pacs_jigen_fbopt_and_baselines.yaml | 2 +- .../pacs_jigen_fbopt_and_baselines_aug.yaml | 2 +- fbopt_mnist_diva_pixel.sh | 2 +- run_benchmark_slurm.sh | 3 +- run_fbopt_diva.sh | 2 +- run_fbopt_diva_cpu.sh | 2 +- run_fbopt_mnist.sh | 2 +- run_fbopt_mnist_diva.sh | 2 +- run_fbopt_mnist_diva_autoki.sh | 2 +- run_fbopt_mnist_feedforward.sh | 2 +- run_fbopt_mnist_jigen_autoki.sh | 2 +- run_fbopt_small_pacs.sh | 2 +- run_mnist_jigen.sh | 5 +- run_pacs_diva_fbopt.sh | 2 +- run_pacs_jigen_fbopt.sh | 2 +- script_jigen_plot.sh | 2 +- test_fbopt_dial.sh | 2 +- test_match_duva.sh | 2 - tests/test_fbopt.py | 3 +- tests/test_fbopt_setpoint_ada.py | 12 +- tests/test_fbopt_setpoint_rewind.py | 1 + 62 files changed, 809 insertions(+), 493 deletions(-) diff --git a/README.md b/README.md index ec7e3e88b..ed427eb7c 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ conda activate domainlab_py39 conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.6 -c pytorch -c conda-forge conda install torchmetrics==0.10.3 git checkout fbopt -pip install -r requirements_notorch.txt +pip install -r requirements_notorch.txt conda install tensorboard ``` @@ -60,7 +60,7 @@ https://github.com/marrlab/DomainLab/blob/fbopt/data/script/download_pacs.py step 2: make a symbolic link following the example script in https://github.com/marrlab/DomainLab/blob/master/sh_pacs.sh -where `mkdir -p data/pacs` is executed under the repository directory, +where `mkdir -p data/pacs` is executed under the repository directory, `ln -s /dir/to/yourdata/pacs/raw ./data/pacs/PACS` will create a symbolic link under the repository directory diff --git a/domainlab/algos/builder_diva.py b/domainlab/algos/builder_diva.py index 94bbff33b..0baf9039a 100644 --- a/domainlab/algos/builder_diva.py +++ b/domainlab/algos/builder_diva.py @@ -2,10 +2,10 @@ Builder pattern to build different component for experiment with DIVA """ from domainlab.algos.a_algo_builder import NodeAlgoBuilder -from domainlab.algos.msels.c_msel_val import MSelValPerf -from domainlab.algos.msels.c_msel_val_top_k import MSelValPerfTopK from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor from domainlab.algos.msels.c_msel_setpoint_delay import MSelSetpointDelay +from domainlab.algos.msels.c_msel_val import MSelValPerf +from domainlab.algos.msels.c_msel_val_top_k import MSelValPerfTopK from domainlab.algos.observers.b_obvisitor import ObVisitor from domainlab.algos.observers.c_obvisitor_cleanup import ObVisitorCleanUp from domainlab.algos.observers.c_obvisitor_gen import ObVisitorGen @@ -37,19 +37,23 @@ def init_business(self, exp): request = RequestVAEBuilderCHW(task.isize.c, task.isize.h, task.isize.w, args) node = VAEChainNodeGetter(request)() task.get_list_domains_tr_te(args.tr_d, args.te_d) - model = mk_diva(str_diva_multiplier_type=args.str_diva_multiplier_type)(node, - zd_dim=args.zd_dim, - zy_dim=args.zy_dim, - zx_dim=args.zx_dim, - list_str_y=task.list_str_y, - list_d_tr=task.list_domain_tr, - gamma_d=args.gamma_d, - gamma_y=args.gamma_y, - beta_x=args.beta_x, - beta_y=args.beta_y, - beta_d=args.beta_d) + model = mk_diva(str_diva_multiplier_type=args.str_diva_multiplier_type)( + node, + zd_dim=args.zd_dim, + zy_dim=args.zy_dim, + zx_dim=args.zx_dim, + list_str_y=task.list_str_y, + list_d_tr=task.list_domain_tr, + gamma_d=args.gamma_d, + gamma_y=args.gamma_y, + beta_x=args.beta_x, + beta_y=args.beta_y, + beta_d=args.beta_d, + ) device = get_device(args) - model_sel = MSelSetpointDelay(MSelOracleVisitor(MSelValPerfTopK(max_es=args.es))) + model_sel = MSelSetpointDelay( + MSelOracleVisitor(MSelValPerfTopK(max_es=args.es)) + ) if not args.gen: observer = ObVisitor(model_sel) else: diff --git a/domainlab/algos/builder_fbopt_dial.py b/domainlab/algos/builder_fbopt_dial.py index 81b5c3eae..f1faad96b 100644 --- a/domainlab/algos/builder_fbopt_dial.py +++ b/domainlab/algos/builder_fbopt_dial.py @@ -9,6 +9,7 @@ class NodeAlgoBuilderFbOptDial(NodeAlgoBuilderDIVA): """ builder for feedback optimization for dial """ + def init_business(self, exp): """ return trainer, model, observer diff --git a/domainlab/algos/builder_jigen1.py b/domainlab/algos/builder_jigen1.py index 4f0cae4f3..b14a3882f 100644 --- a/domainlab/algos/builder_jigen1.py +++ b/domainlab/algos/builder_jigen1.py @@ -2,10 +2,10 @@ builder for JiGen """ from domainlab.algos.a_algo_builder import NodeAlgoBuilder -from domainlab.algos.msels.c_msel_val import MSelValPerf -from domainlab.algos.msels.c_msel_val_top_k import MSelValPerfTopK from domainlab.algos.msels.c_msel_oracle import MSelOracleVisitor from domainlab.algos.msels.c_msel_setpoint_delay import MSelSetpointDelay +from domainlab.algos.msels.c_msel_val import MSelValPerf +from domainlab.algos.msels.c_msel_val_top_k import MSelValPerfTopK from domainlab.algos.observers.b_obvisitor import ObVisitor from domainlab.algos.observers.c_obvisitor_cleanup import ObVisitorCleanUp from domainlab.algos.trainers.hyper_scheduler import HyperSchedulerWarmupExponential diff --git a/domainlab/algos/msels/a_model_sel.py b/domainlab/algos/msels/a_model_sel.py index cb5f09f75..1cbfffeaa 100644 --- a/domainlab/algos/msels/a_model_sel.py +++ b/domainlab/algos/msels/a_model_sel.py @@ -92,7 +92,7 @@ def best_te_metric(self): if self.msel is not None: return self.msel.best_te_metric return -1 - + @property def sel_model_te_acc(self): """ @@ -101,9 +101,9 @@ def sel_model_te_acc(self): if self.msel is not None: return self.msel.sel_model_te_acc return -1 - + @property def oracle_last_setpoint_sel_te_acc(self): if self.msel is not None: return self.msel.oracle_last_setpoint_sel_te_acc - return -1 \ No newline at end of file + return -1 diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 650b57527..3812c7de1 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -2,6 +2,7 @@ Multiobjective Model Selection """ import copy + from domainlab.algos.msels.a_model_sel import AMSel from domainlab.utils.logger import Logger @@ -11,27 +12,32 @@ class MSelSetpointDelay(AMSel): 1. Model selection using validation performance 2. Only update if setpoint has been decreased """ + def __init__(self, msel): super().__init__() # NOTE: super() has to come first always otherwise self.msel will be overwritten to be None self.msel = msel self._oracle_last_setpoint_sel_te_acc = 0.0 - + @property def oracle_last_setpoint_sel_te_acc(self): """ return the last setpoint best acc """ return self._oracle_last_setpoint_sel_te_acc - + def update(self, clear_counter=False): """ if the best model should be updated """ logger = Logger.get_logger() - logger.info(f"setpoint selected current acc {self._oracle_last_setpoint_sel_te_acc}") + logger.info( + f"setpoint selected current acc {self._oracle_last_setpoint_sel_te_acc}" + ) if clear_counter: - logger.info("setpoint msel te acc updated from {self._oracle_last_setpoint_sel_te_acc} to {self.sel_model_te_acc}") + logger.info( + "setpoint msel te acc updated from {self._oracle_last_setpoint_sel_te_acc} to {self.sel_model_te_acc}" + ) self._oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc flag = self.msel.update(clear_counter) return flag diff --git a/domainlab/algos/msels/c_msel_tr_loss.py b/domainlab/algos/msels/c_msel_tr_loss.py index 9d7b2f5a0..7ed3f1168 100644 --- a/domainlab/algos/msels/c_msel_tr_loss.py +++ b/domainlab/algos/msels/c_msel_tr_loss.py @@ -27,7 +27,7 @@ def reset(self): @property def max_es(self): return self._max_es - + def update(self, clear_counter=False): """ if the best model should be updated diff --git a/domainlab/algos/msels/c_msel_val.py b/domainlab/algos/msels/c_msel_val.py index 766be2d07..c1f2f5561 100644 --- a/domainlab/algos/msels/c_msel_val.py +++ b/domainlab/algos/msels/c_msel_val.py @@ -24,7 +24,7 @@ def reset(self): @property def sel_model_te_acc(self): return self._sel_model_te_acc - + @property def best_val_acc(self): """ diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index 02687b0f5..a28015da0 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -10,6 +10,7 @@ class MSelValPerfTopK(MSelValPerf): 1. Model selection using validation performance 2. Visitor pattern to trainer """ + def __init__(self, max_es, top_k=2): super().__init__(max_es) # construct self.tr_obs (observer) self.top_k = top_k @@ -20,32 +21,38 @@ def update(self, clear_counter=False): if the best model should be updated """ flag_super = super().update(clear_counter) - metric_val_current = \ - self.tr_obs.metric_val[self.tr_obs.str_metric4msel] + metric_val_current = self.tr_obs.metric_val[self.tr_obs.str_metric4msel] acc_min = min(self.list_top_k_acc) if metric_val_current > acc_min: # overwrite logger = Logger.get_logger() - logger.info(f"top k validation acc: {self.list_top_k_acc} \ - overwriting/reset counter") + logger.info( + f"top k validation acc: {self.list_top_k_acc} \ + overwriting/reset counter" + ) self.es_c = 0 # restore counter ind = self.list_top_k_acc.index(acc_min) # avoid having identical values if metric_val_current not in self.list_top_k_acc: self.list_top_k_acc[ind] = metric_val_current - logger.info(f"top k validation acc updated: \ - {self.list_top_k_acc}") + logger.info( + f"top k validation acc updated: \ + {self.list_top_k_acc}" + ) # overwrite to ensure consistency - # issue #569: initially self.list_top_k_acc will be [xx, 0] and it does not matter since 0 will be overwriten by second epoch validation acc. + # issue #569: initially self.list_top_k_acc will be [xx, 0] and it does not matter since 0 will be overwriten by second epoch validation acc. # actually, after epoch 1, most often, sefl._best_val_acc will be the higher value of self.list_top_k_acc will overwriten by min(self.list_top_k_acc) - logger.info(f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to minium of {self.list_top_k_acc} which is {min(self.list_top_k_acc)} to ensure consistency") + logger.info( + f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to minium of {self.list_top_k_acc} which is {min(self.list_top_k_acc)} to ensure consistency" + ) self._best_val_acc = min(self.list_top_k_acc) # overwrite test acc, this does not depend on if val top-k acc has been overwritten or not - metric_te_current = \ - self.tr_obs.metric_te[self.tr_obs.str_metric4msel] + metric_te_current = self.tr_obs.metric_te[self.tr_obs.str_metric4msel] if self._sel_model_te_acc != metric_te_current: # this can only happen if the validation acc has decreased and current val acc is only bigger than min(self.list_top_k_acc} but lower than max(self.list_top_k_acc) - logger.info(f"top-2 val sel: overwriting selected model test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency") + logger.info( + f"top-2 val sel: overwriting selected model test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency" + ) self._sel_model_te_acc = metric_te_current return True return flag_super diff --git a/domainlab/algos/observers/b_obvisitor.py b/domainlab/algos/observers/b_obvisitor.py index 457ab874c..6dce73c28 100644 --- a/domainlab/algos/observers/b_obvisitor.py +++ b/domainlab/algos/observers/b_obvisitor.py @@ -119,8 +119,12 @@ def after_all(self): else: metric_te.update({"acc_val": -1}) - if hasattr(self, "model_sel") and hasattr(self.model_sel, "oracle_last_setpoint_sel_te_acc"): - metric_te.update({"acc_setpoint":self.model_sel.oracle_last_setpoint_sel_te_acc}) + if hasattr(self, "model_sel") and hasattr( + self.model_sel, "oracle_last_setpoint_sel_te_acc" + ): + metric_te.update( + {"acc_setpoint": self.model_sel.oracle_last_setpoint_sel_te_acc} + ) else: metric_te.update({"acc_setpoint": -1}) self.dump_prediction(model_ld, metric_te) diff --git a/domainlab/algos/observers/c_obvisitor_cleanup.py b/domainlab/algos/observers/c_obvisitor_cleanup.py index 2632ea46f..4de3ef6b4 100644 --- a/domainlab/algos/observers/c_obvisitor_cleanup.py +++ b/domainlab/algos/observers/c_obvisitor_cleanup.py @@ -12,7 +12,7 @@ def __init__(self, observer): def after_all(self): self.observer.after_all() - self.observer.clean_up() # FIXME should be self.clean_up??? + self.observer.clean_up() # FIXME should be self.clean_up??? def accept(self, trainer): self.observer.accept(trainer) diff --git a/domainlab/algos/trainers/a_trainer.py b/domainlab/algos/trainers/a_trainer.py index d9f80f331..a82c53d99 100644 --- a/domainlab/algos/trainers/a_trainer.py +++ b/domainlab/algos/trainers/a_trainer.py @@ -89,7 +89,6 @@ def __init__(self, successor_node=None, extend=None): self.mu_iter_start = 0 self.flag_setpoint_updated = False - @property def model(self): """ @@ -226,7 +225,7 @@ def get_model(self): if "trainer" not in str(type(self._model)).lower(): return self._model return self._model.get_model() - + def as_model(self): """ used for decorator pattern diff --git a/domainlab/algos/trainers/args_fbopt.py b/domainlab/algos/trainers/args_fbopt.py index 2039ce2d4..53719e05f 100644 --- a/domainlab/algos/trainers/args_fbopt.py +++ b/domainlab/algos/trainers/args_fbopt.py @@ -8,67 +8,119 @@ def add_args2parser_fbopt(parser): append hyper-parameters to the main argparser """ - parser.add_argument('--k_i_gain', type=float, default=0.001, - help='PID control gain for integrator') - - parser.add_argument('--k_i_gain_ratio', type=float, default=None, - help='set k_i_gain to be ratio of \ - initial saturation k_i_gain') - - parser.add_argument('--mu_clip', type=float, default=1e4, - help='maximum value of mu') - - parser.add_argument('--mu_min', type=float, default=1e-6, - help='minimum value of mu') - - parser.add_argument('--mu_init', type=float, default=0.001, - help='initial beta for multiplication') - - parser.add_argument('--coeff_ma', type=float, default=0.5, - help='exponential moving average') - - parser.add_argument('--coeff_ma_output_state', type=float, default=0.1, - help='state exponential moving average of \ - reguarlization loss') - - parser.add_argument('--coeff_ma_setpoint', type=float, default=0.9, - help='setpoint average coeff for previous setpoint') - - parser.add_argument('--exp_shoulder_clip', type=float, default=5, - help='clip before exponential operation') - - parser.add_argument('--ini_setpoint_ratio', type=float, default=0.99, - help='before training start, evaluate reg loss, \ - setpoint will be 0.9 of this loss') - - parser.add_argument('--force_feedforward', action='store_true', - default=False, - help='use feedforward scheduler') - - parser.add_argument('--force_setpoint_change_once', action='store_true', - default=False, - help='train until the setpoint changed at least once \ - up to maximum epos specified') - - parser.add_argument('--no_tensorboard', action='store_true', default=False, - help='disable tensorboard') - - parser.add_argument('--no_setpoint_update', action='store_true', - default=False, - help='disable setpoint update') - - parser.add_argument('--tr_with_init_mu', action='store_true', - default=False, - help='disable setpoint update') - - parser.add_argument('--overshoot_rewind', type=str, default="yes", - help='overshoot_rewind, for benchmark, use yes or no') - - parser.add_argument('--setpoint_rewind', type=str, default="no", - help='setpoing_rewind, for benchmark, use yes or no') - - parser.add_argument('--str_diva_multiplier_type', type=str, - default="gammad_recon", - help='which penalty to tune') + parser.add_argument( + "--k_i_gain", type=float, default=0.001, help="PID control gain for integrator" + ) + + parser.add_argument( + "--k_i_gain_ratio", + type=float, + default=None, + help="set k_i_gain to be ratio of \ + initial saturation k_i_gain", + ) + + parser.add_argument( + "--mu_clip", type=float, default=1e4, help="maximum value of mu" + ) + + parser.add_argument( + "--mu_min", type=float, default=1e-6, help="minimum value of mu" + ) + + parser.add_argument( + "--mu_init", type=float, default=0.001, help="initial beta for multiplication" + ) + + parser.add_argument( + "--coeff_ma", type=float, default=0.5, help="exponential moving average" + ) + + parser.add_argument( + "--coeff_ma_output_state", + type=float, + default=0.1, + help="state exponential moving average of \ + reguarlization loss", + ) + + parser.add_argument( + "--coeff_ma_setpoint", + type=float, + default=0.9, + help="setpoint average coeff for previous setpoint", + ) + + parser.add_argument( + "--exp_shoulder_clip", + type=float, + default=5, + help="clip before exponential operation", + ) + + parser.add_argument( + "--ini_setpoint_ratio", + type=float, + default=0.99, + help="before training start, evaluate reg loss, \ + setpoint will be 0.9 of this loss", + ) + + parser.add_argument( + "--force_feedforward", + action="store_true", + default=False, + help="use feedforward scheduler", + ) + + parser.add_argument( + "--force_setpoint_change_once", + action="store_true", + default=False, + help="train until the setpoint changed at least once \ + up to maximum epos specified", + ) + + parser.add_argument( + "--no_tensorboard", + action="store_true", + default=False, + help="disable tensorboard", + ) + + parser.add_argument( + "--no_setpoint_update", + action="store_true", + default=False, + help="disable setpoint update", + ) + + parser.add_argument( + "--tr_with_init_mu", + action="store_true", + default=False, + help="disable setpoint update", + ) + + parser.add_argument( + "--overshoot_rewind", + type=str, + default="yes", + help="overshoot_rewind, for benchmark, use yes or no", + ) + + parser.add_argument( + "--setpoint_rewind", + type=str, + default="no", + help="setpoing_rewind, for benchmark, use yes or no", + ) + + parser.add_argument( + "--str_diva_multiplier_type", + type=str, + default="gammad_recon", + help="which penalty to tune", + ) return parser diff --git a/domainlab/algos/trainers/compos/matchdg_match.py b/domainlab/algos/trainers/compos/matchdg_match.py index 78e67abde..8c6b46c90 100644 --- a/domainlab/algos/trainers/compos/matchdg_match.py +++ b/domainlab/algos/trainers/compos/matchdg_match.py @@ -16,6 +16,7 @@ class MatchPair: """ match different input """ + @store_args def __init__( self, diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 083295e45..9c4fbf8c5 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -4,15 +4,17 @@ import os import warnings +import numpy as np from torch.utils.tensorboard import SummaryWriter -import numpy as np +from domainlab.algos.trainers.fbopt_setpoint_ada import ( + FbOptSetpointController, + if_list_sign_agree, +) from domainlab.utils.logger import Logger -from domainlab.algos.trainers.fbopt_setpoint_ada import FbOptSetpointController -from domainlab.algos.trainers.fbopt_setpoint_ada import if_list_sign_agree -class StubSummaryWriter(): +class StubSummaryWriter: """ # stub writer for tensorboard that ignores all messages """ @@ -28,10 +30,11 @@ def add_scalars(self, *args, **kwargs): """ -class HyperSchedulerFeedback(): +class HyperSchedulerFeedback: """ design $\\mu$$ sequence based on state of penalized loss """ + def __init__(self, trainer, **kwargs): """ kwargs is a dictionary with key the hyper-parameter name and its value @@ -44,8 +47,7 @@ def __init__(self, trainer, **kwargs): self.mmu = kwargs # force initial value of mu self.mmu = {key: self.init_mu for key, val in self.mmu.items()} - self.set_point_controller = FbOptSetpointController( - args=self.trainer.aconf) + self.set_point_controller = FbOptSetpointController(args=self.trainer.aconf) self.k_i_control = trainer.aconf.k_i_gain self.k_i_gain_ratio = None @@ -62,7 +64,7 @@ def __init__(self, trainer, **kwargs): if trainer.aconf.no_tensorboard: self.writer = StubSummaryWriter() else: - str_job_id = os.environ.get('SLURM_JOB_ID', '') + str_job_id = os.environ.get("SLURM_JOB_ID", "") self.writer = SummaryWriter(comment=str_job_id) def set_k_i_gain(self, epo_reg_loss): @@ -75,14 +77,17 @@ def set_k_i_gain(self, epo_reg_loss): delta_epsilon_r = [a - b for a, b in zip(epo_reg_loss, list_setpoint)] # to calculate self.delta_epsilon_r - k_i_gain_saturate = [a / b for a, b in - zip(self.activation_clip, delta_epsilon_r)] + k_i_gain_saturate = [ + a / b for a, b in zip(self.activation_clip, delta_epsilon_r) + ] k_i_gain_saturate_min = min(k_i_gain_saturate) # NOTE: here we override the commandline arguments specification # for k_i_control, so k_i_control is not a hyperparameter anymore self.k_i_control = self.k_i_gain_ratio * k_i_gain_saturate_min - warnings.warn(f"hyperparameter k_i_gain disabled! \ - replace with {self.k_i_control}") + warnings.warn( + f"hyperparameter k_i_gain disabled! \ + replace with {self.k_i_control}" + ) # FIXME: change this to 1-self.ini_setpoint_ratio, i.e. the more # difficult the initial setpoint is, the bigger the k_i_gain should be @@ -112,38 +117,42 @@ def cal_delta4control(self, list1, list_setpoint): # self.delta_epsilon_r is the previous time step. # delta_epsilon_r is the current time step self.delta_epsilon_r = self.cal_delta_integration( - self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma) + self.delta_epsilon_r, delta_epsilon_r, self.coeff_ma + ) def cal_delta_integration(self, list_old, list_new, coeff): """ ma of delta """ - return [(1 - coeff) * a + coeff * b - for a, b in zip(list_old, list_new)] + return [(1 - coeff) * a + coeff * b for a, b in zip(list_old, list_new)] - def tackle_overshoot(self, - activation, epo_reg_loss, list_str_multiplier_na): + def tackle_overshoot(self, activation, epo_reg_loss, list_str_multiplier_na): """ tackle overshoot """ - list_overshoot = [i if (a - b) * (self.delta_epsilon_r[i]) < 0 - else None - for i, (a, b) in - enumerate( - zip(epo_reg_loss, - self.set_point_controller.setpoint4R))] + list_overshoot = [ + i if (a - b) * (self.delta_epsilon_r[i]) < 0 else None + for i, (a, b) in enumerate( + zip(epo_reg_loss, self.set_point_controller.setpoint4R) + ) + ] for ind in list_overshoot: if ind is not None: logger = Logger.get_logger( - logger_name='main_out_logger', loglevel="INFO") + logger_name="main_out_logger", loglevel="INFO" + ) logger.info(f"delta integration: {self.delta_epsilon_r}") - logger.info(f"overshooting at pos \ - {ind} of activation: {activation}") + logger.info( + f"overshooting at pos \ + {ind} of activation: {activation}" + ) logger.info(f"name reg loss:{list_str_multiplier_na}") if self.overshoot_rewind: activation[ind] = 0.0 - logger.info(f"PID controller set to zero now, \ - new activation: {activation}") + logger.info( + f"PID controller set to zero now, \ + new activation: {activation}" + ) return activation def cal_activation(self): @@ -151,26 +160,29 @@ def cal_activation(self): calculate activation on exponential shoulder """ setpoint = self.get_setpoint4r() - activation = [self.k_i_control * val if setpoint[i] > 0 - else self.k_i_control * (-val) for i, val - in enumerate(self.delta_epsilon_r)] + activation = [ + self.k_i_control * val if setpoint[i] > 0 else self.k_i_control * (-val) + for i, val in enumerate(self.delta_epsilon_r) + ] if self.activation_clip is not None: - activation = [np.clip(val, - a_min=-1 * self.activation_clip, - a_max=self.activation_clip) - for val in activation] + activation = [ + np.clip( + val, a_min=-1 * self.activation_clip, a_max=self.activation_clip + ) + for val in activation + ] return activation - def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, - list_str_multiplier_na, miter): + def search_mu( + self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, miter + ): """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value to see if the criteria is met $$\\mu^{k+1}=mu^{k}exp(rate_mu*[R(\\theta^{k})-ref_R])$$ """ - logger = Logger.get_logger( - logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger(logger_name="main_out_logger", loglevel="INFO") logger.info(f"before controller: current mu: {self.mmu}") logger.info(f"epo reg loss: {epo_reg_loss}") logger.info(f"name reg loss:{list_str_multiplier_na}") @@ -178,39 +190,43 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, activation = self.cal_activation() # overshoot handling activation = self.tackle_overshoot( - activation, epo_reg_loss, list_str_multiplier_na) + activation, epo_reg_loss, list_str_multiplier_na + ) list_gain = np.exp(activation) dict_gain = dict(zip(list_str_multiplier_na, list_gain)) target = self.dict_multiply(self.mmu, dict_gain) self.mmu = self.dict_clip(target) - logger = Logger.get_logger( - logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger(logger_name="main_out_logger", loglevel="INFO") logger.info(f"after contoller: current mu: {self.mmu}") for key, val in self.mmu.items(): - self.writer.add_scalar(f'dyn_mu/{key}', val, miter) - self.writer.add_scalar( - f'controller_gain/{key}', dict_gain[key], miter) + self.writer.add_scalar(f"dyn_mu/{key}", val, miter) + self.writer.add_scalar(f"controller_gain/{key}", dict_gain[key], miter) ind = list_str_multiplier_na.index(key) + self.writer.add_scalar(f"delta/{key}", self.delta_epsilon_r[ind], miter) + for i, (reg_dyn, reg_set) in enumerate( + zip(epo_reg_loss, self.get_setpoint4r()) + ): self.writer.add_scalar( - f'delta/{key}', self.delta_epsilon_r[ind], miter) - for i, (reg_dyn, reg_set) in \ - enumerate(zip(epo_reg_loss, self.get_setpoint4r())): + f"lossrd/dyn_{list_str_multiplier_na[i]}", reg_dyn, miter + ) self.writer.add_scalar( - f'lossrd/dyn_{list_str_multiplier_na[i]}', reg_dyn, miter) - self.writer.add_scalar( - f'lossrs/setpoint_{list_str_multiplier_na[i]}', reg_set, miter) + f"lossrs/setpoint_{list_str_multiplier_na[i]}", reg_set, miter + ) self.writer.add_scalars( - f'loss_rds/loss_{list_str_multiplier_na[i]}_w_setpoint', - {f'lossr/loss_{list_str_multiplier_na[i]}': reg_dyn, - f'lossr/setpoint_{list_str_multiplier_na[i]}': reg_set, - }, miter) + f"loss_rds/loss_{list_str_multiplier_na[i]}_w_setpoint", + { + f"lossr/loss_{list_str_multiplier_na[i]}": reg_dyn, + f"lossr/setpoint_{list_str_multiplier_na[i]}": reg_set, + }, + miter, + ) self.writer.add_scalar( - f'x_ell_y_r/loss_{list_str_multiplier_na[i]}', - reg_dyn, epo_task_loss) - self.writer.add_scalar('loss_task/penalized', epo_loss_tr, miter) - self.writer.add_scalar('loss_task/ell', epo_task_loss, miter) + f"x_ell_y_r/loss_{list_str_multiplier_na[i]}", reg_dyn, epo_task_loss + ) + self.writer.add_scalar("loss_task/penalized", epo_loss_tr, miter) + self.writer.add_scalar("loss_task/ell", epo_task_loss, miter) acc_te = 0 acc_val = 0 acc_sel = 0 @@ -220,8 +236,7 @@ def search_mu(self, epo_reg_loss, epo_task_loss, epo_loss_tr, acc_te = self.trainer.observer.metric_te["acc"] acc_val = self.trainer.observer.metric_val["acc"] acc_sel = self.trainer.observer.model_sel.sel_model_te_acc - acc_set = \ - self.trainer.observer.model_sel.oracle_last_setpoint_sel_te_acc + acc_set = self.trainer.observer.model_sel.oracle_last_setpoint_sel_te_acc self.writer.add_scalar("acc/te", acc_te, miter) self.writer.add_scalar("acc/val", acc_val, miter) self.writer.add_scalar("acc/sel", acc_sel, miter) @@ -231,8 +246,10 @@ def dict_clip(self, dict_base): """ clip each entry of the mu according to pre-set self.mu_clip """ - return {key: np.clip(val, a_min=self.mu_min, a_max=self.mu_clip) - for key, val in dict_base.items()} + return { + key: np.clip(val, a_min=self.mu_min, a_max=self.mu_clip) + for key, val in dict_base.items() + } def dict_is_zero(self, dict_mu): """ @@ -247,8 +264,7 @@ def dict_multiply(self, dict_base, dict_multiplier): """ multiply a float to each element of a dictionary """ - return { - key: val * dict_multiplier[key] for key, val in dict_base.items()} + return {key: val * dict_multiplier[key] for key, val in dict_base.items()} def update_setpoint(self, epo_reg_loss, epo_task_loss): """ diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 2004a1ee2..433dadded 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -2,6 +2,7 @@ update hyper-parameters during training """ import numpy as np + from domainlab.utils.logger import Logger @@ -41,8 +42,9 @@ def is_less_list_any(list1, list2): judge if one list is less than the other """ if_list_sign_agree(list1, list2) - list_comparison = [a < b if a >= 0 and b >= 0 else a > b - for a, b in zip(list1, list2)] + list_comparison = [ + a < b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2) + ] return any(list_comparison), list_true(list_comparison) @@ -51,11 +53,13 @@ def is_less_list_all(list1, list2, flag_eq=False): judge if one list is less than the other """ if_list_sign_agree(list1, list2) - list_comparison = [a < b if a >= 0 and b >= 0 else a > b - for a, b in zip(list1, list2)] + list_comparison = [ + a < b if a >= 0 and b >= 0 else a > b for a, b in zip(list1, list2) + ] if flag_eq: - list_comparison = [a <= b if a >= 0 and b >= 0 else a >= b - for a, b in zip(list1, list2)] + list_comparison = [ + a <= b if a >= 0 and b >= 0 else a >= b for a, b in zip(list1, list2) + ] return all(list_comparison) @@ -63,15 +67,15 @@ def list_ma(list_state, list_input, coeff): """ moving average of list """ - return [a * coeff + b * (1 - coeff) for a, b in \ - zip(list_state, list_input)] + return [a * coeff + b * (1 - coeff) for a, b in zip(list_state, list_input)] -class SetpointRewinder(): +class SetpointRewinder: """ rewind setpoint if current loss exponential moving average is bigger than setpoint """ + def __init__(self, host): self.host = host self.counter = None @@ -95,10 +99,10 @@ def observe(self, epo_reg_loss): if self.ref is None: self.reset(epo_reg_loss) self.epo_ma = list_ma(self.epo_ma, epo_reg_loss, self.coeff_ma) - list_comparison_increase = \ - [a < b for a, b in zip(self.ref, self.epo_ma)] - list_comparison_above_setpoint = \ - [a < b for a, b in zip(self.host.setpoint4R, self.epo_ma)] + list_comparison_increase = [a < b for a, b in zip(self.ref, self.epo_ma)] + list_comparison_above_setpoint = [ + a < b for a, b in zip(self.host.setpoint4R, self.epo_ma) + ] flag_increase = any(list_comparison_increase) flag_above_setpoint = any(list_comparison_above_setpoint) if flag_increase and flag_above_setpoint: @@ -114,9 +118,11 @@ def observe(self, epo_reg_loss): list_pos = list_true(list_comparison_above_setpoint) print(f"\n\n\n!!!!!!!setpoint too low at {list_pos}!\n\n\n") for pos in list_pos: - print(f"\n\n\n!!!!!!!rewinding setpoint at pos {pos} \ + print( + f"\n\n\n!!!!!!!rewinding setpoint at pos {pos} \ from {self.host.setpoint4R[pos]} to \ - {self.epo_ma[pos]}!\n\n\n") + {self.epo_ma[pos]}!\n\n\n" + ) self.host.setpoint4R[pos] = self.epo_ma[pos] if self.counter > 3: @@ -124,10 +130,11 @@ def observe(self, epo_reg_loss): self.counter = np.inf # FIXME -class FbOptSetpointController(): +class FbOptSetpointController: """ update setpoint for mu """ + def __init__(self, state=None, args=None): """ kwargs is a dictionary with key the hyper-parameter name and its value @@ -141,7 +148,9 @@ def __init__(self, state=None, args=None): self.flag_setpoint_rewind = args.setpoint_rewind == "yes" self.setpoint_rewinder = SetpointRewinder(self) self.state_task_loss = 0.0 - self.state_epo_reg_loss = [0.0 for _ in range(10)] # FIXME: 10 is the maximum number losses here + self.state_epo_reg_loss = [ + 0.0 for _ in range(10) + ] # FIXME: 10 is the maximum number losses here self.coeff_ma_setpoint = args.coeff_ma_setpoint self.coeff_ma_output = args.coeff_ma_output_state # initial value will be set via trainer @@ -160,31 +169,34 @@ def update_setpoint_ma(self, list_target, list_pos): """ using moving average """ - target_ma = [self.coeff_ma_setpoint * a + - (1 - self.coeff_ma_setpoint) * b - for a, b in zip(self.setpoint4R, list_target)] - self.setpoint4R = [target_ma[i] if i in list_pos else - self.setpoint4R[i] for i in range(len(target_ma))] + target_ma = [ + self.coeff_ma_setpoint * a + (1 - self.coeff_ma_setpoint) * b + for a, b in zip(self.setpoint4R, list_target) + ] + self.setpoint4R = [ + target_ma[i] if i in list_pos else self.setpoint4R[i] + for i in range(len(target_ma)) + ] def observe(self, epo_reg_loss, epo_task_loss): """ read current epo_reg_loss continuously """ - self.state_epo_reg_loss = [self.coeff_ma_output*a + \ - (1-self.coeff_ma_output)*b - if a != 0.0 else b - for a, b in zip( - self.state_epo_reg_loss, epo_reg_loss)] + self.state_epo_reg_loss = [ + self.coeff_ma_output * a + (1 - self.coeff_ma_output) * b if a != 0.0 else b + for a, b in zip(self.state_epo_reg_loss, epo_reg_loss) + ] if self.state_task_loss == 0.0: self.state_task_loss = epo_task_loss - self.state_task_loss = self.coeff_ma_output * self.state_task_loss + \ - (1 - self.coeff_ma_output) * epo_task_loss + self.state_task_loss = ( + self.coeff_ma_output * self.state_task_loss + + (1 - self.coeff_ma_output) * epo_task_loss + ) self.setpoint_rewinder.observe(self.state_epo_reg_loss) flag_update, list_pos = self.state_updater.update_setpoint() if flag_update: self.setpoint_rewinder.reset(self.state_epo_reg_loss) - logger = Logger.get_logger( - logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger(logger_name="main_out_logger", loglevel="INFO") logger.info(f"!!!!!set point old value {self.setpoint4R}!") self.update_setpoint_ma(self.state_epo_reg_loss, list_pos) logger.info(f"!!!!!set point updated to {self.setpoint4R}!") @@ -192,13 +204,13 @@ def observe(self, epo_reg_loss, epo_task_loss): return False -class FbOptSetpointControllerState(): +class FbOptSetpointControllerState: """ abstract state pattern """ + def __init__(self): - """ - """ + """ """ self.host = None def accept(self, controller): @@ -212,6 +224,7 @@ class FixedSetpoint(FbOptSetpointControllerState): """ do not update setpoint """ + def update_setpoint(self): """ always return False so setpoint no update @@ -223,19 +236,23 @@ class SliderAllComponent(FbOptSetpointControllerState): """ concrete state pattern """ + def update_setpoint(self): """ all components of R descreases regardless if ell decreases or not """ - logger = Logger.get_logger( - logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger(logger_name="main_out_logger", loglevel="INFO") logger.info( f"comparing output vs setpoint: \n \ {self.host.state_epo_reg_loss} \n \ - {self.host.setpoint4R}") - if is_less_list_all(self.host.state_epo_reg_loss, - self.host.setpoint4R, flag_eq=True): - logger.info("!!!!!!!!!In SliderAllComponent: R current value better than current setpoint!") + {self.host.setpoint4R}" + ) + if is_less_list_all( + self.host.state_epo_reg_loss, self.host.setpoint4R, flag_eq=True + ): + logger.info( + "!!!!!!!!!In SliderAllComponent: R current value better than current setpoint!" + ) return True, list(range(len(self.host.setpoint4R))) return False, None @@ -244,12 +261,14 @@ class SliderAnyComponent(FbOptSetpointControllerState): """ concrete state pattern """ + def update_setpoint(self): """ if any component of R has decreased regardless if ell decreases """ flag, list_pos = is_less_list_any( - self.host.state_epo_reg_loss, self.host.setpoint4R) + self.host.state_epo_reg_loss, self.host.setpoint4R + ) return flag, list_pos def transit(self): @@ -260,6 +279,7 @@ class DominateAnyComponent(SliderAnyComponent): """ concrete state pattern """ + def update_setpoint(self): """ if any of the component of R loss has decreased together with ell loss @@ -275,6 +295,7 @@ class DominateAllComponent(SliderAllComponent): """ concrete state pattern """ + def update_setpoint(self): """ if each component of R loss has decreased and ell loss also decreased @@ -282,10 +303,10 @@ def update_setpoint(self): flag1, list_pos = super().update_setpoint() flag2 = self.host.state_task_loss < self.host.setpoint4ell if flag2: - logger = Logger.get_logger( - logger_name='main_out_logger', loglevel="INFO") + logger = Logger.get_logger(logger_name="main_out_logger", loglevel="INFO") logger.info( f"best ell loss: from {self.host.setpoint4ell} to \ - {self.host.state_task_loss}") + {self.host.state_task_loss}" + ) self.host.setpoint4ell = self.host.state_task_loss return flag1 & flag2, list_pos diff --git a/domainlab/algos/trainers/train_basic.py b/domainlab/algos/trainers/train_basic.py index ce8eb20f2..02f8e02fe 100644 --- a/domainlab/algos/trainers/train_basic.py +++ b/domainlab/algos/trainers/train_basic.py @@ -38,10 +38,10 @@ def before_epoch(self): def tr_epoch(self, epoch, flag_info=False): self.before_epoch() - for ind_batch, (tensor_x, tensor_y, tensor_d, *others) in \ - enumerate(self.loader_tr): - self.tr_batch(tensor_x, tensor_y, tensor_d, others, - ind_batch, epoch) + for ind_batch, (tensor_x, tensor_y, tensor_d, *others) in enumerate( + self.loader_tr + ): + self.tr_batch(tensor_x, tensor_y, tensor_d, others, ind_batch, epoch) return self.after_epoch(epoch, flag_info) def after_epoch(self, epoch, flag_info): diff --git a/domainlab/algos/trainers/train_dial.py b/domainlab/algos/trainers/train_dial.py index 1faa4d317..76f2dff02 100644 --- a/domainlab/algos/trainers/train_dial.py +++ b/domainlab/algos/trainers/train_dial.py @@ -51,7 +51,6 @@ def _cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): loss_dial = self.model.cal_task_loss(tensor_x_batch_adv_no_grad, tensor_y) return [loss_dial], [self.aconf.gamma_reg] - def hyper_init(self, functor_scheduler, trainer): """ initialize both trainer's multiplier and model's multiplier diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 21bb43981..93017434b 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -2,10 +2,12 @@ update hyper-parameters during training """ from operator import add + import torch -from domainlab.algos.trainers.train_basic import TrainerBasic + from domainlab.algos.trainers.fbopt_mu_controller import HyperSchedulerFeedback from domainlab.algos.trainers.hyper_scheduler import HyperSchedulerWarmupLinear +from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.utils.logger import Logger @@ -16,10 +18,11 @@ def list_divide(list_val, scalar): return [ele / scalar for ele in list_val] -class HyperSetter(): +class HyperSetter: """ mock object to force hyper-parameter in the model """ + def __init__(self, dict_hyper): self.dict_hyper = dict_hyper @@ -31,6 +34,7 @@ class TrainerFbOpt(TrainerBasic): """ TrainerHyperScheduler """ + def set_scheduler(self, scheduler): """ Args: @@ -53,24 +57,37 @@ def eval_r_loss(self): epo_p_loss = 0 counter = 0.0 with torch.no_grad(): - for _, (tensor_x, vec_y, vec_d, *others) in enumerate(self.loader_tr_no_drop): - tensor_x, vec_y, vec_d = \ - tensor_x.to(self.device), vec_y.to(self.device), vec_d.to(self.device) + for _, (tensor_x, vec_y, vec_d, *others) in enumerate( + self.loader_tr_no_drop + ): + tensor_x, vec_y, vec_d = ( + tensor_x.to(self.device), + vec_y.to(self.device), + vec_d.to(self.device), + ) tuple_reg_loss = self.model.cal_reg_loss(tensor_x, vec_y, vec_d, others) p_loss, *_ = self.model.cal_loss(tensor_x, vec_y, vec_d, others) # NOTE: first [0] extract the loss, second [0] get the list list_b_reg_loss = tuple_reg_loss[0] - list_b_reg_loss_sumed = [ele.sum().detach().item() for ele in list_b_reg_loss] + list_b_reg_loss_sumed = [ + ele.sum().detach().item() for ele in list_b_reg_loss + ] if len(epo_reg_loss) == 0: epo_reg_loss = list_b_reg_loss_sumed else: epo_reg_loss = list(map(add, epo_reg_loss, list_b_reg_loss_sumed)) - b_task_loss = self.model.cal_task_loss(tensor_x, vec_y).sum().detach().item() + b_task_loss = ( + self.model.cal_task_loss(tensor_x, vec_y).sum().detach().item() + ) # sum will kill the dimension of the mini batch epo_task_loss += b_task_loss epo_p_loss += p_loss.sum().detach().item() counter += 1.0 - return list_divide(epo_reg_loss, counter), epo_task_loss / counter, epo_p_loss / counter + return ( + list_divide(epo_reg_loss, counter), + epo_task_loss / counter, + epo_p_loss / counter, + ) def before_batch(self, epoch, ind_batch): """ @@ -79,7 +96,9 @@ def before_batch(self, epoch, ind_batch): """ if self.flag_update_hyper_per_batch: # NOTE: if not update per_batch, then not updated - self.model.hyper_update(epoch * self.num_batches + ind_batch, self.hyper_scheduler) + self.model.hyper_update( + epoch * self.num_batches + ind_batch, self.hyper_scheduler + ) return super().after_batch(epoch, ind_batch) def before_tr(self): @@ -93,11 +112,20 @@ def before_tr(self): if self.aconf.tr_with_init_mu: self.tr_with_init_mu() - self.epo_reg_loss_tr, self.epo_task_loss_tr, self.epo_loss_tr = self.eval_r_loss() + ( + self.epo_reg_loss_tr, + self.epo_task_loss_tr, + self.epo_loss_tr, + ) = self.eval_r_loss() self.hyper_scheduler.set_setpoint( - [ele * self.aconf.ini_setpoint_ratio if ele > 0 else - ele / self.aconf.ini_setpoint_ratio for ele in self.epo_reg_loss_tr], - self.epo_task_loss_tr) # setpoing w.r.t. random initialization of neural network + [ + ele * self.aconf.ini_setpoint_ratio + if ele > 0 + else ele / self.aconf.ini_setpoint_ratio + for ele in self.epo_reg_loss_tr + ], + self.epo_task_loss_tr, + ) # setpoing w.r.t. random initialization of neural network self.hyper_scheduler.set_k_i_gain(self.epo_reg_loss_tr) @property @@ -117,7 +145,9 @@ def set_model_with_mu(self): """ set model multipliers """ - self.model.hyper_update(epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu)) + self.model.hyper_update( + epoch=None, fun_scheduler=HyperSetter(self.hyper_scheduler.mmu) + ) def tr_epoch(self, epoch, flag_info=False): """ @@ -128,7 +158,8 @@ def tr_epoch(self, epoch, flag_info=False): self.epo_task_loss_tr, self.epo_loss_tr, self.list_str_multiplier_na, - miter=epoch) + miter=epoch, + ) self.set_model_with_mu() if hasattr(self.model, "dict_multiplier"): logger = Logger.get_logger() @@ -137,5 +168,6 @@ def tr_epoch(self, epoch, flag_info=False): flag = super().tr_epoch(epoch, self.flag_setpoint_updated) # is it good to update setpoint after we know the new value of each loss? self.flag_setpoint_updated = self.hyper_scheduler.update_setpoint( - self.epo_reg_loss_tr, self.epo_task_loss_tr) + self.epo_reg_loss_tr, self.epo_task_loss_tr + ) return flag diff --git a/domainlab/algos/trainers/zoo_trainer.py b/domainlab/algos/trainers/zoo_trainer.py index 9368cc7e7..92a965a65 100644 --- a/domainlab/algos/trainers/zoo_trainer.py +++ b/domainlab/algos/trainers/zoo_trainer.py @@ -3,11 +3,10 @@ """ from domainlab.algos.trainers.train_basic import TrainerBasic from domainlab.algos.trainers.train_dial import TrainerDIAL +from domainlab.algos.trainers.train_fbopt_b import TrainerFbOpt from domainlab.algos.trainers.train_hyper_scheduler import TrainerHyperScheduler from domainlab.algos.trainers.train_matchdg import TrainerMatchDG from domainlab.algos.trainers.train_mldg import TrainerMLDG -from domainlab.algos.trainers.train_hyper_scheduler import TrainerHyperScheduler -from domainlab.algos.trainers.train_fbopt_b import TrainerFbOpt class TrainerChainNodeGetter(object): diff --git a/domainlab/algos/zoo_algos.py b/domainlab/algos/zoo_algos.py index 95c4e0a6d..4b8240387 100644 --- a/domainlab/algos/zoo_algos.py +++ b/domainlab/algos/zoo_algos.py @@ -5,8 +5,8 @@ from domainlab.algos.builder_dann import NodeAlgoBuilderDANN from domainlab.algos.builder_diva import NodeAlgoBuilderDIVA from domainlab.algos.builder_erm import NodeAlgoBuilderERM -from domainlab.algos.builder_hduva import NodeAlgoBuilderHDUVA from domainlab.algos.builder_fbopt_dial import NodeAlgoBuilderFbOptDial +from domainlab.algos.builder_hduva import NodeAlgoBuilderHDUVA from domainlab.algos.builder_jigen1 import NodeAlgoBuilderJiGen from domainlab.utils.u_import import import_path diff --git a/domainlab/arg_parser.py b/domainlab/arg_parser.py index cc281950c..61a2ea97a 100644 --- a/domainlab/arg_parser.py +++ b/domainlab/arg_parser.py @@ -18,77 +18,117 @@ def mk_parser_main(): """ Args for command line definition """ - parser = argparse.ArgumentParser(description='DomainLab') + parser = argparse.ArgumentParser(description="DomainLab") - parser.add_argument('-c', "--config", default=None, - help="load YAML configuration", dest="config_file", - type=argparse.FileType(mode='r')) + parser.add_argument( + "-c", + "--config", + default=None, + help="load YAML configuration", + dest="config_file", + type=argparse.FileType(mode="r"), + ) - parser.add_argument('--lr', type=float, default=1e-4, - help='learning rate') + parser.add_argument("--lr", type=float, default=1e-4, help="learning rate") - parser.add_argument('--gamma_reg', type=float, default=0.1, - help='weight of regularization loss') + parser.add_argument( + "--gamma_reg", type=float, default=0.1, help="weight of regularization loss" + ) - parser.add_argument('--es', type=int, default=1, - help='early stop steps') + parser.add_argument("--es", type=int, default=1, help="early stop steps") - parser.add_argument('--seed', type=int, default=0, - help='random seed (default: 0)') + parser.add_argument("--seed", type=int, default=0, help="random seed (default: 0)") - parser.add_argument('--nocu', action='store_true', default=False, - help='disables CUDA') + parser.add_argument( + "--nocu", action="store_true", default=False, help="disables CUDA" + ) - parser.add_argument('--device', type=str, default=None, - help='device name default None') + parser.add_argument( + "--device", type=str, default=None, help="device name default None" + ) - parser.add_argument('--gen', action='store_true', default=False, - help='save generated images') + parser.add_argument( + "--gen", action="store_true", default=False, help="save generated images" + ) - parser.add_argument('--keep_model', action='store_true', default=False, - help='do not delete model at the end of training') + parser.add_argument( + "--keep_model", + action="store_true", + default=False, + help="do not delete model at the end of training", + ) - parser.add_argument('--epos', default=2, type=int, - help='maximum number of epochs') + parser.add_argument("--epos", default=2, type=int, help="maximum number of epochs") - parser.add_argument('--epos_min', default=0, type=int, - help='maximum number of epochs') + parser.add_argument( + "--epos_min", default=0, type=int, help="maximum number of epochs" + ) - parser.add_argument('--epo_te', default=1, type=int, - help='test performance per {} epochs') + parser.add_argument( + "--epo_te", default=1, type=int, help="test performance per {} epochs" + ) - parser.add_argument('-w', '--warmup', type=int, default=100, - help='number of epochs for hyper-parameter warm-up. \ - Set to 0 to turn warmup off.') + parser.add_argument( + "-w", + "--warmup", + type=int, + default=100, + help="number of epochs for hyper-parameter warm-up. \ + Set to 0 to turn warmup off.", + ) - parser.add_argument('--debug', action='store_true', default=False) - parser.add_argument('--dmem', action='store_true', default=False) - parser.add_argument('--no_dump', action='store_true', default=False, - help='suppress saving the confusion matrix') + parser.add_argument("--debug", action="store_true", default=False) + parser.add_argument("--dmem", action="store_true", default=False) + parser.add_argument( + "--no_dump", + action="store_true", + default=False, + help="suppress saving the confusion matrix", + ) - parser.add_argument('--trainer', type=str, default=None, - help='specify which trainer to use') + parser.add_argument( + "--trainer", type=str, default=None, help="specify which trainer to use" + ) - parser.add_argument('--out', type=str, default="zoutput", - help='absolute directory to store outputs') + parser.add_argument( + "--out", type=str, default="zoutput", help="absolute directory to store outputs" + ) - parser.add_argument('--dpath', type=str, default="zdpath", - help="path for storing downloaded dataset") + parser.add_argument( + "--dpath", + type=str, + default="zdpath", + help="path for storing downloaded dataset", + ) - parser.add_argument('--tpath', type=str, default=None, - help="path for custom task, should implement \ - get_task function") + parser.add_argument( + "--tpath", + type=str, + default=None, + help="path for custom task, should implement \ + get_task function", + ) - parser.add_argument('--npath', type=str, default=None, - help="path of custom neural network for feature \ - extraction") + parser.add_argument( + "--npath", + type=str, + default=None, + help="path of custom neural network for feature \ + extraction", + ) - parser.add_argument('--npath_dom', type=str, default=None, - help="path of custom neural network for feature \ - extraction") + parser.add_argument( + "--npath_dom", + type=str, + default=None, + help="path of custom neural network for feature \ + extraction", + ) - parser.add_argument('--npath_argna2val', action='append', - help="specify new arguments and their value \ + parser.add_argument( + "--npath_argna2val", + action="append", + help="specify new arguments and their value \ e.g. '--npath_argna2val my_custom_arg_na \ --npath_argna2val xx/yy/zz.py', additional \ pairs can be appended", @@ -146,65 +186,103 @@ def mk_parser_main(): dest="bm_dir", help="Aggregates and plots partial data of a snakemake \ benchmark. Requires the benchmark config file. \ - Other arguments will be ignored.") - - parser.add_argument('--gen_plots', type=str, - default=None, dest="plot_data", - help="plots the data of a snakemake benchmark. " - "Requires the results.csv file" - "and an output file (specify by --outp_file," - "default is zoutput/benchmarks/shell_benchmark). " - "Other arguments will be ignored.") - - parser.add_argument('--outp_dir', type=str, - default='zoutput/benchmarks/shell_benchmark', dest="outp_dir", - help="outpus file for the plots when creating them" - "using --gen_plots. " - "Default is zoutput/benchmarks/shell_benchmark") - parser.add_argument('--param_idx', type=bool, - default=True, dest="param_idx", - help="True: parameter index is used in the " - "pots generated with --gen_plots." - "False: parameter name is used." - "Default is True.") - - parser.add_argument('--msel', choices=['val', 'loss_tr', 'last'], default="val", - help='model selection for early stop: val, loss_tr, recon, the \ + Other arguments will be ignored.", + ) + + parser.add_argument( + "--gen_plots", + type=str, + default=None, + dest="plot_data", + help="plots the data of a snakemake benchmark. " + "Requires the results.csv file" + "and an output file (specify by --outp_file," + "default is zoutput/benchmarks/shell_benchmark). " + "Other arguments will be ignored.", + ) + + parser.add_argument( + "--outp_dir", + type=str, + default="zoutput/benchmarks/shell_benchmark", + dest="outp_dir", + help="outpus file for the plots when creating them" + "using --gen_plots. " + "Default is zoutput/benchmarks/shell_benchmark", + ) + parser.add_argument( + "--param_idx", + type=bool, + default=True, + dest="param_idx", + help="True: parameter index is used in the " + "pots generated with --gen_plots." + "False: parameter name is used." + "Default is True.", + ) + + parser.add_argument( + "--msel", + choices=["val", "loss_tr", "last"], + default="val", + help="model selection for early stop: val, loss_tr, recon, the \ elbo and recon only make sense for vae models,\ - will be ignored by other methods') + will be ignored by other methods", + ) - parser.add_argument('--msel_tr_loss', choices=['reg', 'task'], default="task", - help='model selection for tr loss') + parser.add_argument( + "--msel_tr_loss", + choices=["reg", "task"], + default="task", + help="model selection for tr loss", + ) - parser.add_argument('--model', metavar="an", type=str, - default=None, - help='algorithm name') + parser.add_argument( + "--model", metavar="an", type=str, default=None, help="algorithm name" + ) - parser.add_argument('--acon', metavar="ac", type=str, default=None, - help='algorithm configuration name, (default None)') + parser.add_argument( + "--acon", + metavar="ac", + type=str, + default=None, + help="algorithm configuration name, (default None)", + ) - parser.add_argument('--task', metavar="ta", type=str, - help='task name') + parser.add_argument("--task", metavar="ta", type=str, help="task name") - arg_group_task = parser.add_argument_group('task args') + arg_group_task = parser.add_argument_group("task args") - arg_group_task.add_argument('--bs', type=int, default=100, - help='loader batch size for mixed domains') + arg_group_task.add_argument( + "--bs", type=int, default=100, help="loader batch size for mixed domains" + ) - arg_group_task.add_argument('--split', type=float, default=0, - help='proportion of training, a value between \ - 0 and 1, 0 means no train-validation split') + arg_group_task.add_argument( + "--split", + type=float, + default=0, + help="proportion of training, a value between \ + 0 and 1, 0 means no train-validation split", + ) - arg_group_task.add_argument('--te_d', nargs='*', default=None, - help='test domain names separated by single space, \ - will be parsed to be list of strings') + arg_group_task.add_argument( + "--te_d", + nargs="*", + default=None, + help="test domain names separated by single space, \ + will be parsed to be list of strings", + ) - arg_group_task.add_argument('--tr_d', nargs='*', default=None, - help='training domain names separated by \ + arg_group_task.add_argument( + "--tr_d", + nargs="*", + default=None, + help="training domain names separated by \ single space, will be parsed to be list of \ strings; if not provided then all available \ domains that are not assigned to \ - the test set will be used as training domains') + the test set will be used as training domains", + ) arg_group_task.add_argument( "--san_check", @@ -233,7 +311,7 @@ def mk_parser_main(): arg_group_jigen = add_args2parser_jigen(arg_group_jigen) args_group_dial = parser.add_argument_group("dial") args_group_dial = add_args2parser_dial(args_group_dial) - args_group_fbopt = parser.add_argument_group('fbopt') + args_group_fbopt = parser.add_argument_group("fbopt") args_group_fbopt = add_args2parser_fbopt(args_group_fbopt) return parser diff --git a/domainlab/exp_protocol/run_experiment.py b/domainlab/exp_protocol/run_experiment.py index 19d2535ea..f45bc9498 100644 --- a/domainlab/exp_protocol/run_experiment.py +++ b/domainlab/exp_protocol/run_experiment.py @@ -143,10 +143,10 @@ def run_experiment( gpu_ind = param_index % num_gpus args.device = str(gpu_ind) - logger.info('*** begin args') + logger.info("*** begin args") for k, v in vars(args).items(): - logger.info(f'{k} : {v}') - logger.info('*** end args') + logger.info(f"{k} : {v}") + logger.info("*** end args") if torch.cuda.is_available(): torch.cuda.init() diff --git a/domainlab/models/a_model.py b/domainlab/models/a_model.py index f2763f2db..ca639daa2 100644 --- a/domainlab/models/a_model.py +++ b/domainlab/models/a_model.py @@ -13,6 +13,7 @@ class AModel(nn.Module, metaclass=abc.ABCMeta): """ operations that all models (classification, segmentation, seq2seq) """ + def set_params(self, dict_params): """ set diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index fb55e9fe1..54cc7e1f7 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -9,7 +9,9 @@ from domainlab.utils.utils_class import store_args -def mk_diva(parent_class=VAEXYDClassif, str_diva_multiplier_type="default"): # FIXME: should not be default +def mk_diva( + parent_class=VAEXYDClassif, str_diva_multiplier_type="default" +): # FIXME: should not be default """ Instantiate a domain invariant variational autoencoder (DIVA) with arbitrary task loss. @@ -57,11 +59,21 @@ class ModelDIVA(parent_class): """ @store_args - def __init__(self, chain_node_builder, - zd_dim, zy_dim, zx_dim, - list_str_y, list_d_tr, - gamma_d, gamma_y, - beta_d, beta_x, beta_y, mu_recon=1.0): + def __init__( + self, + chain_node_builder, + zd_dim, + zy_dim, + zx_dim, + list_str_y, + list_d_tr, + gamma_d, + gamma_y, + beta_d, + beta_x, + beta_y, + mu_recon=1.0, + ): """ gamma: classification loss coefficient """ @@ -118,12 +130,14 @@ def dict_multiplier(self): """ list of multipliers name, which correspond to cal_reg_loss """ - return {"mu_recon": self.mu_recon, - "beta_d": self.beta_d, - "beta_x": self.beta_x, - "beta_y": self.beta_y, - "gamma_d": self.gamma_d} - + return { + "mu_recon": self.mu_recon, + "beta_d": self.beta_d, + "beta_x": self.beta_x, + "beta_y": self.beta_y, + "gamma_d": self.gamma_d, + } + def _cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): q_zd, zd_q, q_zx, zx_q, q_zy, zy_q = self.encoder(tensor_x) logit_d = self.net_classif_d(zd_q) @@ -157,8 +171,13 @@ def _cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): _, d_target = tensor_d.max(dim=1) lc_d = F.cross_entropy(logit_d, d_target, reduction=g_str_cross_entropy_agg) - return [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ - [self.mu_recon, -self.beta_d, -self.beta_x, -self.beta_y, self.gamma_d] + return [ + loss_recon_x, + zd_p_minus_zd_q, + zx_p_minus_zx_q, + zy_p_minus_zy_q, + lc_d, + ], [self.mu_recon, -self.beta_d, -self.beta_x, -self.beta_y, self.gamma_d] class ModelDIVAGammadRecon(ModelDIVA): def hyper_update(self, epoch, fun_scheduler): @@ -174,7 +193,6 @@ def hyper_update(self, epoch, fun_scheduler): self.gamma_d = dict_rst["gamma_d"] self.mu_recon = dict_rst["mu_recon"] - def hyper_init(self, functor_scheduler, trainer=None): """ initiate a scheduler object via class name and things inside this model @@ -187,23 +205,32 @@ def hyper_init(self, functor_scheduler, trainer=None): beta_y=self.beta_y, beta_x=self.beta_x, gamma_d=self.gamma_d, - mu_recon=self.mu_recon + mu_recon=self.mu_recon, ) class ModelDIVAGammadReconPerPixel(ModelDIVAGammadRecon): def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None): - [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], [mu_recon, minus_beta_d, minus_beta_x, minus_beta_y, gamma_d] = super().cal_reg_loss(tensor_x, tensor_y, tensor_d, others) - - return [torch.div(loss_recon_x, - tensor_x.shape[2] * tensor_x.shape[3]), - zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], \ - [mu_recon, minus_beta_d, minus_beta_x, - minus_beta_y, gamma_d] + [loss_recon_x, zd_p_minus_zd_q, zx_p_minus_zx_q, zy_p_minus_zy_q, lc_d], [ + mu_recon, + minus_beta_d, + minus_beta_x, + minus_beta_y, + gamma_d, + ] = super().cal_reg_loss(tensor_x, tensor_y, tensor_d, others) + + return [ + torch.div(loss_recon_x, tensor_x.shape[2] * tensor_x.shape[3]), + zd_p_minus_zd_q, + zx_p_minus_zx_q, + zy_p_minus_zy_q, + lc_d, + ], [mu_recon, minus_beta_d, minus_beta_x, minus_beta_y, gamma_d] class ModelDIVAGammad(ModelDIVA): """ only adjust gammad and beta """ + def hyper_update(self, epoch, fun_scheduler): """hyper_update. @@ -234,6 +261,7 @@ class ModelDIVADefault(ModelDIVA): """ mock """ + if str_diva_multiplier_type == "gammad_recon": return ModelDIVAGammadRecon if str_diva_multiplier_type == "gammad_recon_per_pixel": @@ -244,4 +272,5 @@ class ModelDIVADefault(ModelDIVA): return ModelDIVADefault raise RuntimeError( "not support argument candiates for str_diva_multiplier_type: \ - allowed: default, gammad_recon, gammad_recon_per_pixel, gammad") + allowed: default, gammad_recon, gammad_recon_per_pixel, gammad" + ) diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index fa33a315e..515a347d4 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -85,24 +85,29 @@ def hyper_init(self, functor_scheduler, trainer=None): beta_d=self.beta_d, beta_y=self.beta_y, beta_x=self.beta_x, - beta_t=self.beta_t) + beta_t=self.beta_t, + ) @store_args - def __init__(self, chain_node_builder, - zy_dim, zd_dim, - list_str_y, - gamma_d, gamma_y, - beta_d, beta_x, beta_y, - beta_t, - device, - zx_dim=0, - topic_dim=3, - mu_recon=1.0): - """ - """ - super().__init__(chain_node_builder, - zd_dim, zy_dim, zx_dim, - list_str_y) + def __init__( + self, + chain_node_builder, + zy_dim, + zd_dim, + list_str_y, + gamma_d, + gamma_y, + beta_d, + beta_x, + beta_y, + beta_t, + device, + zx_dim=0, + topic_dim=3, + mu_recon=1.0, + ): + """ """ + super().__init__(chain_node_builder, zd_dim, zy_dim, zx_dim, list_str_y) # topic to zd follows Gaussian distribution self.add_module( "net_p_zd", @@ -189,8 +194,13 @@ def _cal_reg_loss(self, tensor_x, tensor_y, tensor_d=None, others=None): # reconstruction z_concat = self.decoder.concat_ytdx(zy_q, topic_q, zd_q, zx_q) loss_recon_x, _, _ = self.decoder(z_concat, tensor_x) - return [loss_recon_x, zx_p_minus_q, zy_p_minus_zy_q, zd_p_minus_q, topic_p_minus_q], \ - [self.mu_recon, -self.beta_x, -self.beta_y, -self.beta_d, -self.beta_t] + return [ + loss_recon_x, + zx_p_minus_q, + zy_p_minus_zy_q, + zd_p_minus_q, + topic_p_minus_q, + ], [self.mu_recon, -self.beta_x, -self.beta_y, -self.beta_d, -self.beta_t] @property def list_str_multiplier_na(self): @@ -204,11 +214,13 @@ def dict_multiplier(self): """ dictionary of multipliers name """ - return {"mu_recon": self.mu_recon, - "beta_d": self.beta_d, - "beta_x": self.beta_x, - "beta_y": self.beta_y, - "beta_t": self.beta_t} + return { + "mu_recon": self.mu_recon, + "beta_d": self.beta_d, + "beta_x": self.beta_x, + "beta_y": self.beta_y, + "beta_t": self.beta_t, + } def extract_semantic_feat(self, tensor_x): """ diff --git a/domainlab/tasks/b_task.py b/domainlab/tasks/b_task.py index fcbbe473e..e64222984 100644 --- a/domainlab/tasks/b_task.py +++ b/domainlab/tasks/b_task.py @@ -54,7 +54,9 @@ def init_business(self, args, trainer=None): self.dict_dset_val.update({na_domain: ddset_val}) ddset_mix = ConcatDataset(tuple(self.dict_dset_tr.values())) self._loader_tr = mk_loader(ddset_mix, args.bs) - self._loader_tr_no_drop = mk_loader(ddset_mix, args.bs, drop_last=False, shuffle=False) + self._loader_tr_no_drop = mk_loader( + ddset_mix, args.bs, drop_last=False, shuffle=False + ) ddset_mix_val = ConcatDataset(tuple(self.dict_dset_val.values())) self._loader_val = mk_loader( diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index b58d2ff83..93790878f 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -1,24 +1,28 @@ +import argparse import glob import os -import numpy as np -import argparse import matplotlib.pyplot as plt -from tensorboard.backend.event_processing.event_accumulator \ - import EventAccumulator +import numpy as np +from tensorboard.backend.event_processing.event_accumulator import EventAccumulator -def get_xy_from_event_file(event_file, plot1, plot2=None, - tf_size_guidance=None, - sanity_check=False, verbose=True): +def get_xy_from_event_file( + event_file, + plot1, + plot2=None, + tf_size_guidance=None, + sanity_check=False, + verbose=True, +): if tf_size_guidance is None: # settings for which/how much data is loaded from the # tensorboard event files tf_size_guidance = { - 'compressedHistograms': 0, - 'images': 0, - 'scalars': 1e10, # keep unlimited number - 'histograms': 0 + "compressedHistograms": 0, + "images": 0, + "scalars": 1e10, # keep unlimited number + "histograms": 0, } # load event file event = EventAccumulator(event_file, tf_size_guidance) @@ -26,7 +30,7 @@ def get_xy_from_event_file(event_file, plot1, plot2=None, # print names of available plots if verbose: print(f"Event file {event_file} -- available plots:") - print(event.Tags()['scalars']) + print(event.Tags()["scalars"]) if plot2: # extract the plot2 values (e.g., reg/dyn0) y_event = event.Scalars(plot2) @@ -47,9 +51,16 @@ def get_xy_from_event_file(event_file, plot1, plot2=None, return x, y -def phase_portrait_combined(event_files, colors, plot1, plot2, - legend1=None, legend2=None, plot_len=None, - output_dir="."): +def phase_portrait_combined( + event_files, + colors, + plot1, + plot2, + legend1=None, + legend2=None, + plot_len=None, + output_dir=".", +): """ combined phase portait for multiple (at least one) Tensorboard event files in the same plot @@ -57,8 +68,7 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, plt.figure() for event_i in range(len(event_files)): - x, y = get_xy_from_event_file(event_files[event_i], - plot1=plot1, plot2=plot2) + x, y = get_xy_from_event_file(event_files[event_i], plot1=plot1, plot2=plot2) assert len(x) == len(y) if plot_len is None: @@ -68,25 +78,35 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, head_w_glob = min((max(x) - min(x)) / 100.0, (max(y) - min(y)) / 100.0) for i in range(plot_len - 1): - xy_dist = np.sqrt((x[i + 1] - x[i])**2 + (y[i + 1] - y[i])**2) + xy_dist = np.sqrt((x[i + 1] - x[i]) ** 2 + (y[i + 1] - y[i]) ** 2) head_l = xy_dist / 30.0 head_w = min(head_l, head_w_glob) - plt.arrow(x[i], y[i], (x[i + 1] - x[i]), (y[i + 1] - y[i]), - head_width=head_w, head_length=head_l, - length_includes_head=True, - fc=colors[event_i], ec=colors[event_i], alpha=0.8) + plt.arrow( + x[i], + y[i], + (x[i + 1] - x[i]), + (y[i + 1] - y[i]), + head_width=head_w, + head_length=head_l, + length_includes_head=True, + fc=colors[event_i], + ec=colors[event_i], + alpha=0.8, + ) # the combination of head_width and head_length make the arrow # more visible. # length_includes_head=False makes the arrow stick too far out # beyond of the point, which let; so, True is used. - colors = ['red', 'green', 'blue', 'yellow', 'purple'] - plt.plot(x[0], y[0], 'ko') + colors = ["red", "green", "blue", "yellow", "purple"] + plt.plot(x[0], y[0], "ko") list_color = [colors[i % len(colors)] for i, h in enumerate(x)] plt.scatter(x, y, s=1, c=np.array(list_color)) - if legend1 is None: legend1=plot1 - if legend2 is None: legend2=plot2 + if legend1 is None: + legend1 = plot1 + if legend2 is None: + legend2 = plot2 plt.xlabel(legend1) plt.ylabel(legend2) plt.title("phase portrait") @@ -94,27 +114,37 @@ def phase_portrait_combined(event_files, colors, plot1, plot2, if not os.path.exists(output_dir): os.makedirs(output_dir) legend22 = legend2.split(os.sep)[-1] - plt.savefig(os.path.join(output_dir, - f'phase_portrait_combined_{legend22}.png'), dpi=300) - - -def two_curves_combined(event_files, colors, plot1, plot2, - legend1=None, legend2=None, output_dir=".", title=None): + plt.savefig( + os.path.join(output_dir, f"phase_portrait_combined_{legend22}.png"), dpi=300 + ) + + +def two_curves_combined( + event_files, + colors, + plot1, + plot2, + legend1=None, + legend2=None, + output_dir=".", + title=None, +): """ FIXME: colors parameter is not used """ plt.figure() for event_i in range(len(event_files)): - x, y = get_xy_from_event_file(event_files[event_i], - plot1=plot1, plot2=plot2) + x, y = get_xy_from_event_file(event_files[event_i], plot1=plot1, plot2=plot2) plt.plot(x, color="blue") plt.plot(y, color="red") plt.xlabel("epoch") # plt.ylabel("loss") if title is not None: plt.title(title) - if legend1 is None: legend1=plot1 - if legend2 is None: legend2=plot2 + if legend1 is None: + legend1 = plot1 + if legend2 is None: + legend2 = plot2 plt.legend([legend1, legend2]) legend11 = legend1.replace(os.sep, "_") @@ -122,8 +152,9 @@ def two_curves_combined(event_files, colors, plot1, plot2, if not os.path.exists(output_dir): os.makedirs(output_dir) - plt.savefig(os.path.join(output_dir, - f'timecourse_{legend11}_{legend22}.png'), dpi=300) + plt.savefig( + os.path.join(output_dir, f"timecourse_{legend11}_{legend22}.png"), dpi=300 + ) def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): @@ -135,7 +166,8 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): x, _ = get_xy_from_event_file(event_files[event_i], plot1=plot1) plt.plot(x) plt.xlabel("time") - if legend1 is None: legend1=plot1 + if legend1 is None: + legend1 = plot1 plt.ylabel(legend1) # plt.title("timecourse") @@ -143,47 +175,68 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): if not os.path.exists(output_dir): os.makedirs(output_dir) - plt.savefig(os.path.join(output_dir, - f'timecourse_{legend11}.png'), dpi=300) + plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.png"), dpi=300) if __name__ == "__main__": - parser = argparse.ArgumentParser(description='plot') - parser.add_argument('-plot1', "--plot1", default=None, type=str) - parser.add_argument('-plot2', "--plot2", default=None, type=str) - parser.add_argument('-legend1', "--legend1", default=None, type=str) - parser.add_argument('-legend2', "--legend2", default=None, type=str) - parser.add_argument('-plot_len', "--plot_len", default=None, type=int) - parser.add_argument('-title', "--title", default=None, type=str) - parser.add_argument('--output_dir', default='.', type=str) - parser.add_argument('--phase_portrait', action='store_true', - help="if True plots a phase portrait,\ - otherwise a curve (default)") + parser = argparse.ArgumentParser(description="plot") + parser.add_argument("-plot1", "--plot1", default=None, type=str) + parser.add_argument("-plot2", "--plot2", default=None, type=str) + parser.add_argument("-legend1", "--legend1", default=None, type=str) + parser.add_argument("-legend2", "--legend2", default=None, type=str) + parser.add_argument("-plot_len", "--plot_len", default=None, type=int) + parser.add_argument("-title", "--title", default=None, type=str) + parser.add_argument("--output_dir", default=".", type=str) + parser.add_argument( + "--phase_portrait", + action="store_true", + help="if True plots a phase portrait,\ + otherwise a curve (default)", + ) args = parser.parse_args() # get event files from all available runs event_files = glob.glob("runs/*/events*") - print("Using the following tensorboard event files:\n{}".format( - "\n".join(event_files))) + print( + "Using the following tensorboard event files:\n{}".format( + "\n".join(event_files) + ) + ) # Different colors for the different runs - cmap = plt.get_cmap('tab10') # Choose a colormap + cmap = plt.get_cmap("tab10") # Choose a colormap colors = [cmap(i) for i in range(len(event_files))] if args.phase_portrait: - phase_portrait_combined(event_files, colors, - plot1=args.plot1, plot2=args.plot2, - legend1=args.legend1, legend2=args.legend2, - plot_len=args.plot_len, output_dir=args.output_dir) + phase_portrait_combined( + event_files, + colors, + plot1=args.plot1, + plot2=args.plot2, + legend1=args.legend1, + legend2=args.legend2, + plot_len=args.plot_len, + output_dir=args.output_dir, + ) else: if args.plot2: # two curves per plot - two_curves_combined(event_files, colors, - plot1=args.plot1, plot2=args.plot2, - legend1=args.legend1, legend2=args.legend2, - output_dir=args.output_dir, title=args.title) + two_curves_combined( + event_files, + colors, + plot1=args.plot1, + plot2=args.plot2, + legend1=args.legend1, + legend2=args.legend2, + output_dir=args.output_dir, + title=args.title, + ) else: # one curve per plot - plot_single_curve(event_files, colors, - plot1=args.plot1, legend1=args.legend1, - output_dir=args.output_dir) + plot_single_curve( + event_files, + colors, + plot1=args.plot1, + legend1=args.legend1, + output_dir=args.output_dir, + ) diff --git a/examples/benchmark/mnist_dann_fbopt.yaml b/examples/benchmark/mnist_dann_fbopt.yaml index 9417fbdd3..8bdbe444c 100644 --- a/examples/benchmark/mnist_dann_fbopt.yaml +++ b/examples/benchmark/mnist_dann_fbopt.yaml @@ -44,7 +44,7 @@ Shared params: mu_init: min: 0.000001 - max: 0.00001 + max: 0.00001 num: 2 distribution: uniform diff --git a/examples/benchmark/mnist_diva_fbopt_alone.yaml b/examples/benchmark/mnist_diva_fbopt_alone.yaml index 7ab074716..c483b0e68 100644 --- a/examples/benchmark/mnist_diva_fbopt_alone.yaml +++ b/examples/benchmark/mnist_diva_fbopt_alone.yaml @@ -65,7 +65,7 @@ Shared params: num: 3 distribution: loguniform - mu_clip: + mu_clip: distribution: categorical datatype: float values: diff --git a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml index 8cd4008fb..b687b69f4 100644 --- a/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/mnist_diva_fbopt_and_baselines.yaml @@ -71,7 +71,7 @@ Shared params: num: 3 distribution: loguniform - mu_clip: + mu_clip: distribution: categorical datatype: float values: diff --git a/examples/benchmark/mnist_jigen_fbopt_and_others.yaml b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml index aa03a3040..bd4857610 100644 --- a/examples/benchmark/mnist_jigen_fbopt_and_others.yaml +++ b/examples/benchmark/mnist_jigen_fbopt_and_others.yaml @@ -63,7 +63,7 @@ jigen_feedback: shared: - k_i_gain - mu_clip - + jigen_feedforward: model: jigen trainer: hyperscheduler diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index 0d5bfd072..8c87ddafe 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -87,7 +87,7 @@ Shared params: -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small diva_fbopt_full: model: diva diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 129e392cf..22b5ee4d8 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -93,7 +93,7 @@ Shared params: -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small diva_fbopt_full: model: diva diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml index 8e21dbfe7..36fd10554 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_output_ma_9.yaml @@ -94,7 +94,7 @@ Shared params: -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small diva_fbopt_full: model: diva diff --git a/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml b/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml index 730696f69..e2a78230a 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_fixed.yaml @@ -86,7 +86,7 @@ Shared params: -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small diva_fbopt_full: model: diva diff --git a/examples/benchmark/pacs_hduva_baselines.yaml b/examples/benchmark/pacs_hduva_baselines.yaml index e40759681..cbdb704eb 100644 --- a/examples/benchmark/pacs_hduva_baselines.yaml +++ b/examples/benchmark/pacs_hduva_baselines.yaml @@ -94,7 +94,7 @@ Shared params: -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small hduva_beta_warmup: model: hduva diff --git a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml index 1422a302c..d773cb25b 100644 --- a/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml +++ b/examples/benchmark/pacs_hduva_fbopt_alone_es1_autoki_aug.yaml @@ -94,7 +94,7 @@ Shared params: -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small diva_fbopt_full: model: hduva diff --git a/examples/benchmark/pacs_hduva_matchdg.yaml b/examples/benchmark/pacs_hduva_matchdg.yaml index 1b12d0143..f8c99d6d3 100644 --- a/examples/benchmark/pacs_hduva_matchdg.yaml +++ b/examples/benchmark/pacs_hduva_matchdg.yaml @@ -102,7 +102,7 @@ Shared params: -# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small match_duva: model: matchhduva diff --git a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml index b28be8632..8c4d99d3d 100644 --- a/examples/benchmark/pacs_jigen_baslines4fbopt.yaml +++ b/examples/benchmark/pacs_jigen_baslines4fbopt.yaml @@ -55,7 +55,7 @@ Shared params: # Test fbopt with different hyperparameter configurations - + jigen_feedforward: model: jigen trainer: hyperscheduler diff --git a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml index 0405e6731..3c70d07b6 100644 --- a/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_alone_autoki.yaml @@ -27,7 +27,7 @@ domainlab_args: zx_dim: 0 zy_dim: 64 zd_dim: 64 - pperm: 0.1 + pperm: 0.1 # pperm correspond to 1-bias_wholeimage in https://github.com/fmcarlucci/JigenDG diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml index 5fac934ce..1421913b3 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines.yaml @@ -73,7 +73,7 @@ jigen_feedback: shared: - k_i_gain - mu_clip - + jigen_feedforward: model: jigen trainer: hyperscheduler diff --git a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml index 4fb01259b..3b0f8dba6 100644 --- a/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml +++ b/examples/benchmark/pacs_jigen_fbopt_and_baselines_aug.yaml @@ -86,7 +86,7 @@ jigen_feedback: - k_i_gain_ratio - mu_clip - lr - + jigen_feedforward: model: jigen trainer: hyperscheduler diff --git a/fbopt_mnist_diva_pixel.sh b/fbopt_mnist_diva_pixel.sh index 6440f90c8..bac129db9 100644 --- a/fbopt_mnist_diva_pixel.sh +++ b/fbopt_mnist_diva_pixel.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_benchmark_slurm.sh b/run_benchmark_slurm.sh index 8f6b9f66e..91e06fa62 100755 --- a/run_benchmark_slurm.sh +++ b/run_benchmark_slurm.sh @@ -35,5 +35,4 @@ echo "verbose log: $logfile" rm -f -R .snakemake -snakemake --profile "examples/yaml/slurm" --keep-going --keep-incomplete --notemp --cores 3 -s "domainlab/exp_protocol/benchmark.smk" --configfile "$CONFIGFILE" 2>&1 | tee "$logfile" - +snakemake --profile "examples/yaml/slurm" --keep-going --keep-incomplete --notemp --cores 3 -s "domainlab/exp_protocol/benchmark.smk" --configfile "$CONFIGFILE" 2>&1 | tee "$logfile" diff --git a/run_fbopt_diva.sh b/run_fbopt_diva.sh index 02cfbd6d9..dc48bce9b 100644 --- a/run_fbopt_diva.sh +++ b/run_fbopt_diva.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_fbopt_diva_cpu.sh b/run_fbopt_diva_cpu.sh index 2fa5665f5..59d0c592a 100644 --- a/run_fbopt_diva_cpu.sh +++ b/run_fbopt_diva_cpu.sh @@ -1,5 +1,5 @@ #!/bin/bash -export CUDA_VISIBLE_DEVICES="" +export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_fbopt_mnist.sh b/run_fbopt_mnist.sh index 7f0f7fcf9..2e3edc424 100644 --- a/run_fbopt_mnist.sh +++ b/run_fbopt_mnist.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_fbopt_mnist_diva.sh b/run_fbopt_mnist_diva.sh index 85caf8695..fd5c2b8cf 100644 --- a/run_fbopt_mnist_diva.sh +++ b/run_fbopt_mnist_diva.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_fbopt_mnist_diva_autoki.sh b/run_fbopt_mnist_diva_autoki.sh index 6423ff283..64c19e102 100644 --- a/run_fbopt_mnist_diva_autoki.sh +++ b/run_fbopt_mnist_diva_autoki.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_fbopt_mnist_feedforward.sh b/run_fbopt_mnist_feedforward.sh index b7b1139a7..b04819c61 100644 --- a/run_fbopt_mnist_feedforward.sh +++ b/run_fbopt_mnist_feedforward.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_fbopt_mnist_jigen_autoki.sh b/run_fbopt_mnist_jigen_autoki.sh index 24d7eb059..8b346e011 100644 --- a/run_fbopt_mnist_jigen_autoki.sh +++ b/run_fbopt_mnist_jigen_autoki.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_fbopt_small_pacs.sh b/run_fbopt_small_pacs.sh index 3583837bc..fc3ab6bc7 100644 --- a/run_fbopt_small_pacs.sh +++ b/run_fbopt_small_pacs.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_mnist_jigen.sh b/run_mnist_jigen.sh index 2b06392a4..0bc854c5e 100644 --- a/run_mnist_jigen.sh +++ b/run_mnist_jigen.sh @@ -1,8 +1,7 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py -python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --model=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=200 --mu_init=1.0 --coeff_ma_output=0 --coeff_ma_setpoint=0 --coeff_ma_output=0 - +python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --model=jigen --trainer=fbopt --nname=alexnet --epos=200 --es=200 --mu_init=1.0 --coeff_ma_output=0 --coeff_ma_setpoint=0 --coeff_ma_output=0 diff --git a/run_pacs_diva_fbopt.sh b/run_pacs_diva_fbopt.sh index 0157b21a8..74d1f0cd3 100644 --- a/run_pacs_diva_fbopt.sh +++ b/run_pacs_diva_fbopt.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/run_pacs_jigen_fbopt.sh b/run_pacs_jigen_fbopt.sh index 70be6b7fe..99663ee61 100644 --- a/run_pacs_jigen_fbopt.sh +++ b/run_pacs_jigen_fbopt.sh @@ -1,5 +1,5 @@ #!/bin/bash -# export CUDA_VISIBLE_DEVICES="" +# export CUDA_VISIBLE_DEVICES="" # although garbage collector has been explicitly called, sometimes there is still CUDA out of memory error # so it is better not to use GPU to do the pytest to ensure every time there is no CUDA out of memory error occuring # pytest -s tests/test_fbopt.py diff --git a/script_jigen_plot.sh b/script_jigen_plot.sh index 6d770a266..5c47a68f8 100755 --- a/script_jigen_plot.sh +++ b/script_jigen_plot.sh @@ -1,4 +1,4 @@ -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_alpha" --plot1="loss_task/ell" --legend2="regularization loss jigen" --legend1="classification loss" --output_dir="." --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_alpha" --plot1="loss_task/ell" --legend2="regularization loss jigen" --legend1="classification loss" --output_dir="." --phase_portrait python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrs/setpoint_alpha" --plot2="lossrd/dyn_alpha" --legend2="regularization loss jigen" --legend1="setpoint" --output_dir="." diff --git a/test_fbopt_dial.sh b/test_fbopt_dial.sh index 9583fa080..4bf0c669b 100644 --- a/test_fbopt_dial.sh +++ b/test_fbopt_dial.sh @@ -1,2 +1,2 @@ -export CUDA_VISIBLE_DEVICES="" +export CUDA_VISIBLE_DEVICES="" python main_out.py --te_d=caltech --task=mini_vlcs --bs=16 --model=fboptdial --trainer=dial --nname=alexnet --nname_dom=alexnet --gamma_y=1e6 --gamma_d=1e6 diff --git a/test_match_duva.sh b/test_match_duva.sh index c67c93ea2..9f3e9951e 100644 --- a/test_match_duva.sh +++ b/test_match_duva.sh @@ -2,5 +2,3 @@ python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --debug --bs=2 -- --epochs_ctr=3 --epos=6 --nname=conv_bn_pool_2 --gamma_y=7e5 \ --nname_encoder_x2topic_h=conv_bn_pool_2 \ --nname_encoder_sandwich_x2h4zd=conv_bn_pool_2 - - diff --git a/tests/test_fbopt.py b/tests/test_fbopt.py index 5d13404c6..1e2859291 100644 --- a/tests/test_fbopt.py +++ b/tests/test_fbopt.py @@ -19,6 +19,7 @@ def test_jigen_fbopt(): args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --model=jigen --trainer=fbopt --nname=alexnet --epos=3" utils_test_algo(args) + def test_diva_fbopt(): """ diva @@ -26,10 +27,10 @@ def test_diva_fbopt(): args = "--te_d=caltech --task=mini_vlcs --debug --bs=2 --model=diva --gamma_y=1.0 --trainer=fbopt --nname=alexnet --epos=3" utils_test_algo(args) + def test_forcesetpoint_fbopt(): """ diva """ args = "--te_d=0 --tr_d 1 2 --task=mnistcolor10 --bs=16 --model=jigen --trainer=fbopt --nname=conv_bn_pool_2 --epos=10 --es=0 --mu_init=0.00001 --coeff_ma_setpoint=0.5 --coeff_ma_output_state=0.99 --force_setpoint_change_once" utils_test_algo(args) - diff --git a/tests/test_fbopt_setpoint_ada.py b/tests/test_fbopt_setpoint_ada.py index 3eeca4d0a..4b8029056 100644 --- a/tests/test_fbopt_setpoint_ada.py +++ b/tests/test_fbopt_setpoint_ada.py @@ -1,7 +1,9 @@ from domainlab.algos.trainers.fbopt_setpoint_ada import is_less_list_all + + def test_less_than(): - a = [3, 4, -9, -8] - b = [1, 0.5, -1, -0.5] - c = [0.5, 0.25, -0.5, -0.25] - assert not is_less_list_all(a, b) - assert is_less_list_all(c, b) + a = [3, 4, -9, -8] + b = [1, 0.5, -1, -0.5] + c = [0.5, 0.25, -0.5, -0.25] + assert not is_less_list_all(a, b) + assert is_less_list_all(c, b) diff --git a/tests/test_fbopt_setpoint_rewind.py b/tests/test_fbopt_setpoint_rewind.py index e1b797c4d..3c1011bab 100644 --- a/tests/test_fbopt_setpoint_rewind.py +++ b/tests/test_fbopt_setpoint_rewind.py @@ -3,6 +3,7 @@ """ from tests.utils_test import utils_test_algo + def test_jigen_fbopt(): """ jigen From 2ec560ede47bec3741ec712d35094048660d2e0f Mon Sep 17 00:00:00 2001 From: nutan Date: Wed, 17 Jan 2024 18:38:59 +0100 Subject: [PATCH 694/762] c_msel_val_top_k --- domainlab/algos/msels/c_msel_val_top_k.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index a28015da0..4836a6245 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -43,7 +43,9 @@ def update(self, clear_counter=False): # issue #569: initially self.list_top_k_acc will be [xx, 0] and it does not matter since 0 will be overwriten by second epoch validation acc. # actually, after epoch 1, most often, sefl._best_val_acc will be the higher value of self.list_top_k_acc will overwriten by min(self.list_top_k_acc) logger.info( - f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to minium of {self.list_top_k_acc} which is {min(self.list_top_k_acc)} to ensure consistency" + f"top-2 val sel: overwriting best val acc from {self._best_val_acc} to " + f"minimum of {self.list_top_k_acc} which is {min(self.list_top_k_acc)} " + f"to ensure consistency" ) self._best_val_acc = min(self.list_top_k_acc) # overwrite test acc, this does not depend on if val top-k acc has been overwritten or not @@ -51,7 +53,8 @@ def update(self, clear_counter=False): if self._sel_model_te_acc != metric_te_current: # this can only happen if the validation acc has decreased and current val acc is only bigger than min(self.list_top_k_acc} but lower than max(self.list_top_k_acc) logger.info( - f"top-2 val sel: overwriting selected model test acc from {self._sel_model_te_acc} to {metric_te_current} to ensure consistency" + f"top-2 val sel: overwriting selected model test acc from " + f"{self._sel_model_te_acc} to {metric_te_current} to ensure consistency" ) self._sel_model_te_acc = metric_te_current return True From 96e0b44986480603358626d5cc25fa9fce0fae5d Mon Sep 17 00:00:00 2001 From: nutan Date: Wed, 17 Jan 2024 18:39:37 +0100 Subject: [PATCH 695/762] c_msel_setpoin_delay --- domainlab/algos/msels/c_msel_setpoint_delay.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 3812c7de1..87c9b3c84 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -35,9 +35,12 @@ def update(self, clear_counter=False): f"setpoint selected current acc {self._oracle_last_setpoint_sel_te_acc}" ) if clear_counter: - logger.info( - "setpoint msel te acc updated from {self._oracle_last_setpoint_sel_te_acc} to {self.sel_model_te_acc}" + log_message = ( + f"setpoint msel te acc updated from " + f"{self._oracle_last_setpoint_sel_te_acc} to " + f"{self.sel_model_te_acc}" ) + logger.info(log_message) self._oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc flag = self.msel.update(clear_counter) return flag From 791d4b7dcf3dfbb52b6307e95d80c517b3b86906 Mon Sep 17 00:00:00 2001 From: nutan Date: Wed, 17 Jan 2024 18:44:35 +0100 Subject: [PATCH 696/762] resolve too many attributes --- domainlab/algos/trainers/fbopt_mu_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 9c4fbf8c5..69e453918 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -31,6 +31,7 @@ def add_scalars(self, *args, **kwargs): class HyperSchedulerFeedback: + # pylint: disable=too-many-instance-attributes """ design $\\mu$$ sequence based on state of penalized loss """ From 30393a3b1d9bbcfab6fe75a2dd8393152cccc1ed Mon Sep 17 00:00:00 2001 From: nutan Date: Wed, 17 Jan 2024 18:54:09 +0100 Subject: [PATCH 697/762] ignore too many local variables --- domainlab/algos/trainers/fbopt_mu_controller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 69e453918..205bc1039 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -177,6 +177,7 @@ def cal_activation(self): def search_mu( self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, miter ): + # pylint: disable=too-many-locals """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value From 3a077f63711bdb5f99495bf54ed086824850be61 Mon Sep 17 00:00:00 2001 From: nutan Date: Wed, 17 Jan 2024 18:59:50 +0100 Subject: [PATCH 698/762] code style --- domainlab/algos/trainers/fbopt_mu_controller.py | 2 +- domainlab/algos/trainers/fbopt_setpoint_ada.py | 2 ++ domainlab/algos/trainers/train_fbopt_b.py | 1 + domainlab/models/model_diva.py | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/domainlab/algos/trainers/fbopt_mu_controller.py b/domainlab/algos/trainers/fbopt_mu_controller.py index 205bc1039..9f8e02971 100644 --- a/domainlab/algos/trainers/fbopt_mu_controller.py +++ b/domainlab/algos/trainers/fbopt_mu_controller.py @@ -177,7 +177,7 @@ def cal_activation(self): def search_mu( self, epo_reg_loss, epo_task_loss, epo_loss_tr, list_str_multiplier_na, miter ): - # pylint: disable=too-many-locals + # pylint: disable=too-many-locals, too-many-arguments """ start from parameter dictionary dict_theta: {"layer":tensor}, enlarge mu w.r.t. its current value diff --git a/domainlab/algos/trainers/fbopt_setpoint_ada.py b/domainlab/algos/trainers/fbopt_setpoint_ada.py index 433dadded..c3c0193ce 100644 --- a/domainlab/algos/trainers/fbopt_setpoint_ada.py +++ b/domainlab/algos/trainers/fbopt_setpoint_ada.py @@ -131,6 +131,7 @@ def observe(self, epo_reg_loss): class FbOptSetpointController: + # pylint: disable=too-many-instance-attributes """ update setpoint for mu """ @@ -205,6 +206,7 @@ def observe(self, epo_reg_loss, epo_task_loss): class FbOptSetpointControllerState: + # pylint: disable=too-few-public-methods """ abstract state pattern """ diff --git a/domainlab/algos/trainers/train_fbopt_b.py b/domainlab/algos/trainers/train_fbopt_b.py index 93017434b..7258453ba 100644 --- a/domainlab/algos/trainers/train_fbopt_b.py +++ b/domainlab/algos/trainers/train_fbopt_b.py @@ -19,6 +19,7 @@ def list_divide(list_val, scalar): class HyperSetter: + # pylint: disable=too-few-public-methods """ mock object to force hyper-parameter in the model """ diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 54cc7e1f7..8dcbb629b 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -74,6 +74,7 @@ def __init__( beta_y, mu_recon=1.0, ): + # pylint: disable=too-many-arguments """ gamma: classification loss coefficient """ From c39fb0075fbfcdc22b01989ba094b655c3f4f976 Mon Sep 17 00:00:00 2001 From: nutan Date: Wed, 17 Jan 2024 19:05:34 +0100 Subject: [PATCH 699/762] pylint --- domainlab/models/model_diva.py | 2 +- domainlab/models/model_hduva.py | 1 + domainlab/utils/generate_fbopt_phase_portrait.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/domainlab/models/model_diva.py b/domainlab/models/model_diva.py index 8dcbb629b..eb41a84f0 100644 --- a/domainlab/models/model_diva.py +++ b/domainlab/models/model_diva.py @@ -74,7 +74,7 @@ def __init__( beta_y, mu_recon=1.0, ): - # pylint: disable=too-many-arguments + # pylint: disable=too-many-arguments, unused-argument """ gamma: classification loss coefficient """ diff --git a/domainlab/models/model_hduva.py b/domainlab/models/model_hduva.py index 515a347d4..a86c4e405 100644 --- a/domainlab/models/model_hduva.py +++ b/domainlab/models/model_hduva.py @@ -106,6 +106,7 @@ def __init__( topic_dim=3, mu_recon=1.0, ): + # pylint: disable=too-many-arguments, unused-argument """ """ super().__init__(chain_node_builder, zd_dim, zy_dim, zx_dim, list_str_y) # topic to zd follows Gaussian distribution diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 93790878f..6bd841b07 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -1,3 +1,7 @@ +""" +This file is used to generate phase portraits. +""" + import argparse import glob import os From fb93437bcd51cf6a51689f42adccc128d8987732 Mon Sep 17 00:00:00 2001 From: nutan Date: Wed, 17 Jan 2024 19:15:35 +0100 Subject: [PATCH 700/762] pylint --- domainlab/utils/generate_fbopt_phase_portrait.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 6bd841b07..2b9baae07 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -1,5 +1,5 @@ """ -This file is used to generate phase portraits. +This file is used for generating phase portrait from tensorboard event files. """ import argparse @@ -11,6 +11,7 @@ from tensorboard.backend.event_processing.event_accumulator import EventAccumulator +# pylint: disable=too-many-arguments def get_xy_from_event_file( event_file, plot1, @@ -19,6 +20,9 @@ def get_xy_from_event_file( sanity_check=False, verbose=True, ): + """ + extract x and y values from a tensorboard event file + """ if tf_size_guidance is None: # settings for which/how much data is loaded from the # tensorboard event files @@ -55,6 +59,7 @@ def get_xy_from_event_file( return x, y +# pylint: disable=too-many-arguments, too-many-locals, redefined-outer-name, unused-argument def phase_portrait_combined( event_files, colors, From 2319105e39644757beba7d8aade32ed73576ec8c Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 19 Jan 2024 14:17:43 +0100 Subject: [PATCH 701/762] Update pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 16813df95..80007070f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ pandas = "^1.5.1" scikit-learn = "^1.2.1" pyyaml = "^6.0" gdown = "^4.7.1" +tensorboard = "^2.14.0" [tool.poetry.scripts] domainlab = 'domainlab.cli:domainlab_cli' From 04a6f25da58c489a1c66cccb6ad2c8885495a4ec Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 19 Jan 2024 15:00:33 +0100 Subject: [PATCH 702/762] Update ci.yml: revert how pytest runs: no poetry --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1ec8923d..d3007d6cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: pip install poetry poetry install --with dev - name: Generate coverage report - run: poetry run pytest --cov=domainlab tests/ --cov-report=xml + run: pytest --cov=domainlab tests/ --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: From 1298519e35125b77f1547763b07a5955623f88a1 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Fri, 19 Jan 2024 17:11:33 +0100 Subject: [PATCH 703/762] Update pyproject.toml: rm tensorboard = "^2.14.0" --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 80007070f..16813df95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,6 @@ pandas = "^1.5.1" scikit-learn = "^1.2.1" pyyaml = "^6.0" gdown = "^4.7.1" -tensorboard = "^2.14.0" [tool.poetry.scripts] domainlab = 'domainlab.cli:domainlab_cli' From 5bd00d6768ca1a7436ede842baf905d1dd3aafe0 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 21 Jan 2024 16:58:04 +0100 Subject: [PATCH 704/762] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7259f4d4..fc0fca8ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: pip install poetry poetry install --with dev - name: Generate coverage report - run: pytest --cov=domainlab tests/ --cov-report=xml + run: poetry pytest --cov=domainlab tests/ --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: From 108c2e779a03b8e5b8082701abe00ebfadabb5ea Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Sun, 21 Jan 2024 16:58:41 +0100 Subject: [PATCH 705/762] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc0fca8ea..b84b1803d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: pip install poetry poetry install --with dev - name: Generate coverage report - run: poetry pytest --cov=domainlab tests/ --cov-report=xml + run: poetry run pytest --cov=domainlab tests/ --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: From 00a30af60d4b1dab5de68af3089e54aa3351bcd6 Mon Sep 17 00:00:00 2001 From: smilesun Date: Sun, 21 Jan 2024 18:07:56 +0100 Subject: [PATCH 706/762] add tensorboard to pyproject --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ef81af58b..545a508a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ pandas = "^1.5.1" scikit-learn = "^1.2.1" pyyaml = "^6.0" gdown = "^4.7.1" +tensorboard = "^2.14.0" [tool.poetry.scripts] domainlab = 'domainlab.cli:domainlab_cli' From 6dbe7d650beced55ddf49d1b771980dfc8560bfd Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Mon, 22 Jan 2024 11:12:45 +0000 Subject: [PATCH 707/762] update poetry.lock file --- poetry.lock | 2227 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 1301 insertions(+), 926 deletions(-) diff --git a/poetry.lock b/poetry.lock index 2e8de781b..301d0c87e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,72 +1,250 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "absl-py" +version = "2.1.0" +description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py." +optional = false +python-versions = ">=3.7" +files = [ + {file = "absl-py-2.1.0.tar.gz", hash = "sha256:7820790efbb316739cde8b4e19357243fc3608a152024288513dd968d7d959ff"}, + {file = "absl_py-2.1.0-py3-none-any.whl", hash = "sha256:526a04eadab8b4ee719ce68f204172ead1027549089702d99b9059f129ff1308"}, +] + [[package]] name = "atomicwrites" version = "1.4.1" description = "Atomic file writes." -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, +] [[package]] name = "attrs" -version = "23.1.0" +version = "23.2.0" description = "Classes Without Boilerplate" -category = "dev" optional = false python-versions = ">=3.7" +files = [ + {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, + {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, +] [package.extras] cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] -dev = ["attrs[docs,tests]", "pre-commit"] +dev = ["attrs[tests]", "pre-commit"] docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] tests = ["attrs[tests-no-zope]", "zope-interface"] -tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] +tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] [[package]] name = "beautifulsoup4" -version = "4.12.2" +version = "4.12.3" description = "Screen-scraping library" -category = "main" optional = false python-versions = ">=3.6.0" +files = [ + {file = "beautifulsoup4-4.12.3-py3-none-any.whl", hash = "sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed"}, + {file = "beautifulsoup4-4.12.3.tar.gz", hash = "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"}, +] [package.dependencies] soupsieve = ">1.2" [package.extras] +cchardet = ["cchardet"] +chardet = ["chardet"] +charset-normalizer = ["charset-normalizer"] html5lib = ["html5lib"] lxml = ["lxml"] +[[package]] +name = "cachetools" +version = "5.3.2" +description = "Extensible memoizing collections and decorators" +optional = false +python-versions = ">=3.7" +files = [ + {file = "cachetools-5.3.2-py3-none-any.whl", hash = "sha256:861f35a13a451f94e301ce2bec7cac63e881232ccce7ed67fab9b5df4d3beaa1"}, + {file = "cachetools-5.3.2.tar.gz", hash = "sha256:086ee420196f7b2ab9ca2db2520aca326318b68fe5ba8bc4d49cca91add450f2"}, +] + [[package]] name = "certifi" version = "2023.11.17" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, + {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, +] [[package]] name = "charset-normalizer" version = "3.3.2" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = ">=3.7.0" +files = [ + {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-win32.whl", hash = "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73"}, + {file = "charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-win32.whl", hash = "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab"}, + {file = "charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-win32.whl", hash = "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7"}, + {file = "charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-win32.whl", hash = "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4"}, + {file = "charset_normalizer-3.3.2-cp37-cp37m-win_amd64.whl", hash = "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-win32.whl", hash = "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25"}, + {file = "charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-win32.whl", hash = "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f"}, + {file = "charset_normalizer-3.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d"}, + {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"}, +] [[package]] name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] [[package]] name = "contourpy" version = "1.2.0" description = "Python library for calculating contours of 2D quadrilateral grids" -category = "main" optional = false python-versions = ">=3.9" +files = [ + {file = "contourpy-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0274c1cb63625972c0c007ab14dd9ba9e199c36ae1a231ce45d725cbcbfd10a8"}, + {file = "contourpy-1.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ab459a1cbbf18e8698399c595a01f6dcc5c138220ca3ea9e7e6126232d102bb4"}, + {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fdd887f17c2f4572ce548461e4f96396681212d858cae7bd52ba3310bc6f00f"}, + {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5d16edfc3fc09968e09ddffada434b3bf989bf4911535e04eada58469873e28e"}, + {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1c203f617abc0dde5792beb586f827021069fb6d403d7f4d5c2b543d87edceb9"}, + {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b69303ceb2e4d4f146bf82fda78891ef7bcd80c41bf16bfca3d0d7eb545448aa"}, + {file = "contourpy-1.2.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:884c3f9d42d7218304bc74a8a7693d172685c84bd7ab2bab1ee567b769696df9"}, + {file = "contourpy-1.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4a1b1208102be6e851f20066bf0e7a96b7d48a07c9b0cfe6d0d4545c2f6cadab"}, + {file = "contourpy-1.2.0-cp310-cp310-win32.whl", hash = "sha256:34b9071c040d6fe45d9826cbbe3727d20d83f1b6110d219b83eb0e2a01d79488"}, + {file = "contourpy-1.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:bd2f1ae63998da104f16a8b788f685e55d65760cd1929518fd94cd682bf03e41"}, + {file = "contourpy-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:dd10c26b4eadae44783c45ad6655220426f971c61d9b239e6f7b16d5cdaaa727"}, + {file = "contourpy-1.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5c6b28956b7b232ae801406e529ad7b350d3f09a4fde958dfdf3c0520cdde0dd"}, + {file = "contourpy-1.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ebeac59e9e1eb4b84940d076d9f9a6cec0064e241818bcb6e32124cc5c3e377a"}, + {file = "contourpy-1.2.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:139d8d2e1c1dd52d78682f505e980f592ba53c9f73bd6be102233e358b401063"}, + {file = "contourpy-1.2.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1e9dc350fb4c58adc64df3e0703ab076f60aac06e67d48b3848c23647ae4310e"}, + {file = "contourpy-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18fc2b4ed8e4a8fe849d18dce4bd3c7ea637758c6343a1f2bae1e9bd4c9f4686"}, + {file = "contourpy-1.2.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:16a7380e943a6d52472096cb7ad5264ecee36ed60888e2a3d3814991a0107286"}, + {file = "contourpy-1.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8d8faf05be5ec8e02a4d86f616fc2a0322ff4a4ce26c0f09d9f7fb5330a35c95"}, + {file = "contourpy-1.2.0-cp311-cp311-win32.whl", hash = "sha256:67b7f17679fa62ec82b7e3e611c43a016b887bd64fb933b3ae8638583006c6d6"}, + {file = "contourpy-1.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:99ad97258985328b4f207a5e777c1b44a83bfe7cf1f87b99f9c11d4ee477c4de"}, + {file = "contourpy-1.2.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:575bcaf957a25d1194903a10bc9f316c136c19f24e0985a2b9b5608bdf5dbfe0"}, + {file = "contourpy-1.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9e6c93b5b2dbcedad20a2f18ec22cae47da0d705d454308063421a3b290d9ea4"}, + {file = "contourpy-1.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:464b423bc2a009088f19bdf1f232299e8b6917963e2b7e1d277da5041f33a779"}, + {file = "contourpy-1.2.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:68ce4788b7d93e47f84edd3f1f95acdcd142ae60bc0e5493bfd120683d2d4316"}, + {file = "contourpy-1.2.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d7d1f8871998cdff5d2ff6a087e5e1780139abe2838e85b0b46b7ae6cc25399"}, + {file = "contourpy-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e739530c662a8d6d42c37c2ed52a6f0932c2d4a3e8c1f90692ad0ce1274abe0"}, + {file = "contourpy-1.2.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:247b9d16535acaa766d03037d8e8fb20866d054d3c7fbf6fd1f993f11fc60ca0"}, + {file = "contourpy-1.2.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:461e3ae84cd90b30f8d533f07d87c00379644205b1d33a5ea03381edc4b69431"}, + {file = "contourpy-1.2.0-cp312-cp312-win32.whl", hash = "sha256:1c2559d6cffc94890b0529ea7eeecc20d6fadc1539273aa27faf503eb4656d8f"}, + {file = "contourpy-1.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:491b1917afdd8638a05b611a56d46587d5a632cabead889a5440f7c638bc6ed9"}, + {file = "contourpy-1.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5fd1810973a375ca0e097dee059c407913ba35723b111df75671a1976efa04bc"}, + {file = "contourpy-1.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:999c71939aad2780f003979b25ac5b8f2df651dac7b38fb8ce6c46ba5abe6ae9"}, + {file = "contourpy-1.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b7caf9b241464c404613512d5594a6e2ff0cc9cb5615c9475cc1d9b514218ae8"}, + {file = "contourpy-1.2.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:266270c6f6608340f6c9836a0fb9b367be61dde0c9a9a18d5ece97774105ff3e"}, + {file = "contourpy-1.2.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbd50d0a0539ae2e96e537553aff6d02c10ed165ef40c65b0e27e744a0f10af8"}, + {file = "contourpy-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:11f8d2554e52f459918f7b8e6aa20ec2a3bce35ce95c1f0ef4ba36fbda306df5"}, + {file = "contourpy-1.2.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ce96dd400486e80ac7d195b2d800b03e3e6a787e2a522bfb83755938465a819e"}, + {file = "contourpy-1.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6d3364b999c62f539cd403f8123ae426da946e142312a514162adb2addd8d808"}, + {file = "contourpy-1.2.0-cp39-cp39-win32.whl", hash = "sha256:1c88dfb9e0c77612febebb6ac69d44a8d81e3dc60f993215425b62c1161353f4"}, + {file = "contourpy-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:78e6ad33cf2e2e80c5dfaaa0beec3d61face0fb650557100ee36db808bfa6843"}, + {file = "contourpy-1.2.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:be16975d94c320432657ad2402f6760990cb640c161ae6da1363051805fa8108"}, + {file = "contourpy-1.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b95a225d4948b26a28c08307a60ac00fb8671b14f2047fc5476613252a129776"}, + {file = "contourpy-1.2.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:0d7e03c0f9a4f90dc18d4e77e9ef4ec7b7bbb437f7f675be8e530d65ae6ef956"}, + {file = "contourpy-1.2.0.tar.gz", hash = "sha256:171f311cb758de7da13fc53af221ae47a5877be5a0843a9fe150818c51ed276a"}, +] [package.dependencies] numpy = ">=1.20,<2.0" @@ -82,9 +260,62 @@ test-no-images = ["pytest", "pytest-cov", "pytest-xdist", "wurlitzer"] name = "coverage" version = "7.4.0" description = "Code coverage measurement for Python" -category = "dev" optional = false python-versions = ">=3.8" +files = [ + {file = "coverage-7.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36b0ea8ab20d6a7564e89cb6135920bc9188fb5f1f7152e94e8300b7b189441a"}, + {file = "coverage-7.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0676cd0ba581e514b7f726495ea75aba3eb20899d824636c6f59b0ed2f88c471"}, + {file = "coverage-7.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0ca5c71a5a1765a0f8f88022c52b6b8be740e512980362f7fdbb03725a0d6b9"}, + {file = "coverage-7.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a7c97726520f784239f6c62506bc70e48d01ae71e9da128259d61ca5e9788516"}, + {file = "coverage-7.4.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:815ac2d0f3398a14286dc2cea223a6f338109f9ecf39a71160cd1628786bc6f5"}, + {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:80b5ee39b7f0131ebec7968baa9b2309eddb35b8403d1869e08f024efd883566"}, + {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:5b2ccb7548a0b65974860a78c9ffe1173cfb5877460e5a229238d985565574ae"}, + {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:995ea5c48c4ebfd898eacb098164b3cc826ba273b3049e4a889658548e321b43"}, + {file = "coverage-7.4.0-cp310-cp310-win32.whl", hash = "sha256:79287fd95585ed36e83182794a57a46aeae0b64ca53929d1176db56aacc83451"}, + {file = "coverage-7.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:5b14b4f8760006bfdb6e08667af7bc2d8d9bfdb648351915315ea17645347137"}, + {file = "coverage-7.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:04387a4a6ecb330c1878907ce0dc04078ea72a869263e53c72a1ba5bbdf380ca"}, + {file = "coverage-7.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ea81d8f9691bb53f4fb4db603203029643caffc82bf998ab5b59ca05560f4c06"}, + {file = "coverage-7.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74775198b702868ec2d058cb92720a3c5a9177296f75bd97317c787daf711505"}, + {file = "coverage-7.4.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:76f03940f9973bfaee8cfba70ac991825611b9aac047e5c80d499a44079ec0bc"}, + {file = "coverage-7.4.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:485e9f897cf4856a65a57c7f6ea3dc0d4e6c076c87311d4bc003f82cfe199d25"}, + {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6ae8c9d301207e6856865867d762a4b6fd379c714fcc0607a84b92ee63feff70"}, + {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bf477c355274a72435ceb140dc42de0dc1e1e0bf6e97195be30487d8eaaf1a09"}, + {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:83c2dda2666fe32332f8e87481eed056c8b4d163fe18ecc690b02802d36a4d26"}, + {file = "coverage-7.4.0-cp311-cp311-win32.whl", hash = "sha256:697d1317e5290a313ef0d369650cfee1a114abb6021fa239ca12b4849ebbd614"}, + {file = "coverage-7.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:26776ff6c711d9d835557ee453082025d871e30b3fd6c27fcef14733f67f0590"}, + {file = "coverage-7.4.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:13eaf476ec3e883fe3e5fe3707caeb88268a06284484a3daf8250259ef1ba143"}, + {file = "coverage-7.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:846f52f46e212affb5bcf131c952fb4075b55aae6b61adc9856222df89cbe3e2"}, + {file = "coverage-7.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26f66da8695719ccf90e794ed567a1549bb2644a706b41e9f6eae6816b398c4a"}, + {file = "coverage-7.4.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:164fdcc3246c69a6526a59b744b62e303039a81e42cfbbdc171c91a8cc2f9446"}, + {file = "coverage-7.4.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:316543f71025a6565677d84bc4df2114e9b6a615aa39fb165d697dba06a54af9"}, + {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:bb1de682da0b824411e00a0d4da5a784ec6496b6850fdf8c865c1d68c0e318dd"}, + {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:0e8d06778e8fbffccfe96331a3946237f87b1e1d359d7fbe8b06b96c95a5407a"}, + {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a56de34db7b7ff77056a37aedded01b2b98b508227d2d0979d373a9b5d353daa"}, + {file = "coverage-7.4.0-cp312-cp312-win32.whl", hash = "sha256:51456e6fa099a8d9d91497202d9563a320513fcf59f33991b0661a4a6f2ad450"}, + {file = "coverage-7.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:cd3c1e4cb2ff0083758f09be0f77402e1bdf704adb7f89108007300a6da587d0"}, + {file = "coverage-7.4.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e9d1bf53c4c8de58d22e0e956a79a5b37f754ed1ffdbf1a260d9dcfa2d8a325e"}, + {file = "coverage-7.4.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:109f5985182b6b81fe33323ab4707011875198c41964f014579cf82cebf2bb85"}, + {file = "coverage-7.4.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3cc9d4bc55de8003663ec94c2f215d12d42ceea128da8f0f4036235a119c88ac"}, + {file = "coverage-7.4.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cc6d65b21c219ec2072c1293c505cf36e4e913a3f936d80028993dd73c7906b1"}, + {file = "coverage-7.4.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5a10a4920def78bbfff4eff8a05c51be03e42f1c3735be42d851f199144897ba"}, + {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b8e99f06160602bc64da35158bb76c73522a4010f0649be44a4e167ff8555952"}, + {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:7d360587e64d006402b7116623cebf9d48893329ef035278969fa3bbf75b697e"}, + {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:29f3abe810930311c0b5d1a7140f6395369c3db1be68345638c33eec07535105"}, + {file = "coverage-7.4.0-cp38-cp38-win32.whl", hash = "sha256:5040148f4ec43644702e7b16ca864c5314ccb8ee0751ef617d49aa0e2d6bf4f2"}, + {file = "coverage-7.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:9864463c1c2f9cb3b5db2cf1ff475eed2f0b4285c2aaf4d357b69959941aa555"}, + {file = "coverage-7.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:936d38794044b26c99d3dd004d8af0035ac535b92090f7f2bb5aa9c8e2f5cd42"}, + {file = "coverage-7.4.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:799c8f873794a08cdf216aa5d0531c6a3747793b70c53f70e98259720a6fe2d7"}, + {file = "coverage-7.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e7defbb9737274023e2d7af02cac77043c86ce88a907c58f42b580a97d5bcca9"}, + {file = "coverage-7.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a1526d265743fb49363974b7aa8d5899ff64ee07df47dd8d3e37dcc0818f09ed"}, + {file = "coverage-7.4.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bf635a52fc1ea401baf88843ae8708591aa4adff875e5c23220de43b1ccf575c"}, + {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:756ded44f47f330666843b5781be126ab57bb57c22adbb07d83f6b519783b870"}, + {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:0eb3c2f32dabe3a4aaf6441dde94f35687224dfd7eb2a7f47f3fd9428e421058"}, + {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:bfd5db349d15c08311702611f3dccbef4b4e2ec148fcc636cf8739519b4a5c0f"}, + {file = "coverage-7.4.0-cp39-cp39-win32.whl", hash = "sha256:53d7d9158ee03956e0eadac38dfa1ec8068431ef8058fe6447043db1fb40d932"}, + {file = "coverage-7.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:cfd2a8b6b0d8e66e944d47cdec2f47c48fef2ba2f2dff5a9a75757f64172857e"}, + {file = "coverage-7.4.0-pp38.pp39.pp310-none-any.whl", hash = "sha256:c530833afc4707fe48524a44844493f36d8727f04dcce91fb978c414a8556cc6"}, + {file = "coverage-7.4.0.tar.gz", hash = "sha256:707c0f58cb1712b8809ece32b68996ee1e609f71bd14615bd8f87a1293cb610e"}, +] [package.dependencies] tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} @@ -96,9 +327,12 @@ toml = ["tomli"] name = "cycler" version = "0.12.1" description = "Composable style cycles" -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "cycler-0.12.1-py3-none-any.whl", hash = "sha256:85cef7cff222d8644161529808465972e51340599459b8ac3ccbac5a854e0d30"}, + {file = "cycler-0.12.1.tar.gz", hash = "sha256:88bb128f02ba341da8ef447245a9e138fae777f6a23943da4540077d3601eb1c"}, +] [package.extras] docs = ["ipython", "matplotlib", "numpydoc", "sphinx"] @@ -108,9 +342,12 @@ tests = ["pytest", "pytest-cov", "pytest-xdist"] name = "filelock" version = "3.13.1" description = "A platform independent file lock." -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, + {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, +] [package.extras] docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] @@ -119,16 +356,59 @@ typing = ["typing-extensions (>=4.8)"] [[package]] name = "fonttools" -version = "4.46.0" +version = "4.47.2" description = "Tools to manipulate font files" -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "fonttools-4.47.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3b629108351d25512d4ea1a8393a2dba325b7b7d7308116b605ea3f8e1be88df"}, + {file = "fonttools-4.47.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c19044256c44fe299d9a73456aabee4b4d06c6b930287be93b533b4737d70aa1"}, + {file = "fonttools-4.47.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b8be28c036b9f186e8c7eaf8a11b42373e7e4949f9e9f370202b9da4c4c3f56c"}, + {file = "fonttools-4.47.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f83a4daef6d2a202acb9bf572958f91cfde5b10c8ee7fb1d09a4c81e5d851fd8"}, + {file = "fonttools-4.47.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4a5a5318ba5365d992666ac4fe35365f93004109d18858a3e18ae46f67907670"}, + {file = "fonttools-4.47.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8f57ecd742545362a0f7186774b2d1c53423ed9ece67689c93a1055b236f638c"}, + {file = "fonttools-4.47.2-cp310-cp310-win32.whl", hash = "sha256:a1c154bb85dc9a4cf145250c88d112d88eb414bad81d4cb524d06258dea1bdc0"}, + {file = "fonttools-4.47.2-cp310-cp310-win_amd64.whl", hash = "sha256:3e2b95dce2ead58fb12524d0ca7d63a63459dd489e7e5838c3cd53557f8933e1"}, + {file = "fonttools-4.47.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:29495d6d109cdbabe73cfb6f419ce67080c3ef9ea1e08d5750240fd4b0c4763b"}, + {file = "fonttools-4.47.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0a1d313a415eaaba2b35d6cd33536560deeebd2ed758b9bfb89ab5d97dc5deac"}, + {file = "fonttools-4.47.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:90f898cdd67f52f18049250a6474185ef6544c91f27a7bee70d87d77a8daf89c"}, + {file = "fonttools-4.47.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3480eeb52770ff75140fe7d9a2ec33fb67b07efea0ab5129c7e0c6a639c40c70"}, + {file = "fonttools-4.47.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0255dbc128fee75fb9be364806b940ed450dd6838672a150d501ee86523ac61e"}, + {file = "fonttools-4.47.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f791446ff297fd5f1e2247c188de53c1bfb9dd7f0549eba55b73a3c2087a2703"}, + {file = "fonttools-4.47.2-cp311-cp311-win32.whl", hash = "sha256:740947906590a878a4bde7dd748e85fefa4d470a268b964748403b3ab2aeed6c"}, + {file = "fonttools-4.47.2-cp311-cp311-win_amd64.whl", hash = "sha256:63fbed184979f09a65aa9c88b395ca539c94287ba3a364517698462e13e457c9"}, + {file = "fonttools-4.47.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:4ec558c543609e71b2275c4894e93493f65d2f41c15fe1d089080c1d0bb4d635"}, + {file = "fonttools-4.47.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:e040f905d542362e07e72e03612a6270c33d38281fd573160e1003e43718d68d"}, + {file = "fonttools-4.47.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6dd58cc03016b281bd2c74c84cdaa6bd3ce54c5a7f47478b7657b930ac3ed8eb"}, + {file = "fonttools-4.47.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:32ab2e9702dff0dd4510c7bb958f265a8d3dd5c0e2547e7b5f7a3df4979abb07"}, + {file = "fonttools-4.47.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3a808f3c1d1df1f5bf39be869b6e0c263570cdafb5bdb2df66087733f566ea71"}, + {file = "fonttools-4.47.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ac71e2e201df041a2891067dc36256755b1229ae167edbdc419b16da78732c2f"}, + {file = "fonttools-4.47.2-cp312-cp312-win32.whl", hash = "sha256:69731e8bea0578b3c28fdb43dbf95b9386e2d49a399e9a4ad736b8e479b08085"}, + {file = "fonttools-4.47.2-cp312-cp312-win_amd64.whl", hash = "sha256:b3e1304e5f19ca861d86a72218ecce68f391646d85c851742d265787f55457a4"}, + {file = "fonttools-4.47.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:254d9a6f7be00212bf0c3159e0a420eb19c63793b2c05e049eb337f3023c5ecc"}, + {file = "fonttools-4.47.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:eabae77a07c41ae0b35184894202305c3ad211a93b2eb53837c2a1143c8bc952"}, + {file = "fonttools-4.47.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a86a5ab2873ed2575d0fcdf1828143cfc6b977ac448e3dc616bb1e3d20efbafa"}, + {file = "fonttools-4.47.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13819db8445a0cec8c3ff5f243af6418ab19175072a9a92f6cc8ca7d1452754b"}, + {file = "fonttools-4.47.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:4e743935139aa485fe3253fc33fe467eab6ea42583fa681223ea3f1a93dd01e6"}, + {file = "fonttools-4.47.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d49ce3ea7b7173faebc5664872243b40cf88814ca3eb135c4a3cdff66af71946"}, + {file = "fonttools-4.47.2-cp38-cp38-win32.whl", hash = "sha256:94208ea750e3f96e267f394d5588579bb64cc628e321dbb1d4243ffbc291b18b"}, + {file = "fonttools-4.47.2-cp38-cp38-win_amd64.whl", hash = "sha256:0f750037e02beb8b3569fbff701a572e62a685d2a0e840d75816592280e5feae"}, + {file = "fonttools-4.47.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:3d71606c9321f6701642bd4746f99b6089e53d7e9817fc6b964e90d9c5f0ecc6"}, + {file = "fonttools-4.47.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:86e0427864c6c91cf77f16d1fb9bf1bbf7453e824589e8fb8461b6ee1144f506"}, + {file = "fonttools-4.47.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a00bd0e68e88987dcc047ea31c26d40a3c61185153b03457956a87e39d43c37"}, + {file = "fonttools-4.47.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a5d77479fb885ef38a16a253a2f4096bc3d14e63a56d6246bfdb56365a12b20c"}, + {file = "fonttools-4.47.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5465df494f20a7d01712b072ae3ee9ad2887004701b95cb2cc6dcb9c2c97a899"}, + {file = "fonttools-4.47.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4c811d3c73b6abac275babb8aa439206288f56fdb2c6f8835e3d7b70de8937a7"}, + {file = "fonttools-4.47.2-cp39-cp39-win32.whl", hash = "sha256:5b60e3afa9635e3dfd3ace2757039593e3bd3cf128be0ddb7a1ff4ac45fa5a50"}, + {file = "fonttools-4.47.2-cp39-cp39-win_amd64.whl", hash = "sha256:7ee48bd9d6b7e8f66866c9090807e3a4a56cf43ffad48962725a190e0dd774c8"}, + {file = "fonttools-4.47.2-py3-none-any.whl", hash = "sha256:7eb7ad665258fba68fd22228a09f347469d95a97fb88198e133595947a20a184"}, + {file = "fonttools-4.47.2.tar.gz", hash = "sha256:7df26dd3650e98ca45f1e29883c96a0b9f5bb6af8d632a6a108bc744fa0bd9b3"}, +] [package.extras] -all = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "fs (>=2.2.0,<3)", "lxml (>=4.0,<5)", "lz4 (>=1.7.4.2)", "matplotlib", "munkres", "scipy", "skia-pathops (>=0.5.0)", "sympy", "uharfbuzz (>=0.23.0)", "unicodedata2 (>=15.1.0)", "xattr", "zopfli (>=0.1.4)"] +all = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "fs (>=2.2.0,<3)", "lxml (>=4.0,<5)", "lz4 (>=1.7.4.2)", "matplotlib", "munkres", "pycairo", "scipy", "skia-pathops (>=0.5.0)", "sympy", "uharfbuzz (>=0.23.0)", "unicodedata2 (>=15.1.0)", "xattr", "zopfli (>=0.1.4)"] graphite = ["lz4 (>=1.7.4.2)"] -interpolatable = ["munkres", "scipy"] +interpolatable = ["munkres", "pycairo", "scipy"] lxml = ["lxml (>=4.0,<5)"] pathops = ["skia-pathops (>=0.5.0)"] plot = ["matplotlib"] @@ -141,11 +421,14 @@ woff = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "zopfli (>=0.1.4)"] [[package]] name = "gdown" -version = "4.7.1" +version = "4.7.3" description = "Google Drive direct download of big files." -category = "main" optional = false python-versions = "*" +files = [ + {file = "gdown-4.7.3-py3-none-any.whl", hash = "sha256:aeb7b979b35efd007d0c12fee17350f007aeb5fa84a9def09381d765075ba9ce"}, + {file = "gdown-4.7.3.tar.gz", hash = "sha256:37edc3a0edda1a7fe5ebcc631c3aad0612582766460630ee52f481ba1ec7aefe"}, +] [package.dependencies] beautifulsoup4 = "*" @@ -155,67 +438,334 @@ six = "*" tqdm = "*" [[package]] -name = "idna" -version = "3.6" -description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" +name = "google-auth" +version = "2.26.2" +description = "Google Authentication Library" optional = false -python-versions = ">=3.5" +python-versions = ">=3.7" +files = [ + {file = "google-auth-2.26.2.tar.gz", hash = "sha256:97327dbbf58cccb58fc5a1712bba403ae76668e64814eb30f7316f7e27126b81"}, + {file = "google_auth-2.26.2-py2.py3-none-any.whl", hash = "sha256:3f445c8ce9b61ed6459aad86d8ccdba4a9afed841b2d1451a11ef4db08957424"}, +] + +[package.dependencies] +cachetools = ">=2.0.0,<6.0" +pyasn1-modules = ">=0.2.1" +rsa = ">=3.1.4,<5" + +[package.extras] +aiohttp = ["aiohttp (>=3.6.2,<4.0.0.dev0)", "requests (>=2.20.0,<3.0.0.dev0)"] +enterprise-cert = ["cryptography (==36.0.2)", "pyopenssl (==22.0.0)"] +pyopenssl = ["cryptography (>=38.0.3)", "pyopenssl (>=20.0.0)"] +reauth = ["pyu2f (>=0.1.5)"] +requests = ["requests (>=2.20.0,<3.0.0.dev0)"] [[package]] -name = "importlib-resources" -version = "6.1.1" -description = "Read resources from Python packages" -category = "main" +name = "google-auth-oauthlib" +version = "1.2.0" +description = "Google Authentication Library" optional = false -python-versions = ">=3.8" +python-versions = ">=3.6" +files = [ + {file = "google-auth-oauthlib-1.2.0.tar.gz", hash = "sha256:292d2d3783349f2b0734a0a0207b1e1e322ac193c2c09d8f7c613fb7cc501ea8"}, + {file = "google_auth_oauthlib-1.2.0-py2.py3-none-any.whl", hash = "sha256:297c1ce4cb13a99b5834c74a1fe03252e1e499716718b190f56bcb9c4abc4faf"}, +] [package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} +google-auth = ">=2.15.0" +requests-oauthlib = ">=0.7.0" [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-ruff", "zipp (>=3.17)"] +tool = ["click (>=6.0.0)"] [[package]] -name = "iniconfig" -version = "2.0.0" -description = "brain-dead simple config-ini parsing" -category = "dev" +name = "grpcio" +version = "1.60.0" +description = "HTTP/2-based RPC framework" optional = false python-versions = ">=3.7" +files = [ + {file = "grpcio-1.60.0-cp310-cp310-linux_armv7l.whl", hash = "sha256:d020cfa595d1f8f5c6b343530cd3ca16ae5aefdd1e832b777f9f0eb105f5b139"}, + {file = "grpcio-1.60.0-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:b98f43fcdb16172dec5f4b49f2fece4b16a99fd284d81c6bbac1b3b69fcbe0ff"}, + {file = "grpcio-1.60.0-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:20e7a4f7ded59097c84059d28230907cd97130fa74f4a8bfd1d8e5ba18c81491"}, + {file = "grpcio-1.60.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:452ca5b4afed30e7274445dd9b441a35ece656ec1600b77fff8c216fdf07df43"}, + {file = "grpcio-1.60.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43e636dc2ce9ece583b3e2ca41df5c983f4302eabc6d5f9cd04f0562ee8ec1ae"}, + {file = "grpcio-1.60.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:6e306b97966369b889985a562ede9d99180def39ad42c8014628dd3cc343f508"}, + {file = "grpcio-1.60.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:f897c3b127532e6befdcf961c415c97f320d45614daf84deba0a54e64ea2457b"}, + {file = "grpcio-1.60.0-cp310-cp310-win32.whl", hash = "sha256:b87efe4a380887425bb15f220079aa8336276398dc33fce38c64d278164f963d"}, + {file = "grpcio-1.60.0-cp310-cp310-win_amd64.whl", hash = "sha256:a9c7b71211f066908e518a2ef7a5e211670761651039f0d6a80d8d40054047df"}, + {file = "grpcio-1.60.0-cp311-cp311-linux_armv7l.whl", hash = "sha256:fb464479934778d7cc5baf463d959d361954d6533ad34c3a4f1d267e86ee25fd"}, + {file = "grpcio-1.60.0-cp311-cp311-macosx_10_10_universal2.whl", hash = "sha256:4b44d7e39964e808b071714666a812049765b26b3ea48c4434a3b317bac82f14"}, + {file = "grpcio-1.60.0-cp311-cp311-manylinux_2_17_aarch64.whl", hash = "sha256:90bdd76b3f04bdb21de5398b8a7c629676c81dfac290f5f19883857e9371d28c"}, + {file = "grpcio-1.60.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:91229d7203f1ef0ab420c9b53fe2ca5c1fbeb34f69b3bc1b5089466237a4a134"}, + {file = "grpcio-1.60.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b36a2c6d4920ba88fa98075fdd58ff94ebeb8acc1215ae07d01a418af4c0253"}, + {file = "grpcio-1.60.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:297eef542156d6b15174a1231c2493ea9ea54af8d016b8ca7d5d9cc65cfcc444"}, + {file = "grpcio-1.60.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:87c9224acba0ad8bacddf427a1c2772e17ce50b3042a789547af27099c5f751d"}, + {file = "grpcio-1.60.0-cp311-cp311-win32.whl", hash = "sha256:95ae3e8e2c1b9bf671817f86f155c5da7d49a2289c5cf27a319458c3e025c320"}, + {file = "grpcio-1.60.0-cp311-cp311-win_amd64.whl", hash = "sha256:467a7d31554892eed2aa6c2d47ded1079fc40ea0b9601d9f79204afa8902274b"}, + {file = "grpcio-1.60.0-cp312-cp312-linux_armv7l.whl", hash = "sha256:a7152fa6e597c20cb97923407cf0934e14224af42c2b8d915f48bc3ad2d9ac18"}, + {file = "grpcio-1.60.0-cp312-cp312-macosx_10_10_universal2.whl", hash = "sha256:7db16dd4ea1b05ada504f08d0dca1cd9b926bed3770f50e715d087c6f00ad748"}, + {file = "grpcio-1.60.0-cp312-cp312-manylinux_2_17_aarch64.whl", hash = "sha256:b0571a5aef36ba9177e262dc88a9240c866d903a62799e44fd4aae3f9a2ec17e"}, + {file = "grpcio-1.60.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6fd9584bf1bccdfff1512719316efa77be235469e1e3295dce64538c4773840b"}, + {file = "grpcio-1.60.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d6a478581b1a1a8fdf3318ecb5f4d0cda41cacdffe2b527c23707c9c1b8fdb55"}, + {file = "grpcio-1.60.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:77c8a317f0fd5a0a2be8ed5cbe5341537d5c00bb79b3bb27ba7c5378ba77dbca"}, + {file = "grpcio-1.60.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:1c30bb23a41df95109db130a6cc1b974844300ae2e5d68dd4947aacba5985aa5"}, + {file = "grpcio-1.60.0-cp312-cp312-win32.whl", hash = "sha256:2aef56e85901c2397bd557c5ba514f84de1f0ae5dd132f5d5fed042858115951"}, + {file = "grpcio-1.60.0-cp312-cp312-win_amd64.whl", hash = "sha256:e381fe0c2aa6c03b056ad8f52f8efca7be29fb4d9ae2f8873520843b6039612a"}, + {file = "grpcio-1.60.0-cp37-cp37m-linux_armv7l.whl", hash = "sha256:92f88ca1b956eb8427a11bb8b4a0c0b2b03377235fc5102cb05e533b8693a415"}, + {file = "grpcio-1.60.0-cp37-cp37m-macosx_10_10_universal2.whl", hash = "sha256:e278eafb406f7e1b1b637c2cf51d3ad45883bb5bd1ca56bc05e4fc135dfdaa65"}, + {file = "grpcio-1.60.0-cp37-cp37m-manylinux_2_17_aarch64.whl", hash = "sha256:a48edde788b99214613e440fce495bbe2b1e142a7f214cce9e0832146c41e324"}, + {file = "grpcio-1.60.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:de2ad69c9a094bf37c1102b5744c9aec6cf74d2b635558b779085d0263166454"}, + {file = "grpcio-1.60.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:073f959c6f570797272f4ee9464a9997eaf1e98c27cb680225b82b53390d61e6"}, + {file = "grpcio-1.60.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:c826f93050c73e7769806f92e601e0efdb83ec8d7c76ddf45d514fee54e8e619"}, + {file = "grpcio-1.60.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:9e30be89a75ee66aec7f9e60086fadb37ff8c0ba49a022887c28c134341f7179"}, + {file = "grpcio-1.60.0-cp37-cp37m-win_amd64.whl", hash = "sha256:b0fb2d4801546598ac5cd18e3ec79c1a9af8b8f2a86283c55a5337c5aeca4b1b"}, + {file = "grpcio-1.60.0-cp38-cp38-linux_armv7l.whl", hash = "sha256:9073513ec380434eb8d21970e1ab3161041de121f4018bbed3146839451a6d8e"}, + {file = "grpcio-1.60.0-cp38-cp38-macosx_10_10_universal2.whl", hash = "sha256:74d7d9fa97809c5b892449b28a65ec2bfa458a4735ddad46074f9f7d9550ad13"}, + {file = "grpcio-1.60.0-cp38-cp38-manylinux_2_17_aarch64.whl", hash = "sha256:1434ca77d6fed4ea312901122dc8da6c4389738bf5788f43efb19a838ac03ead"}, + {file = "grpcio-1.60.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e61e76020e0c332a98290323ecfec721c9544f5b739fab925b6e8cbe1944cf19"}, + {file = "grpcio-1.60.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:675997222f2e2f22928fbba640824aebd43791116034f62006e19730715166c0"}, + {file = "grpcio-1.60.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:5208a57eae445ae84a219dfd8b56e04313445d146873117b5fa75f3245bc1390"}, + {file = "grpcio-1.60.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:428d699c8553c27e98f4d29fdc0f0edc50e9a8a7590bfd294d2edb0da7be3629"}, + {file = "grpcio-1.60.0-cp38-cp38-win32.whl", hash = "sha256:83f2292ae292ed5a47cdcb9821039ca8e88902923198f2193f13959360c01860"}, + {file = "grpcio-1.60.0-cp38-cp38-win_amd64.whl", hash = "sha256:705a68a973c4c76db5d369ed573fec3367d7d196673fa86614b33d8c8e9ebb08"}, + {file = "grpcio-1.60.0-cp39-cp39-linux_armv7l.whl", hash = "sha256:c193109ca4070cdcaa6eff00fdb5a56233dc7610216d58fb81638f89f02e4968"}, + {file = "grpcio-1.60.0-cp39-cp39-macosx_10_10_universal2.whl", hash = "sha256:676e4a44e740deaba0f4d95ba1d8c5c89a2fcc43d02c39f69450b1fa19d39590"}, + {file = "grpcio-1.60.0-cp39-cp39-manylinux_2_17_aarch64.whl", hash = "sha256:5ff21e000ff2f658430bde5288cb1ac440ff15c0d7d18b5fb222f941b46cb0d2"}, + {file = "grpcio-1.60.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c86343cf9ff7b2514dd229bdd88ebba760bd8973dac192ae687ff75e39ebfab"}, + {file = "grpcio-1.60.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fd3b3968ffe7643144580f260f04d39d869fcc2cddb745deef078b09fd2b328"}, + {file = "grpcio-1.60.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:30943b9530fe3620e3b195c03130396cd0ee3a0d10a66c1bee715d1819001eaf"}, + {file = "grpcio-1.60.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:b10241250cb77657ab315270b064a6c7f1add58af94befa20687e7c8d8603ae6"}, + {file = "grpcio-1.60.0-cp39-cp39-win32.whl", hash = "sha256:79a050889eb8d57a93ed21d9585bb63fca881666fc709f5d9f7f9372f5e7fd03"}, + {file = "grpcio-1.60.0-cp39-cp39-win_amd64.whl", hash = "sha256:8a97a681e82bc11a42d4372fe57898d270a2707f36c45c6676e49ce0d5c41353"}, + {file = "grpcio-1.60.0.tar.gz", hash = "sha256:2199165a1affb666aa24adf0c97436686d0a61bc5fc113c037701fb7c7fceb96"}, +] + +[package.extras] +protobuf = ["grpcio-tools (>=1.60.0)"] [[package]] -name = "itermate" -version = "1.0.2" -description = "Iterator-tools for functional programming." -category = "dev" +name = "idna" +version = "3.6" +description = "Internationalized Domain Names in Applications (IDNA)" optional = false -python-versions = "*" +python-versions = ">=3.5" +files = [ + {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, + {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, +] + +[[package]] +name = "importlib-metadata" +version = "7.0.1" +description = "Read metadata from Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "importlib_metadata-7.0.1-py3-none-any.whl", hash = "sha256:4805911c3a4ec7c3966410053e9ec6a1fecd629117df5adee56dfc9432a1081e"}, + {file = "importlib_metadata-7.0.1.tar.gz", hash = "sha256:f238736bb06590ae52ac1fab06a3a9ef1d8dce2b7a35b5ab329371d6c8f5d2cc"}, +] + +[package.dependencies] +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] + +[[package]] +name = "importlib-resources" +version = "6.1.1" +description = "Read resources from Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "importlib_resources-6.1.1-py3-none-any.whl", hash = "sha256:e8bf90d8213b486f428c9c39714b920041cb02c184686a3dee24905aaa8105d6"}, + {file = "importlib_resources-6.1.1.tar.gz", hash = "sha256:3893a00122eafde6894c59914446a512f728a0c1a45f9bb9b63721b6bacf0b4a"}, +] + +[package.dependencies] +zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-ruff", "zipp (>=3.17)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "itermate" +version = "1.0.2" +description = "Iterator-tools for functional programming." +optional = false +python-versions = "*" +files = [ + {file = "itermate-1.0.2-py2-none-any.whl", hash = "sha256:00308991e0fe54465e0e0fbec4d47180b4f6df0f26c1e5d2ce3641e3373f28a0"}, + {file = "itermate-1.0.2.zip", hash = "sha256:5ee758cbb363493156cee7a29effc2b148a1a19d2be3097e92fc824991901e2a"}, +] [[package]] name = "joblib" version = "1.3.2" description = "Lightweight pipelining with Python functions" -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "joblib-1.3.2-py3-none-any.whl", hash = "sha256:ef4331c65f239985f3f2220ecc87db222f08fd22097a3dd5698f693875f8cbb9"}, + {file = "joblib-1.3.2.tar.gz", hash = "sha256:92f865e621e17784e7955080b6d042489e3b8e294949cc44c6eac304f59772b1"}, +] [[package]] name = "kiwisolver" version = "1.4.5" description = "A fast implementation of the Cassowary constraint solver" -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "kiwisolver-1.4.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:05703cf211d585109fcd72207a31bb170a0f22144d68298dc5e61b3c946518af"}, + {file = "kiwisolver-1.4.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:146d14bebb7f1dc4d5fbf74f8a6cb15ac42baadee8912eb84ac0b3b2a3dc6ac3"}, + {file = "kiwisolver-1.4.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6ef7afcd2d281494c0a9101d5c571970708ad911d028137cd558f02b851c08b4"}, + {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:9eaa8b117dc8337728e834b9c6e2611f10c79e38f65157c4c38e9400286f5cb1"}, + {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ec20916e7b4cbfb1f12380e46486ec4bcbaa91a9c448b97023fde0d5bbf9e4ff"}, + {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:39b42c68602539407884cf70d6a480a469b93b81b7701378ba5e2328660c847a"}, + {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aa12042de0171fad672b6c59df69106d20d5596e4f87b5e8f76df757a7c399aa"}, + {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2a40773c71d7ccdd3798f6489aaac9eee213d566850a9533f8d26332d626b82c"}, + {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:19df6e621f6d8b4b9c4d45f40a66839294ff2bb235e64d2178f7522d9170ac5b"}, + {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:83d78376d0d4fd884e2c114d0621624b73d2aba4e2788182d286309ebdeed770"}, + {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:e391b1f0a8a5a10ab3b9bb6afcfd74f2175f24f8975fb87ecae700d1503cdee0"}, + {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:852542f9481f4a62dbb5dd99e8ab7aedfeb8fb6342349a181d4036877410f525"}, + {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:59edc41b24031bc25108e210c0def6f6c2191210492a972d585a06ff246bb79b"}, + {file = "kiwisolver-1.4.5-cp310-cp310-win32.whl", hash = "sha256:a6aa6315319a052b4ee378aa171959c898a6183f15c1e541821c5c59beaa0238"}, + {file = "kiwisolver-1.4.5-cp310-cp310-win_amd64.whl", hash = "sha256:d0ef46024e6a3d79c01ff13801cb19d0cad7fd859b15037aec74315540acc276"}, + {file = "kiwisolver-1.4.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:11863aa14a51fd6ec28688d76f1735f8f69ab1fabf388851a595d0721af042f5"}, + {file = "kiwisolver-1.4.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8ab3919a9997ab7ef2fbbed0cc99bb28d3c13e6d4b1ad36e97e482558a91be90"}, + {file = "kiwisolver-1.4.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:fcc700eadbbccbf6bc1bcb9dbe0786b4b1cb91ca0dcda336eef5c2beed37b797"}, + {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dfdd7c0b105af050eb3d64997809dc21da247cf44e63dc73ff0fd20b96be55a9"}, + {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:76c6a5964640638cdeaa0c359382e5703e9293030fe730018ca06bc2010c4437"}, + {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bbea0db94288e29afcc4c28afbf3a7ccaf2d7e027489c449cf7e8f83c6346eb9"}, + {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ceec1a6bc6cab1d6ff5d06592a91a692f90ec7505d6463a88a52cc0eb58545da"}, + {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:040c1aebeda72197ef477a906782b5ab0d387642e93bda547336b8957c61022e"}, + {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:f91de7223d4c7b793867797bacd1ee53bfe7359bd70d27b7b58a04efbb9436c8"}, + {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:faae4860798c31530dd184046a900e652c95513796ef51a12bc086710c2eec4d"}, + {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:b0157420efcb803e71d1b28e2c287518b8808b7cf1ab8af36718fd0a2c453eb0"}, + {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:06f54715b7737c2fecdbf140d1afb11a33d59508a47bf11bb38ecf21dc9ab79f"}, + {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:fdb7adb641a0d13bdcd4ef48e062363d8a9ad4a182ac7647ec88f695e719ae9f"}, + {file = "kiwisolver-1.4.5-cp311-cp311-win32.whl", hash = "sha256:bb86433b1cfe686da83ce32a9d3a8dd308e85c76b60896d58f082136f10bffac"}, + {file = "kiwisolver-1.4.5-cp311-cp311-win_amd64.whl", hash = "sha256:6c08e1312a9cf1074d17b17728d3dfce2a5125b2d791527f33ffbe805200a355"}, + {file = "kiwisolver-1.4.5-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:32d5cf40c4f7c7b3ca500f8985eb3fb3a7dfc023215e876f207956b5ea26632a"}, + {file = "kiwisolver-1.4.5-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f846c260f483d1fd217fe5ed7c173fb109efa6b1fc8381c8b7552c5781756192"}, + {file = "kiwisolver-1.4.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5ff5cf3571589b6d13bfbfd6bcd7a3f659e42f96b5fd1c4830c4cf21d4f5ef45"}, + {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7269d9e5f1084a653d575c7ec012ff57f0c042258bf5db0954bf551c158466e7"}, + {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:da802a19d6e15dffe4b0c24b38b3af68e6c1a68e6e1d8f30148c83864f3881db"}, + {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3aba7311af82e335dd1e36ffff68aaca609ca6290c2cb6d821a39aa075d8e3ff"}, + {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:763773d53f07244148ccac5b084da5adb90bfaee39c197554f01b286cf869228"}, + {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2270953c0d8cdab5d422bee7d2007f043473f9d2999631c86a223c9db56cbd16"}, + {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d099e745a512f7e3bbe7249ca835f4d357c586d78d79ae8f1dcd4d8adeb9bda9"}, + {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:74db36e14a7d1ce0986fa104f7d5637aea5c82ca6326ed0ec5694280942d1162"}, + {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:7e5bab140c309cb3a6ce373a9e71eb7e4873c70c2dda01df6820474f9889d6d4"}, + {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:0f114aa76dc1b8f636d077979c0ac22e7cd8f3493abbab152f20eb8d3cda71f3"}, + {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:88a2df29d4724b9237fc0c6eaf2a1adae0cdc0b3e9f4d8e7dc54b16812d2d81a"}, + {file = "kiwisolver-1.4.5-cp312-cp312-win32.whl", hash = "sha256:72d40b33e834371fd330fb1472ca19d9b8327acb79a5821d4008391db8e29f20"}, + {file = "kiwisolver-1.4.5-cp312-cp312-win_amd64.whl", hash = "sha256:2c5674c4e74d939b9d91dda0fae10597ac7521768fec9e399c70a1f27e2ea2d9"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:3a2b053a0ab7a3960c98725cfb0bf5b48ba82f64ec95fe06f1d06c99b552e130"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3cd32d6c13807e5c66a7cbb79f90b553642f296ae4518a60d8d76243b0ad2898"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:59ec7b7c7e1a61061850d53aaf8e93db63dce0c936db1fda2658b70e4a1be709"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:da4cfb373035def307905d05041c1d06d8936452fe89d464743ae7fb8371078b"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2400873bccc260b6ae184b2b8a4fec0e4082d30648eadb7c3d9a13405d861e89"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:1b04139c4236a0f3aff534479b58f6f849a8b351e1314826c2d230849ed48985"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:4e66e81a5779b65ac21764c295087de82235597a2293d18d943f8e9e32746265"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:7931d8f1f67c4be9ba1dd9c451fb0eeca1a25b89e4d3f89e828fe12a519b782a"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:b3f7e75f3015df442238cca659f8baa5f42ce2a8582727981cbfa15fee0ee205"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:bbf1d63eef84b2e8c89011b7f2235b1e0bf7dacc11cac9431fc6468e99ac77fb"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:4c380469bd3f970ef677bf2bcba2b6b0b4d5c75e7a020fb863ef75084efad66f"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-win32.whl", hash = "sha256:9408acf3270c4b6baad483865191e3e582b638b1654a007c62e3efe96f09a9a3"}, + {file = "kiwisolver-1.4.5-cp37-cp37m-win_amd64.whl", hash = "sha256:5b94529f9b2591b7af5f3e0e730a4e0a41ea174af35a4fd067775f9bdfeee01a"}, + {file = "kiwisolver-1.4.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:11c7de8f692fc99816e8ac50d1d1aef4f75126eefc33ac79aac02c099fd3db71"}, + {file = "kiwisolver-1.4.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:53abb58632235cd154176ced1ae8f0d29a6657aa1aa9decf50b899b755bc2b93"}, + {file = "kiwisolver-1.4.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:88b9f257ca61b838b6f8094a62418421f87ac2a1069f7e896c36a7d86b5d4c29"}, + {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3195782b26fc03aa9c6913d5bad5aeb864bdc372924c093b0f1cebad603dd712"}, + {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fc579bf0f502e54926519451b920e875f433aceb4624a3646b3252b5caa9e0b6"}, + {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5a580c91d686376f0f7c295357595c5a026e6cbc3d77b7c36e290201e7c11ecb"}, + {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:cfe6ab8da05c01ba6fbea630377b5da2cd9bcbc6338510116b01c1bc939a2c18"}, + {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:d2e5a98f0ec99beb3c10e13b387f8db39106d53993f498b295f0c914328b1333"}, + {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:a51a263952b1429e429ff236d2f5a21c5125437861baeed77f5e1cc2d2c7c6da"}, + {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:3edd2fa14e68c9be82c5b16689e8d63d89fe927e56debd6e1dbce7a26a17f81b"}, + {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:74d1b44c6cfc897df648cc9fdaa09bc3e7679926e6f96df05775d4fb3946571c"}, + {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:76d9289ed3f7501012e05abb8358bbb129149dbd173f1f57a1bf1c22d19ab7cc"}, + {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:92dea1ffe3714fa8eb6a314d2b3c773208d865a0e0d35e713ec54eea08a66250"}, + {file = "kiwisolver-1.4.5-cp38-cp38-win32.whl", hash = "sha256:5c90ae8c8d32e472be041e76f9d2f2dbff4d0b0be8bd4041770eddb18cf49a4e"}, + {file = "kiwisolver-1.4.5-cp38-cp38-win_amd64.whl", hash = "sha256:c7940c1dc63eb37a67721b10d703247552416f719c4188c54e04334321351ced"}, + {file = "kiwisolver-1.4.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:9407b6a5f0d675e8a827ad8742e1d6b49d9c1a1da5d952a67d50ef5f4170b18d"}, + {file = "kiwisolver-1.4.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:15568384086b6df3c65353820a4473575dbad192e35010f622c6ce3eebd57af9"}, + {file = "kiwisolver-1.4.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0dc9db8e79f0036e8173c466d21ef18e1befc02de8bf8aa8dc0813a6dc8a7046"}, + {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:cdc8a402aaee9a798b50d8b827d7ecf75edc5fb35ea0f91f213ff927c15f4ff0"}, + {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6c3bd3cde54cafb87d74d8db50b909705c62b17c2099b8f2e25b461882e544ff"}, + {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:955e8513d07a283056b1396e9a57ceddbd272d9252c14f154d450d227606eb54"}, + {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:346f5343b9e3f00b8db8ba359350eb124b98c99efd0b408728ac6ebf38173958"}, + {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b9098e0049e88c6a24ff64545cdfc50807818ba6c1b739cae221bbbcbc58aad3"}, + {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:00bd361b903dc4bbf4eb165f24d1acbee754fce22ded24c3d56eec268658a5cf"}, + {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:7b8b454bac16428b22560d0a1cf0a09875339cab69df61d7805bf48919415901"}, + {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:f1d072c2eb0ad60d4c183f3fb44ac6f73fb7a8f16a2694a91f988275cbf352f9"}, + {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:31a82d498054cac9f6d0b53d02bb85811185bcb477d4b60144f915f3b3126342"}, + {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6512cb89e334e4700febbffaaa52761b65b4f5a3cf33f960213d5656cea36a77"}, + {file = "kiwisolver-1.4.5-cp39-cp39-win32.whl", hash = "sha256:9db8ea4c388fdb0f780fe91346fd438657ea602d58348753d9fb265ce1bca67f"}, + {file = "kiwisolver-1.4.5-cp39-cp39-win_amd64.whl", hash = "sha256:59415f46a37f7f2efeec758353dd2eae1b07640d8ca0f0c42548ec4125492635"}, + {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:5c7b3b3a728dc6faf3fc372ef24f21d1e3cee2ac3e9596691d746e5a536de920"}, + {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:620ced262a86244e2be10a676b646f29c34537d0d9cc8eb26c08f53d98013390"}, + {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:378a214a1e3bbf5ac4a8708304318b4f890da88c9e6a07699c4ae7174c09a68d"}, + {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aaf7be1207676ac608a50cd08f102f6742dbfc70e8d60c4db1c6897f62f71523"}, + {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:ba55dce0a9b8ff59495ddd050a0225d58bd0983d09f87cfe2b6aec4f2c1234e4"}, + {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:fd32ea360bcbb92d28933fc05ed09bffcb1704ba3fc7942e81db0fd4f81a7892"}, + {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5e7139af55d1688f8b960ee9ad5adafc4ac17c1c473fe07133ac092310d76544"}, + {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:dced8146011d2bc2e883f9bd68618b8247387f4bbec46d7392b3c3b032640126"}, + {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c9bf3325c47b11b2e51bca0824ea217c7cd84491d8ac4eefd1e409705ef092bd"}, + {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:5794cf59533bc3f1b1c821f7206a3617999db9fbefc345360aafe2e067514929"}, + {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:e368f200bbc2e4f905b8e71eb38b3c04333bddaa6a2464a6355487b02bb7fb09"}, + {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e5d706eba36b4c4d5bc6c6377bb6568098765e990cfc21ee16d13963fab7b3e7"}, + {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:85267bd1aa8880a9c88a8cb71e18d3d64d2751a790e6ca6c27b8ccc724bcd5ad"}, + {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:210ef2c3a1f03272649aff1ef992df2e724748918c4bc2d5a90352849eb40bea"}, + {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:11d011a7574eb3b82bcc9c1a1d35c1d7075677fdd15de527d91b46bd35e935ee"}, + {file = "kiwisolver-1.4.5.tar.gz", hash = "sha256:e57e563a57fb22a142da34f38acc2fc1a5c864bc29ca1517a88abc963e60d6ec"}, +] + +[[package]] +name = "markdown" +version = "3.5.2" +description = "Python implementation of John Gruber's Markdown." +optional = false +python-versions = ">=3.8" +files = [ + {file = "Markdown-3.5.2-py3-none-any.whl", hash = "sha256:d43323865d89fc0cb9b20c75fc8ad313af307cc087e84b657d9eec768eddeadd"}, + {file = "Markdown-3.5.2.tar.gz", hash = "sha256:e1ac7b3dc550ee80e602e71c1d168002f062e49f1b11e26a36264dafd4df2ef8"}, +] + +[package.dependencies] +importlib-metadata = {version = ">=4.4", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["mdx-gh-links (>=0.2)", "mkdocs (>=1.5)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"] +testing = ["coverage", "pyyaml"] [[package]] name = "markdown-it-py" version = "3.0.0" description = "Python port of markdown-it. Markdown parsing, done right!" -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, + {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, +] [package.dependencies] mdurl = ">=0.1,<1.0" @@ -230,13 +780,111 @@ profiling = ["gprof2dot"] rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] +[[package]] +name = "markupsafe" +version = "2.1.4" +description = "Safely add untrusted strings to HTML/XML markup." +optional = false +python-versions = ">=3.7" +files = [ + {file = "MarkupSafe-2.1.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:de8153a7aae3835484ac168a9a9bdaa0c5eee4e0bc595503c95d53b942879c84"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e888ff76ceb39601c59e219f281466c6d7e66bd375b4ec1ce83bcdc68306796b"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0b838c37ba596fcbfca71651a104a611543077156cb0a26fe0c475e1f152ee8"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dac1ebf6983148b45b5fa48593950f90ed6d1d26300604f321c74a9ca1609f8e"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0fbad3d346df8f9d72622ac71b69565e621ada2ce6572f37c2eae8dacd60385d"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d5291d98cd3ad9a562883468c690a2a238c4a6388ab3bd155b0c75dd55ece858"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:a7cc49ef48a3c7a0005a949f3c04f8baa5409d3f663a1b36f0eba9bfe2a0396e"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b83041cda633871572f0d3c41dddd5582ad7d22f65a72eacd8d3d6d00291df26"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-win32.whl", hash = "sha256:0c26f67b3fe27302d3a412b85ef696792c4a2386293c53ba683a89562f9399b0"}, + {file = "MarkupSafe-2.1.4-cp310-cp310-win_amd64.whl", hash = "sha256:a76055d5cb1c23485d7ddae533229039b850db711c554a12ea64a0fd8a0129e2"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9e9e3c4020aa2dc62d5dd6743a69e399ce3de58320522948af6140ac959ab863"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0042d6a9880b38e1dd9ff83146cc3c9c18a059b9360ceae207805567aacccc69"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:55d03fea4c4e9fd0ad75dc2e7e2b6757b80c152c032ea1d1de487461d8140efc"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ab3a886a237f6e9c9f4f7d272067e712cdb4efa774bef494dccad08f39d8ae6"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:abf5ebbec056817057bfafc0445916bb688a255a5146f900445d081db08cbabb"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e1a0d1924a5013d4f294087e00024ad25668234569289650929ab871231668e7"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:e7902211afd0af05fbadcc9a312e4cf10f27b779cf1323e78d52377ae4b72bea"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:c669391319973e49a7c6230c218a1e3044710bc1ce4c8e6eb71f7e6d43a2c131"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-win32.whl", hash = "sha256:31f57d64c336b8ccb1966d156932f3daa4fee74176b0fdc48ef580be774aae74"}, + {file = "MarkupSafe-2.1.4-cp311-cp311-win_amd64.whl", hash = "sha256:54a7e1380dfece8847c71bf7e33da5d084e9b889c75eca19100ef98027bd9f56"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:a76cd37d229fc385738bd1ce4cba2a121cf26b53864c1772694ad0ad348e509e"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:987d13fe1d23e12a66ca2073b8d2e2a75cec2ecb8eab43ff5624ba0ad42764bc"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5244324676254697fe5c181fc762284e2c5fceeb1c4e3e7f6aca2b6f107e60dc"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78bc995e004681246e85e28e068111a4c3f35f34e6c62da1471e844ee1446250"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a4d176cfdfde84f732c4a53109b293d05883e952bbba68b857ae446fa3119b4f"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:f9917691f410a2e0897d1ef99619fd3f7dd503647c8ff2475bf90c3cf222ad74"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:f06e5a9e99b7df44640767842f414ed5d7bedaaa78cd817ce04bbd6fd86e2dd6"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:396549cea79e8ca4ba65525470d534e8a41070e6b3500ce2414921099cb73e8d"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-win32.whl", hash = "sha256:f6be2d708a9d0e9b0054856f07ac7070fbe1754be40ca8525d5adccdbda8f475"}, + {file = "MarkupSafe-2.1.4-cp312-cp312-win_amd64.whl", hash = "sha256:5045e892cfdaecc5b4c01822f353cf2c8feb88a6ec1c0adef2a2e705eef0f656"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:7a07f40ef8f0fbc5ef1000d0c78771f4d5ca03b4953fc162749772916b298fc4"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d18b66fe626ac412d96c2ab536306c736c66cf2a31c243a45025156cc190dc8a"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:698e84142f3f884114ea8cf83e7a67ca8f4ace8454e78fe960646c6c91c63bfa"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:49a3b78a5af63ec10d8604180380c13dcd870aba7928c1fe04e881d5c792dc4e"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:15866d7f2dc60cfdde12ebb4e75e41be862348b4728300c36cdf405e258415ec"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:6aa5e2e7fc9bc042ae82d8b79d795b9a62bd8f15ba1e7594e3db243f158b5565"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:54635102ba3cf5da26eb6f96c4b8c53af8a9c0d97b64bdcb592596a6255d8518"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-win32.whl", hash = "sha256:3583a3a3ab7958e354dc1d25be74aee6228938312ee875a22330c4dc2e41beb0"}, + {file = "MarkupSafe-2.1.4-cp37-cp37m-win_amd64.whl", hash = "sha256:d6e427c7378c7f1b2bef6a344c925b8b63623d3321c09a237b7cc0e77dd98ceb"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:bf1196dcc239e608605b716e7b166eb5faf4bc192f8a44b81e85251e62584bd2"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4df98d4a9cd6a88d6a585852f56f2155c9cdb6aec78361a19f938810aa020954"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b835aba863195269ea358cecc21b400276747cc977492319fd7682b8cd2c253d"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:23984d1bdae01bee794267424af55eef4dfc038dc5d1272860669b2aa025c9e3"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c98c33ffe20e9a489145d97070a435ea0679fddaabcafe19982fe9c971987d5"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:9896fca4a8eb246defc8b2a7ac77ef7553b638e04fbf170bff78a40fa8a91474"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:b0fe73bac2fed83839dbdbe6da84ae2a31c11cfc1c777a40dbd8ac8a6ed1560f"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:c7556bafeaa0a50e2fe7dc86e0382dea349ebcad8f010d5a7dc6ba568eaaa789"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-win32.whl", hash = "sha256:fc1a75aa8f11b87910ffd98de62b29d6520b6d6e8a3de69a70ca34dea85d2a8a"}, + {file = "MarkupSafe-2.1.4-cp38-cp38-win_amd64.whl", hash = "sha256:3a66c36a3864df95e4f62f9167c734b3b1192cb0851b43d7cc08040c074c6279"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:765f036a3d00395a326df2835d8f86b637dbaf9832f90f5d196c3b8a7a5080cb"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:21e7af8091007bf4bebf4521184f4880a6acab8df0df52ef9e513d8e5db23411"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5c31fe855c77cad679b302aabc42d724ed87c043b1432d457f4976add1c2c3e"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7653fa39578957bc42e5ebc15cf4361d9e0ee4b702d7d5ec96cdac860953c5b4"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:47bb5f0142b8b64ed1399b6b60f700a580335c8e1c57f2f15587bd072012decc"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:fe8512ed897d5daf089e5bd010c3dc03bb1bdae00b35588c49b98268d4a01e00"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:36d7626a8cca4d34216875aee5a1d3d654bb3dac201c1c003d182283e3205949"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:b6f14a9cd50c3cb100eb94b3273131c80d102e19bb20253ac7bd7336118a673a"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-win32.whl", hash = "sha256:c8f253a84dbd2c63c19590fa86a032ef3d8cc18923b8049d91bcdeeb2581fbf6"}, + {file = "MarkupSafe-2.1.4-cp39-cp39-win_amd64.whl", hash = "sha256:8b570a1537367b52396e53325769608f2a687ec9a4363647af1cded8928af959"}, + {file = "MarkupSafe-2.1.4.tar.gz", hash = "sha256:3aae9af4cac263007fd6309c64c6ab4506dd2b79382d9d19a1994f9240b8db4f"}, +] + [[package]] name = "matplotlib" version = "3.8.2" description = "Python plotting package" -category = "main" optional = false python-versions = ">=3.9" +files = [ + {file = "matplotlib-3.8.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:09796f89fb71a0c0e1e2f4bdaf63fb2cefc84446bb963ecdeb40dfee7dfa98c7"}, + {file = "matplotlib-3.8.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6f9c6976748a25e8b9be51ea028df49b8e561eed7809146da7a47dbecebab367"}, + {file = "matplotlib-3.8.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b78e4f2cedf303869b782071b55fdde5987fda3038e9d09e58c91cc261b5ad18"}, + {file = "matplotlib-3.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4e208f46cf6576a7624195aa047cb344a7f802e113bb1a06cfd4bee431de5e31"}, + {file = "matplotlib-3.8.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:46a569130ff53798ea5f50afce7406e91fdc471ca1e0e26ba976a8c734c9427a"}, + {file = "matplotlib-3.8.2-cp310-cp310-win_amd64.whl", hash = "sha256:830f00640c965c5b7f6bc32f0d4ce0c36dfe0379f7dd65b07a00c801713ec40a"}, + {file = "matplotlib-3.8.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d86593ccf546223eb75a39b44c32788e6f6440d13cfc4750c1c15d0fcb850b63"}, + {file = "matplotlib-3.8.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9a5430836811b7652991939012f43d2808a2db9b64ee240387e8c43e2e5578c8"}, + {file = "matplotlib-3.8.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b9576723858a78751d5aacd2497b8aef29ffea6d1c95981505877f7ac28215c6"}, + {file = "matplotlib-3.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ba9cbd8ac6cf422f3102622b20f8552d601bf8837e49a3afed188d560152788"}, + {file = "matplotlib-3.8.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:03f9d160a29e0b65c0790bb07f4f45d6a181b1ac33eb1bb0dd225986450148f0"}, + {file = "matplotlib-3.8.2-cp311-cp311-win_amd64.whl", hash = "sha256:3773002da767f0a9323ba1a9b9b5d00d6257dbd2a93107233167cfb581f64717"}, + {file = "matplotlib-3.8.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:4c318c1e95e2f5926fba326f68177dee364aa791d6df022ceb91b8221bd0a627"}, + {file = "matplotlib-3.8.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:091275d18d942cf1ee9609c830a1bc36610607d8223b1b981c37d5c9fc3e46a4"}, + {file = "matplotlib-3.8.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b0f3b8ea0e99e233a4bcc44590f01604840d833c280ebb8fe5554fd3e6cfe8d"}, + {file = "matplotlib-3.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7b1704a530395aaf73912be741c04d181f82ca78084fbd80bc737be04848331"}, + {file = "matplotlib-3.8.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:533b0e3b0c6768eef8cbe4b583731ce25a91ab54a22f830db2b031e83cca9213"}, + {file = "matplotlib-3.8.2-cp312-cp312-win_amd64.whl", hash = "sha256:0f4fc5d72b75e2c18e55eb32292659cf731d9d5b312a6eb036506304f4675630"}, + {file = "matplotlib-3.8.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:deaed9ad4da0b1aea77fe0aa0cebb9ef611c70b3177be936a95e5d01fa05094f"}, + {file = "matplotlib-3.8.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:172f4d0fbac3383d39164c6caafd3255ce6fa58f08fc392513a0b1d3b89c4f89"}, + {file = "matplotlib-3.8.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7d36c2209d9136cd8e02fab1c0ddc185ce79bc914c45054a9f514e44c787917"}, + {file = "matplotlib-3.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5864bdd7da445e4e5e011b199bb67168cdad10b501750367c496420f2ad00843"}, + {file = "matplotlib-3.8.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ef8345b48e95cee45ff25192ed1f4857273117917a4dcd48e3905619bcd9c9b8"}, + {file = "matplotlib-3.8.2-cp39-cp39-win_amd64.whl", hash = "sha256:7c48d9e221b637c017232e3760ed30b4e8d5dfd081daf327e829bf2a72c731b4"}, + {file = "matplotlib-3.8.2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:aa11b3c6928a1e496c1a79917d51d4cd5d04f8a2e75f21df4949eeefdf697f4b"}, + {file = "matplotlib-3.8.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d1095fecf99eeb7384dabad4bf44b965f929a5f6079654b681193edf7169ec20"}, + {file = "matplotlib-3.8.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:bddfb1db89bfaa855912261c805bd0e10218923cc262b9159a49c29a7a1c1afa"}, + {file = "matplotlib-3.8.2.tar.gz", hash = "sha256:01a978b871b881ee76017152f1f1a0cbf6bd5f7b8ff8c96df0df1bd57d8755a1"}, +] [package.dependencies] contourpy = ">=1.0.1" @@ -254,39 +902,126 @@ python-dateutil = ">=2.7" name = "mdurl" version = "0.1.2" description = "Markdown URL utilities" -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, + {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, +] [[package]] name = "numpy" -version = "1.26.2" +version = "1.26.3" description = "Fundamental package for array computing in Python" -category = "main" optional = false python-versions = ">=3.9" +files = [ + {file = "numpy-1.26.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:806dd64230dbbfaca8a27faa64e2f414bf1c6622ab78cc4264f7f5f028fee3bf"}, + {file = "numpy-1.26.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:02f98011ba4ab17f46f80f7f8f1c291ee7d855fcef0a5a98db80767a468c85cd"}, + {file = "numpy-1.26.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d45b3ec2faed4baca41c76617fcdcfa4f684ff7a151ce6fc78ad3b6e85af0a6"}, + {file = "numpy-1.26.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bdd2b45bf079d9ad90377048e2747a0c82351989a2165821f0c96831b4a2a54b"}, + {file = "numpy-1.26.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:211ddd1e94817ed2d175b60b6374120244a4dd2287f4ece45d49228b4d529178"}, + {file = "numpy-1.26.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b1240f767f69d7c4c8a29adde2310b871153df9b26b5cb2b54a561ac85146485"}, + {file = "numpy-1.26.3-cp310-cp310-win32.whl", hash = "sha256:21a9484e75ad018974a2fdaa216524d64ed4212e418e0a551a2d83403b0531d3"}, + {file = "numpy-1.26.3-cp310-cp310-win_amd64.whl", hash = "sha256:9e1591f6ae98bcfac2a4bbf9221c0b92ab49762228f38287f6eeb5f3f55905ce"}, + {file = "numpy-1.26.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b831295e5472954104ecb46cd98c08b98b49c69fdb7040483aff799a755a7374"}, + {file = "numpy-1.26.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9e87562b91f68dd8b1c39149d0323b42e0082db7ddb8e934ab4c292094d575d6"}, + {file = "numpy-1.26.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c66d6fec467e8c0f975818c1796d25c53521124b7cfb760114be0abad53a0a2"}, + {file = "numpy-1.26.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f25e2811a9c932e43943a2615e65fc487a0b6b49218899e62e426e7f0a57eeda"}, + {file = "numpy-1.26.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:af36e0aa45e25c9f57bf684b1175e59ea05d9a7d3e8e87b7ae1a1da246f2767e"}, + {file = "numpy-1.26.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:51c7f1b344f302067b02e0f5b5d2daa9ed4a721cf49f070280ac202738ea7f00"}, + {file = "numpy-1.26.3-cp311-cp311-win32.whl", hash = "sha256:7ca4f24341df071877849eb2034948459ce3a07915c2734f1abb4018d9c49d7b"}, + {file = "numpy-1.26.3-cp311-cp311-win_amd64.whl", hash = "sha256:39763aee6dfdd4878032361b30b2b12593fb445ddb66bbac802e2113eb8a6ac4"}, + {file = "numpy-1.26.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a7081fd19a6d573e1a05e600c82a1c421011db7935ed0d5c483e9dd96b99cf13"}, + {file = "numpy-1.26.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12c70ac274b32bc00c7f61b515126c9205323703abb99cd41836e8125ea0043e"}, + {file = "numpy-1.26.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f784e13e598e9594750b2ef6729bcd5a47f6cfe4a12cca13def35e06d8163e3"}, + {file = "numpy-1.26.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f24750ef94d56ce6e33e4019a8a4d68cfdb1ef661a52cdaee628a56d2437419"}, + {file = "numpy-1.26.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:77810ef29e0fb1d289d225cabb9ee6cf4d11978a00bb99f7f8ec2132a84e0166"}, + {file = "numpy-1.26.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8ed07a90f5450d99dad60d3799f9c03c6566709bd53b497eb9ccad9a55867f36"}, + {file = "numpy-1.26.3-cp312-cp312-win32.whl", hash = "sha256:f73497e8c38295aaa4741bdfa4fda1a5aedda5473074369eca10626835445511"}, + {file = "numpy-1.26.3-cp312-cp312-win_amd64.whl", hash = "sha256:da4b0c6c699a0ad73c810736303f7fbae483bcb012e38d7eb06a5e3b432c981b"}, + {file = "numpy-1.26.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1666f634cb3c80ccbd77ec97bc17337718f56d6658acf5d3b906ca03e90ce87f"}, + {file = "numpy-1.26.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:18c3319a7d39b2c6a9e3bb75aab2304ab79a811ac0168a671a62e6346c29b03f"}, + {file = "numpy-1.26.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b7e807d6888da0db6e7e75838444d62495e2b588b99e90dd80c3459594e857b"}, + {file = "numpy-1.26.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4d362e17bcb0011738c2d83e0a65ea8ce627057b2fdda37678f4374a382a137"}, + {file = "numpy-1.26.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b8c275f0ae90069496068c714387b4a0eba5d531aace269559ff2b43655edd58"}, + {file = "numpy-1.26.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:cc0743f0302b94f397a4a65a660d4cd24267439eb16493fb3caad2e4389bccbb"}, + {file = "numpy-1.26.3-cp39-cp39-win32.whl", hash = "sha256:9bc6d1a7f8cedd519c4b7b1156d98e051b726bf160715b769106661d567b3f03"}, + {file = "numpy-1.26.3-cp39-cp39-win_amd64.whl", hash = "sha256:867e3644e208c8922a3be26fc6bbf112a035f50f0a86497f98f228c50c607bb2"}, + {file = "numpy-1.26.3-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:3c67423b3703f8fbd90f5adaa37f85b5794d3366948efe9a5190a5f3a83fc34e"}, + {file = "numpy-1.26.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46f47ee566d98849323f01b349d58f2557f02167ee301e5e28809a8c0e27a2d0"}, + {file = "numpy-1.26.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a8474703bffc65ca15853d5fd4d06b18138ae90c17c8d12169968e998e448bb5"}, + {file = "numpy-1.26.3.tar.gz", hash = "sha256:697df43e2b6310ecc9d95f05d5ef20eacc09c7c4ecc9da3f235d39e71b7da1e4"}, +] + +[[package]] +name = "oauthlib" +version = "3.2.2" +description = "A generic, spec-compliant, thorough implementation of the OAuth request-signing logic" +optional = false +python-versions = ">=3.6" +files = [ + {file = "oauthlib-3.2.2-py3-none-any.whl", hash = "sha256:8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca"}, + {file = "oauthlib-3.2.2.tar.gz", hash = "sha256:9859c40929662bec5d64f34d01c99e093149682a3f38915dc0655d5a633dd918"}, +] + +[package.extras] +rsa = ["cryptography (>=3.0.0)"] +signals = ["blinker (>=1.4.0)"] +signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"] [[package]] name = "packaging" version = "23.2" description = "Core utilities for Python packages" -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, + {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, +] [[package]] name = "pandas" version = "1.5.3" description = "Powerful data structures for data analysis, time series, and statistics" -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3749077d86e3a2f0ed51367f30bf5b82e131cc0f14260c4d3e499186fccc4406"}, + {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:972d8a45395f2a2d26733eb8d0f629b2f90bebe8e8eddbb8829b180c09639572"}, + {file = "pandas-1.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:50869a35cbb0f2e0cd5ec04b191e7b12ed688874bd05dd777c19b28cbea90996"}, + {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3ac844a0fe00bfaeb2c9b51ab1424e5c8744f89860b138434a363b1f620f354"}, + {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a0a56cef15fd1586726dace5616db75ebcfec9179a3a55e78f72c5639fa2a23"}, + {file = "pandas-1.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:478ff646ca42b20376e4ed3fa2e8d7341e8a63105586efe54fa2508ee087f328"}, + {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6973549c01ca91ec96199e940495219c887ea815b2083722821f1d7abfa2b4dc"}, + {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c39a8da13cede5adcd3be1182883aea1c925476f4e84b2807a46e2775306305d"}, + {file = "pandas-1.5.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f76d097d12c82a535fda9dfe5e8dd4127952b45fea9b0276cb30cca5ea313fbc"}, + {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e474390e60ed609cec869b0da796ad94f420bb057d86784191eefc62b65819ae"}, + {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f2b952406a1588ad4cad5b3f55f520e82e902388a6d5a4a91baa8d38d23c7f6"}, + {file = "pandas-1.5.3-cp311-cp311-win_amd64.whl", hash = "sha256:bc4c368f42b551bf72fac35c5128963a171b40dce866fb066540eeaf46faa003"}, + {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:14e45300521902689a81f3f41386dc86f19b8ba8dd5ac5a3c7010ef8d2932813"}, + {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9842b6f4b8479e41968eced654487258ed81df7d1c9b7b870ceea24ed9459b31"}, + {file = "pandas-1.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:26d9c71772c7afb9d5046e6e9cf42d83dd147b5cf5bcb9d97252077118543792"}, + {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5fbcb19d6fceb9e946b3e23258757c7b225ba450990d9ed63ccceeb8cae609f7"}, + {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:565fa34a5434d38e9d250af3c12ff931abaf88050551d9fbcdfafca50d62babf"}, + {file = "pandas-1.5.3-cp38-cp38-win32.whl", hash = "sha256:87bd9c03da1ac870a6d2c8902a0e1fd4267ca00f13bc494c9e5a9020920e1d51"}, + {file = "pandas-1.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:41179ce559943d83a9b4bbacb736b04c928b095b5f25dd2b7389eda08f46f373"}, + {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c74a62747864ed568f5a82a49a23a8d7fe171d0c69038b38cedf0976831296fa"}, + {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c4c00e0b0597c8e4f59e8d461f797e5d70b4d025880516a8261b2817c47759ee"}, + {file = "pandas-1.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a50d9a4336a9621cab7b8eb3fb11adb82de58f9b91d84c2cd526576b881a0c5a"}, + {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd05f7783b3274aa206a1af06f0ceed3f9b412cf665b7247eacd83be41cf7bf0"}, + {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f69c4029613de47816b1bb30ff5ac778686688751a5e9c99ad8c7031f6508e5"}, + {file = "pandas-1.5.3-cp39-cp39-win32.whl", hash = "sha256:7cec0bee9f294e5de5bbfc14d0573f65526071029d036b753ee6507d2a21480a"}, + {file = "pandas-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:dfd681c5dc216037e0b0a2c821f5ed99ba9f03ebcf119c7dac0e9a7b960b9ec9"}, + {file = "pandas-1.5.3.tar.gz", hash = "sha256:74a3fd7e5a7ec052f183273dc7b0acd3a863edf7520f5d3a1765c04ffdb3b0b1"}, +] [package.dependencies] numpy = [ {version = ">=1.20.3", markers = "python_version < \"3.10\""}, - {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, + {version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""}, ] python-dateutil = ">=2.8.1" pytz = ">=2020.1" @@ -295,44 +1030,167 @@ pytz = ">=2020.1" test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] [[package]] -name = "Pillow" +name = "pillow" version = "9.5.0" description = "Python Imaging Library (Fork)" -category = "main" optional = false python-versions = ">=3.7" - -[package.extras] -docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] -tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] - -[[package]] -name = "pluggy" -version = "1.3.0" -description = "plugin and hook calling mechanisms for python" -category = "dev" -optional = false -python-versions = ">=3.8" - -[package.extras] +files = [ + {file = "Pillow-9.5.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:ace6ca218308447b9077c14ea4ef381ba0b67ee78d64046b3f19cf4e1139ad16"}, + {file = "Pillow-9.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d3d403753c9d5adc04d4694d35cf0391f0f3d57c8e0030aac09d7678fa8030aa"}, + {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5ba1b81ee69573fe7124881762bb4cd2e4b6ed9dd28c9c60a632902fe8db8b38"}, + {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe7e1c262d3392afcf5071df9afa574544f28eac825284596ac6db56e6d11062"}, + {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f36397bf3f7d7c6a3abdea815ecf6fd14e7fcd4418ab24bae01008d8d8ca15e"}, + {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:252a03f1bdddce077eff2354c3861bf437c892fb1832f75ce813ee94347aa9b5"}, + {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:85ec677246533e27770b0de5cf0f9d6e4ec0c212a1f89dfc941b64b21226009d"}, + {file = "Pillow-9.5.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b416f03d37d27290cb93597335a2f85ed446731200705b22bb927405320de903"}, + {file = "Pillow-9.5.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:1781a624c229cb35a2ac31cc4a77e28cafc8900733a864870c49bfeedacd106a"}, + {file = "Pillow-9.5.0-cp310-cp310-win32.whl", hash = "sha256:8507eda3cd0608a1f94f58c64817e83ec12fa93a9436938b191b80d9e4c0fc44"}, + {file = "Pillow-9.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:d3c6b54e304c60c4181da1c9dadf83e4a54fd266a99c70ba646a9baa626819eb"}, + {file = "Pillow-9.5.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:7ec6f6ce99dab90b52da21cf0dc519e21095e332ff3b399a357c187b1a5eee32"}, + {file = "Pillow-9.5.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:560737e70cb9c6255d6dcba3de6578a9e2ec4b573659943a5e7e4af13f298f5c"}, + {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:96e88745a55b88a7c64fa49bceff363a1a27d9a64e04019c2281049444a571e3"}, + {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d9c206c29b46cfd343ea7cdfe1232443072bbb270d6a46f59c259460db76779a"}, + {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cfcc2c53c06f2ccb8976fb5c71d448bdd0a07d26d8e07e321c103416444c7ad1"}, + {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:a0f9bb6c80e6efcde93ffc51256d5cfb2155ff8f78292f074f60f9e70b942d99"}, + {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:8d935f924bbab8f0a9a28404422da8af4904e36d5c33fc6f677e4c4485515625"}, + {file = "Pillow-9.5.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:fed1e1cf6a42577953abbe8e6cf2fe2f566daebde7c34724ec8803c4c0cda579"}, + {file = "Pillow-9.5.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:c1170d6b195555644f0616fd6ed929dfcf6333b8675fcca044ae5ab110ded296"}, + {file = "Pillow-9.5.0-cp311-cp311-win32.whl", hash = "sha256:54f7102ad31a3de5666827526e248c3530b3a33539dbda27c6843d19d72644ec"}, + {file = "Pillow-9.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:cfa4561277f677ecf651e2b22dc43e8f5368b74a25a8f7d1d4a3a243e573f2d4"}, + {file = "Pillow-9.5.0-cp311-cp311-win_arm64.whl", hash = "sha256:965e4a05ef364e7b973dd17fc765f42233415974d773e82144c9bbaaaea5d089"}, + {file = "Pillow-9.5.0-cp312-cp312-win32.whl", hash = "sha256:22baf0c3cf0c7f26e82d6e1adf118027afb325e703922c8dfc1d5d0156bb2eeb"}, + {file = "Pillow-9.5.0-cp312-cp312-win_amd64.whl", hash = "sha256:432b975c009cf649420615388561c0ce7cc31ce9b2e374db659ee4f7d57a1f8b"}, + {file = "Pillow-9.5.0-cp37-cp37m-macosx_10_10_x86_64.whl", hash = "sha256:5d4ebf8e1db4441a55c509c4baa7a0587a0210f7cd25fcfe74dbbce7a4bd1906"}, + {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:375f6e5ee9620a271acb6820b3d1e94ffa8e741c0601db4c0c4d3cb0a9c224bf"}, + {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:99eb6cafb6ba90e436684e08dad8be1637efb71c4f2180ee6b8f940739406e78"}, + {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2dfaaf10b6172697b9bceb9a3bd7b951819d1ca339a5ef294d1f1ac6d7f63270"}, + {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_28_aarch64.whl", hash = "sha256:763782b2e03e45e2c77d7779875f4432e25121ef002a41829d8868700d119392"}, + {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_28_x86_64.whl", hash = "sha256:35f6e77122a0c0762268216315bf239cf52b88865bba522999dc38f1c52b9b47"}, + {file = "Pillow-9.5.0-cp37-cp37m-win32.whl", hash = "sha256:aca1c196f407ec7cf04dcbb15d19a43c507a81f7ffc45b690899d6a76ac9fda7"}, + {file = "Pillow-9.5.0-cp37-cp37m-win_amd64.whl", hash = "sha256:322724c0032af6692456cd6ed554bb85f8149214d97398bb80613b04e33769f6"}, + {file = "Pillow-9.5.0-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:a0aa9417994d91301056f3d0038af1199eb7adc86e646a36b9e050b06f526597"}, + {file = "Pillow-9.5.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f8286396b351785801a976b1e85ea88e937712ee2c3ac653710a4a57a8da5d9c"}, + {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c830a02caeb789633863b466b9de10c015bded434deb3ec87c768e53752ad22a"}, + {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fbd359831c1657d69bb81f0db962905ee05e5e9451913b18b831febfe0519082"}, + {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f8fc330c3370a81bbf3f88557097d1ea26cd8b019d6433aa59f71195f5ddebbf"}, + {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:7002d0797a3e4193c7cdee3198d7c14f92c0836d6b4a3f3046a64bd1ce8df2bf"}, + {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:229e2c79c00e85989a34b5981a2b67aa079fd08c903f0aaead522a1d68d79e51"}, + {file = "Pillow-9.5.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:9adf58f5d64e474bed00d69bcd86ec4bcaa4123bfa70a65ce72e424bfb88ed96"}, + {file = "Pillow-9.5.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:662da1f3f89a302cc22faa9f14a262c2e3951f9dbc9617609a47521c69dd9f8f"}, + {file = "Pillow-9.5.0-cp38-cp38-win32.whl", hash = "sha256:6608ff3bf781eee0cd14d0901a2b9cc3d3834516532e3bd673a0a204dc8615fc"}, + {file = "Pillow-9.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:e49eb4e95ff6fd7c0c402508894b1ef0e01b99a44320ba7d8ecbabefddcc5569"}, + {file = "Pillow-9.5.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:482877592e927fd263028c105b36272398e3e1be3269efda09f6ba21fd83ec66"}, + {file = "Pillow-9.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3ded42b9ad70e5f1754fb7c2e2d6465a9c842e41d178f262e08b8c85ed8a1d8e"}, + {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c446d2245ba29820d405315083d55299a796695d747efceb5717a8b450324115"}, + {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8aca1152d93dcc27dc55395604dcfc55bed5f25ef4c98716a928bacba90d33a3"}, + {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:608488bdcbdb4ba7837461442b90ea6f3079397ddc968c31265c1e056964f1ef"}, + {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:60037a8db8750e474af7ffc9faa9b5859e6c6d0a50e55c45576bf28be7419705"}, + {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:07999f5834bdc404c442146942a2ecadd1cb6292f5229f4ed3b31e0a108746b1"}, + {file = "Pillow-9.5.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a127ae76092974abfbfa38ca2d12cbeddcdeac0fb71f9627cc1135bedaf9d51a"}, + {file = "Pillow-9.5.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:489f8389261e5ed43ac8ff7b453162af39c3e8abd730af8363587ba64bb2e865"}, + {file = "Pillow-9.5.0-cp39-cp39-win32.whl", hash = "sha256:9b1af95c3a967bf1da94f253e56b6286b50af23392a886720f563c547e48e964"}, + {file = "Pillow-9.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:77165c4a5e7d5a284f10a6efaa39a0ae8ba839da344f20b111d62cc932fa4e5d"}, + {file = "Pillow-9.5.0-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:833b86a98e0ede388fa29363159c9b1a294b0905b5128baf01db683672f230f5"}, + {file = "Pillow-9.5.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aaf305d6d40bd9632198c766fb64f0c1a83ca5b667f16c1e79e1661ab5060140"}, + {file = "Pillow-9.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0852ddb76d85f127c135b6dd1f0bb88dbb9ee990d2cd9aa9e28526c93e794fba"}, + {file = "Pillow-9.5.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:91ec6fe47b5eb5a9968c79ad9ed78c342b1f97a091677ba0e012701add857829"}, + {file = "Pillow-9.5.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:cb841572862f629b99725ebaec3287fc6d275be9b14443ea746c1dd325053cbd"}, + {file = "Pillow-9.5.0-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:c380b27d041209b849ed246b111b7c166ba36d7933ec6e41175fd15ab9eb1572"}, + {file = "Pillow-9.5.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7c9af5a3b406a50e313467e3565fc99929717f780164fe6fbb7704edba0cebbe"}, + {file = "Pillow-9.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5671583eab84af046a397d6d0ba25343c00cd50bce03787948e0fff01d4fd9b1"}, + {file = "Pillow-9.5.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:84a6f19ce086c1bf894644b43cd129702f781ba5751ca8572f08aa40ef0ab7b7"}, + {file = "Pillow-9.5.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:1e7723bd90ef94eda669a3c2c19d549874dd5badaeefabefd26053304abe5799"}, + {file = "Pillow-9.5.0.tar.gz", hash = "sha256:bf548479d336726d7a0eceb6e767e179fbde37833ae42794602631a070d630f1"}, +] + +[package.extras] +docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] +tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] + +[[package]] +name = "pluggy" +version = "1.3.0" +description = "plugin and hook calling mechanisms for python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, + {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, +] + +[package.extras] dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "protobuf" +version = "4.23.4" +description = "" +optional = false +python-versions = ">=3.7" +files = [ + {file = "protobuf-4.23.4-cp310-abi3-win32.whl", hash = "sha256:5fea3c64d41ea5ecf5697b83e41d09b9589e6f20b677ab3c48e5f242d9b7897b"}, + {file = "protobuf-4.23.4-cp310-abi3-win_amd64.whl", hash = "sha256:7b19b6266d92ca6a2a87effa88ecc4af73ebc5cfde194dc737cf8ef23a9a3b12"}, + {file = "protobuf-4.23.4-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:8547bf44fe8cec3c69e3042f5c4fb3e36eb2a7a013bb0a44c018fc1e427aafbd"}, + {file = "protobuf-4.23.4-cp37-abi3-manylinux2014_aarch64.whl", hash = "sha256:fee88269a090ada09ca63551bf2f573eb2424035bcf2cb1b121895b01a46594a"}, + {file = "protobuf-4.23.4-cp37-abi3-manylinux2014_x86_64.whl", hash = "sha256:effeac51ab79332d44fba74660d40ae79985901ac21bca408f8dc335a81aa597"}, + {file = "protobuf-4.23.4-cp37-cp37m-win32.whl", hash = "sha256:c3e0939433c40796ca4cfc0fac08af50b00eb66a40bbbc5dee711998fb0bbc1e"}, + {file = "protobuf-4.23.4-cp37-cp37m-win_amd64.whl", hash = "sha256:9053df6df8e5a76c84339ee4a9f5a2661ceee4a0dab019e8663c50ba324208b0"}, + {file = "protobuf-4.23.4-cp38-cp38-win32.whl", hash = "sha256:e1c915778d8ced71e26fcf43c0866d7499891bca14c4368448a82edc61fdbc70"}, + {file = "protobuf-4.23.4-cp38-cp38-win_amd64.whl", hash = "sha256:351cc90f7d10839c480aeb9b870a211e322bf05f6ab3f55fcb2f51331f80a7d2"}, + {file = "protobuf-4.23.4-cp39-cp39-win32.whl", hash = "sha256:6dd9b9940e3f17077e820b75851126615ee38643c2c5332aa7a359988820c720"}, + {file = "protobuf-4.23.4-cp39-cp39-win_amd64.whl", hash = "sha256:0a5759f5696895de8cc913f084e27fd4125e8fb0914bb729a17816a33819f474"}, + {file = "protobuf-4.23.4-py3-none-any.whl", hash = "sha256:e9d0be5bf34b275b9f87ba7407796556abeeba635455d036c7351f7c183ef8ff"}, + {file = "protobuf-4.23.4.tar.gz", hash = "sha256:ccd9430c0719dce806b93f89c91de7977304729e55377f872a92465d548329a9"}, +] + [[package]] name = "py" version = "1.11.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, +] + +[[package]] +name = "pyasn1" +version = "0.5.1" +description = "Pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208)" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" +files = [ + {file = "pyasn1-0.5.1-py2.py3-none-any.whl", hash = "sha256:4439847c58d40b1d0a573d07e3856e95333f1976294494c325775aeca506eb58"}, + {file = "pyasn1-0.5.1.tar.gz", hash = "sha256:6d391a96e59b23130a5cfa74d6fd7f388dbbe26cc8f1edf39fdddf08d9d6676c"}, +] + +[[package]] +name = "pyasn1-modules" +version = "0.3.0" +description = "A collection of ASN.1-based protocols modules" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" +files = [ + {file = "pyasn1_modules-0.3.0-py2.py3-none-any.whl", hash = "sha256:d3ccd6ed470d9ffbc716be08bd90efbd44d0734bc9303818f7336070984a162d"}, + {file = "pyasn1_modules-0.3.0.tar.gz", hash = "sha256:5bd01446b736eb9d31512a30d46c1ac3395d676c6f3cafa4c03eb54b9925631c"}, +] + +[package.dependencies] +pyasn1 = ">=0.4.6,<0.6.0" [[package]] -name = "Pygments" +name = "pygments" version = "2.17.2" description = "Pygments is a syntax highlighting package written in Python." -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "pygments-2.17.2-py3-none-any.whl", hash = "sha256:b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c"}, + {file = "pygments-2.17.2.tar.gz", hash = "sha256:da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"}, +] [package.extras] plugins = ["importlib-metadata"] @@ -342,28 +1200,38 @@ windows-terminal = ["colorama (>=0.4.6)"] name = "pyparsing" version = "3.1.1" description = "pyparsing module - Classes and methods to define and execute parsing grammars" -category = "main" optional = false python-versions = ">=3.6.8" +files = [ + {file = "pyparsing-3.1.1-py3-none-any.whl", hash = "sha256:32c7c0b711493c72ff18a981d24f28aaf9c1fb7ed5e9667c9e84e3db623bdbfb"}, + {file = "pyparsing-3.1.1.tar.gz", hash = "sha256:ede28a1a32462f5a9705e07aea48001a08f7cf81a021585011deba701581a0db"}, +] [package.extras] diagrams = ["jinja2", "railroad-diagrams"] [[package]] -name = "PySocks" +name = "pysocks" version = "1.7.1" description = "A Python SOCKS client module. See https://github.com/Anorov/PySocks for more information." -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "PySocks-1.7.1-py27-none-any.whl", hash = "sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299"}, + {file = "PySocks-1.7.1-py3-none-any.whl", hash = "sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5"}, + {file = "PySocks-1.7.1.tar.gz", hash = "sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0"}, +] [[package]] name = "pytest" version = "6.2.5" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.6" +files = [ + {file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"}, + {file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"}, +] [package.dependencies] atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} @@ -382,9 +1250,12 @@ testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xm name = "pytest-cov" version = "4.1.0" description = "Pytest plugin for measuring coverage." -category = "dev" optional = false python-versions = ">=3.7" +files = [ + {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, + {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, +] [package.dependencies] coverage = {version = ">=5.2.1", extras = ["toml"]} @@ -397,9 +1268,12 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtuale name = "pytest-shell" version = "0.3.2" description = "A pytest plugin to help with testing shell scripts / black box commands" -category = "dev" optional = false python-versions = ">=3.7,<4.0" +files = [ + {file = "pytest-shell-0.3.2.tar.gz", hash = "sha256:7e30cf518a5271328f25eaa9013e1639607f169d7396a4b85204a8b34dacbab1"}, + {file = "pytest_shell-0.3.2-py3-none-any.whl", hash = "sha256:f60716134fc30e2c1fe9facb9fe60121d18b4d7b95e692b2c6f29271350aa12b"}, +] [package.dependencies] where = ">=1.0.2,<2.0.0" @@ -408,9 +1282,12 @@ where = ">=1.0.2,<2.0.0" name = "python-dateutil" version = "2.8.2" description = "Extensions to the standard Python datetime module" -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, + {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, +] [package.dependencies] six = ">=1.5" @@ -419,25 +1296,83 @@ six = ">=1.5" name = "pytz" version = "2023.3.post1" description = "World timezone definitions, modern and historical" -category = "main" optional = false python-versions = "*" +files = [ + {file = "pytz-2023.3.post1-py2.py3-none-any.whl", hash = "sha256:ce42d816b81b68506614c11e8937d3aa9e41007ceb50bfdcb0749b921bf646c7"}, + {file = "pytz-2023.3.post1.tar.gz", hash = "sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b"}, +] [[package]] -name = "PyYAML" +name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" -category = "main" optional = false python-versions = ">=3.6" +files = [ + {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, + {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, + {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, + {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, + {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, + {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, + {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, + {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, + {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, + {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, + {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, + {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, + {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, + {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, +] [[package]] name = "requests" version = "2.31.0" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"}, + {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, +] [package.dependencies] certifi = ">=2017.4.17" @@ -450,13 +1385,34 @@ urllib3 = ">=1.21.1,<3" socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] +[[package]] +name = "requests-oauthlib" +version = "1.3.1" +description = "OAuthlib authentication support for Requests." +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "requests-oauthlib-1.3.1.tar.gz", hash = "sha256:75beac4a47881eeb94d5ea5d6ad31ef88856affe2332b9aafb52c6452ccf0d7a"}, + {file = "requests_oauthlib-1.3.1-py2.py3-none-any.whl", hash = "sha256:2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5"}, +] + +[package.dependencies] +oauthlib = ">=3.0.0" +requests = ">=2.0.0" + +[package.extras] +rsa = ["oauthlib[signedtoken] (>=3.0.0)"] + [[package]] name = "rich" version = "13.7.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -category = "main" optional = false python-versions = ">=3.7.0" +files = [ + {file = "rich-13.7.0-py3-none-any.whl", hash = "sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235"}, + {file = "rich-13.7.0.tar.gz", hash = "sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa"}, +] [package.dependencies] markdown-it-py = ">=2.2.0" @@ -465,49 +1421,134 @@ pygments = ">=2.13.0,<3.0.0" [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] +[[package]] +name = "rsa" +version = "4.9" +description = "Pure-Python RSA implementation" +optional = false +python-versions = ">=3.6,<4" +files = [ + {file = "rsa-4.9-py3-none-any.whl", hash = "sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7"}, + {file = "rsa-4.9.tar.gz", hash = "sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21"}, +] + +[package.dependencies] +pyasn1 = ">=0.1.3" + [[package]] name = "scikit-learn" -version = "1.3.2" +version = "1.4.0" description = "A set of python modules for machine learning and data mining" -category = "main" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" +files = [ + {file = "scikit-learn-1.4.0.tar.gz", hash = "sha256:d4373c984eba20e393216edd51a3e3eede56cbe93d4247516d205643c3b93121"}, + {file = "scikit_learn-1.4.0-1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:fce93a7473e2f4ee4cc280210968288d6a7d7ad8dc6fa7bb7892145e407085f9"}, + {file = "scikit_learn-1.4.0-1-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:d77df3d1e15fc37a9329999979fa7868ba8655dbab21fe97fc7ddabac9e08cc7"}, + {file = "scikit_learn-1.4.0-1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2404659fedec40eeafa310cd14d613e564d13dbf8f3c752d31c095195ec05de6"}, + {file = "scikit_learn-1.4.0-1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e98632da8f6410e6fb6bf66937712c949b4010600ccd3f22a5388a83e610cc3c"}, + {file = "scikit_learn-1.4.0-1-cp310-cp310-win_amd64.whl", hash = "sha256:11b3b140f70fbc9f6a08884631ae8dd60a4bb2d7d6d1de92738ea42b740d8992"}, + {file = "scikit_learn-1.4.0-1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a8341eabdc754d5ab91641a7763243845e96b6d68e03e472531e88a4f1b09f21"}, + {file = "scikit_learn-1.4.0-1-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:d1f6bce875ac2bb6b52514f67c185c564ccd299a05b65b7bab091a4c13dde12d"}, + {file = "scikit_learn-1.4.0-1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c408b46b2fd61952d519ea1af2f8f0a7a703e1433923ab1704c4131520b2083b"}, + {file = "scikit_learn-1.4.0-1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2b465dd1dcd237b7b1dcd1a9048ccbf70a98c659474324fa708464c3a2533fad"}, + {file = "scikit_learn-1.4.0-1-cp311-cp311-win_amd64.whl", hash = "sha256:0db8e22c42f7980fe5eb22069b1f84c48966f3e0d23a01afde5999e3987a2501"}, + {file = "scikit_learn-1.4.0-1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:e7eef6ea2ed289af40e88c0be9f7704ca8b5de18508a06897c3fe21e0905efdf"}, + {file = "scikit_learn-1.4.0-1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:349669b01435bc4dbf25c6410b0892073befdaec52637d1a1d1ff53865dc8db3"}, + {file = "scikit_learn-1.4.0-1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d439c584e58434d0350701bd33f6c10b309e851fccaf41c121aed55f6851d8cf"}, + {file = "scikit_learn-1.4.0-1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0e2427d9ef46477625ab9b55c1882844fe6fc500f418c3f8e650200182457bc"}, + {file = "scikit_learn-1.4.0-1-cp312-cp312-win_amd64.whl", hash = "sha256:d3d75343940e7bf9b85c830c93d34039fa015eeb341c5c0b4cd7a90dadfe00d4"}, + {file = "scikit_learn-1.4.0-1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:76986d22e884ab062b1beecdd92379656e9d3789ecc1f9870923c178de55f9fe"}, + {file = "scikit_learn-1.4.0-1-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:e22446ad89f1cb7657f0d849dcdc345b48e2d10afa3daf2925fdb740f85b714c"}, + {file = "scikit_learn-1.4.0-1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74812c9eabb265be69d738a8ea8d4884917a59637fcbf88a5f0e9020498bc6b3"}, + {file = "scikit_learn-1.4.0-1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aad2a63e0dd386b92da3270887a29b308af4d7c750d8c4995dfd9a4798691bcc"}, + {file = "scikit_learn-1.4.0-1-cp39-cp39-win_amd64.whl", hash = "sha256:53b9e29177897c37e2ff9d4ba6ca12fdb156e22523e463db05def303f5c72b5c"}, + {file = "scikit_learn-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:cb8f044a8f5962613ce1feb4351d66f8d784bd072d36393582f351859b065f7d"}, + {file = "scikit_learn-1.4.0-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:a6372c90bbf302387792108379f1ec77719c1618d88496d0df30cb8e370b4661"}, + {file = "scikit_learn-1.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:785ce3c352bf697adfda357c3922c94517a9376002971bc5ea50896144bc8916"}, + {file = "scikit_learn-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0aba2a20d89936d6e72d95d05e3bf1db55bca5c5920926ad7b92c34f5e7d3bbe"}, + {file = "scikit_learn-1.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:2bac5d56b992f8f06816f2cd321eb86071c6f6d44bb4b1cb3d626525820d754b"}, + {file = "scikit_learn-1.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:27ae4b0f1b2c77107c096a7e05b33458354107b47775428d1f11b23e30a73e8a"}, + {file = "scikit_learn-1.4.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:5c5c62ffb52c3ffb755eb21fa74cc2cbf2c521bd53f5c04eaa10011dbecf5f80"}, + {file = "scikit_learn-1.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f0d2018ac6fa055dab65fe8a485967990d33c672d55bc254c56c35287b02fab"}, + {file = "scikit_learn-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:91a8918c415c4b4bf1d60c38d32958849a9191c2428ab35d30b78354085c7c7a"}, + {file = "scikit_learn-1.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:80a21de63275f8bcd7877b3e781679d2ff1eddfed515a599f95b2502a3283d42"}, + {file = "scikit_learn-1.4.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:0f33bbafb310c26b81c4d41ecaebdbc1f63498a3f13461d50ed9a2e8f24d28e4"}, + {file = "scikit_learn-1.4.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:8b6ac1442ec714b4911e5aef8afd82c691b5c88b525ea58299d455acc4e8dcec"}, + {file = "scikit_learn-1.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05fc5915b716c6cc60a438c250108e9a9445b522975ed37e416d5ea4f9a63381"}, + {file = "scikit_learn-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:842b7d6989f3c574685e18da6f91223eb32301d0f93903dd399894250835a6f7"}, + {file = "scikit_learn-1.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:88bcb586fdff865372df1bc6be88bb7e6f9e0aa080dab9f54f5cac7eca8e2b6b"}, + {file = "scikit_learn-1.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f77674647dd31f56cb12ed13ed25b6ed43a056fffef051715022d2ebffd7a7d1"}, + {file = "scikit_learn-1.4.0-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:833999872e2920ce00f3a50839946bdac7539454e200eb6db54898a41f4bfd43"}, + {file = "scikit_learn-1.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:970ec697accaef10fb4f51763f3a7b1250f9f0553cf05514d0e94905322a0172"}, + {file = "scikit_learn-1.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:923d778f378ebacca2c672ab1740e5a413e437fb45ab45ab02578f8b689e5d43"}, + {file = "scikit_learn-1.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:1d041bc95006b545b59e458399e3175ab11ca7a03dc9a74a573ac891f5df1489"}, +] [package.dependencies] -joblib = ">=1.1.1" -numpy = ">=1.17.3,<2.0" -scipy = ">=1.5.0" +joblib = ">=1.2.0" +numpy = ">=1.19.5" +scipy = ">=1.6.0" threadpoolctl = ">=2.0.0" [package.extras] -benchmark = ["matplotlib (>=3.1.3)", "memory-profiler (>=0.57.0)", "pandas (>=1.0.5)"] -docs = ["Pillow (>=7.1.2)", "matplotlib (>=3.1.3)", "memory-profiler (>=0.57.0)", "numpydoc (>=1.2.0)", "pandas (>=1.0.5)", "plotly (>=5.14.0)", "pooch (>=1.6.0)", "scikit-image (>=0.16.2)", "seaborn (>=0.9.0)", "sphinx (>=6.0.0)", "sphinx-copybutton (>=0.5.2)", "sphinx-gallery (>=0.10.1)", "sphinx-prompt (>=1.3.0)", "sphinxext-opengraph (>=0.4.2)"] -examples = ["matplotlib (>=3.1.3)", "pandas (>=1.0.5)", "plotly (>=5.14.0)", "pooch (>=1.6.0)", "scikit-image (>=0.16.2)", "seaborn (>=0.9.0)"] -tests = ["black (>=23.3.0)", "matplotlib (>=3.1.3)", "mypy (>=1.3)", "numpydoc (>=1.2.0)", "pandas (>=1.0.5)", "pooch (>=1.6.0)", "pyamg (>=4.0.0)", "pytest (>=7.1.2)", "pytest-cov (>=2.9.0)", "ruff (>=0.0.272)", "scikit-image (>=0.16.2)"] +benchmark = ["matplotlib (>=3.3.4)", "memory-profiler (>=0.57.0)", "pandas (>=1.1.5)"] +docs = ["Pillow (>=7.1.2)", "matplotlib (>=3.3.4)", "memory-profiler (>=0.57.0)", "numpydoc (>=1.2.0)", "pandas (>=1.1.5)", "plotly (>=5.14.0)", "pooch (>=1.6.0)", "scikit-image (>=0.17.2)", "seaborn (>=0.9.0)", "sphinx (>=6.0.0)", "sphinx-copybutton (>=0.5.2)", "sphinx-gallery (>=0.15.0)", "sphinx-prompt (>=1.3.0)", "sphinxext-opengraph (>=0.4.2)"] +examples = ["matplotlib (>=3.3.4)", "pandas (>=1.1.5)", "plotly (>=5.14.0)", "pooch (>=1.6.0)", "scikit-image (>=0.17.2)", "seaborn (>=0.9.0)"] +tests = ["black (>=23.3.0)", "matplotlib (>=3.3.4)", "mypy (>=1.3)", "numpydoc (>=1.2.0)", "pandas (>=1.1.5)", "polars (>=0.19.12)", "pooch (>=1.6.0)", "pyamg (>=4.0.0)", "pyarrow (>=12.0.0)", "pytest (>=7.1.2)", "pytest-cov (>=2.9.0)", "ruff (>=0.0.272)", "scikit-image (>=0.17.2)"] [[package]] name = "scipy" -version = "1.11.4" +version = "1.12.0" description = "Fundamental algorithms for scientific computing in Python" -category = "main" optional = false python-versions = ">=3.9" +files = [ + {file = "scipy-1.12.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:78e4402e140879387187f7f25d91cc592b3501a2e51dfb320f48dfb73565f10b"}, + {file = "scipy-1.12.0-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:f5f00ebaf8de24d14b8449981a2842d404152774c1a1d880c901bf454cb8e2a1"}, + {file = "scipy-1.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e53958531a7c695ff66c2e7bb7b79560ffdc562e2051644c5576c39ff8efb563"}, + {file = "scipy-1.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e32847e08da8d895ce09d108a494d9eb78974cf6de23063f93306a3e419960c"}, + {file = "scipy-1.12.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4c1020cad92772bf44b8e4cdabc1df5d87376cb219742549ef69fc9fd86282dd"}, + {file = "scipy-1.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:75ea2a144096b5e39402e2ff53a36fecfd3b960d786b7efd3c180e29c39e53f2"}, + {file = "scipy-1.12.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:408c68423f9de16cb9e602528be4ce0d6312b05001f3de61fe9ec8b1263cad08"}, + {file = "scipy-1.12.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:5adfad5dbf0163397beb4aca679187d24aec085343755fcdbdeb32b3679f254c"}, + {file = "scipy-1.12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3003652496f6e7c387b1cf63f4bb720951cfa18907e998ea551e6de51a04467"}, + {file = "scipy-1.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8b8066bce124ee5531d12a74b617d9ac0ea59245246410e19bca549656d9a40a"}, + {file = "scipy-1.12.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8bee4993817e204d761dba10dbab0774ba5a8612e57e81319ea04d84945375ba"}, + {file = "scipy-1.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:a24024d45ce9a675c1fb8494e8e5244efea1c7a09c60beb1eeb80373d0fecc70"}, + {file = "scipy-1.12.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:e7e76cc48638228212c747ada851ef355c2bb5e7f939e10952bc504c11f4e372"}, + {file = "scipy-1.12.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:f7ce148dffcd64ade37b2df9315541f9adad6efcaa86866ee7dd5db0c8f041c3"}, + {file = "scipy-1.12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9c39f92041f490422924dfdb782527a4abddf4707616e07b021de33467f917bc"}, + {file = "scipy-1.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a7ebda398f86e56178c2fa94cad15bf457a218a54a35c2a7b4490b9f9cb2676c"}, + {file = "scipy-1.12.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:95e5c750d55cf518c398a8240571b0e0782c2d5a703250872f36eaf737751338"}, + {file = "scipy-1.12.0-cp312-cp312-win_amd64.whl", hash = "sha256:e646d8571804a304e1da01040d21577685ce8e2db08ac58e543eaca063453e1c"}, + {file = "scipy-1.12.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:913d6e7956c3a671de3b05ccb66b11bc293f56bfdef040583a7221d9e22a2e35"}, + {file = "scipy-1.12.0-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:bba1b0c7256ad75401c73e4b3cf09d1f176e9bd4248f0d3112170fb2ec4db067"}, + {file = "scipy-1.12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:730badef9b827b368f351eacae2e82da414e13cf8bd5051b4bdfd720271a5371"}, + {file = "scipy-1.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6546dc2c11a9df6926afcbdd8a3edec28566e4e785b915e849348c6dd9f3f490"}, + {file = "scipy-1.12.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:196ebad3a4882081f62a5bf4aeb7326aa34b110e533aab23e4374fcccb0890dc"}, + {file = "scipy-1.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:b360f1b6b2f742781299514e99ff560d1fe9bd1bff2712894b52abe528d1fd1e"}, + {file = "scipy-1.12.0.tar.gz", hash = "sha256:4bf5abab8a36d20193c698b0f1fc282c1d083c94723902c447e5d2f1780936a3"}, +] [package.dependencies] -numpy = ">=1.21.6,<1.28.0" +numpy = ">=1.22.4,<1.29.0" [package.extras] dev = ["click", "cython-lint (>=0.12.2)", "doit (>=0.36.0)", "mypy", "pycodestyle", "pydevtool", "rich-click", "ruff", "types-psutil", "typing_extensions"] doc = ["jupytext", "matplotlib (>2)", "myst-nb", "numpydoc", "pooch", "pydata-sphinx-theme (==0.9.0)", "sphinx (!=4.1.0)", "sphinx-design (>=0.2.0)"] -test = ["asv", "gmpy2", "mpmath", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] +test = ["asv", "gmpy2", "hypothesis", "mpmath", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] [[package]] name = "seaborn" version = "0.12.2" description = "Statistical data visualization" -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "seaborn-0.12.2-py3-none-any.whl", hash = "sha256:ebf15355a4dba46037dfd65b7350f014ceb1f13c05e814eda2c9f5fd731afc08"}, + {file = "seaborn-0.12.2.tar.gz", hash = "sha256:374645f36509d0dcab895cba5b47daf0586f77bfe3b36c97c607db7da5be0139"}, +] [package.dependencies] matplotlib = ">=3.1,<3.6.1 || >3.6.1" @@ -519,53 +1560,141 @@ dev = ["flake8", "flit", "mypy", "pandas-stubs", "pre-commit", "pytest", "pytest docs = ["ipykernel", "nbconvert", "numpydoc", "pydata_sphinx_theme (==0.10.0rc2)", "pyyaml", "sphinx-copybutton", "sphinx-design", "sphinx-issues"] stats = ["scipy (>=1.3)", "statsmodels (>=0.10)"] +[[package]] +name = "setuptools" +version = "69.0.3" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, + {file = "setuptools-69.0.3.tar.gz", hash = "sha256:be1af57fc409f93647f2e8e4573a142ed38724b8cdd389706a867bb4efcf1e78"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.1)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + [[package]] name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] [[package]] name = "soupsieve" version = "2.5" description = "A modern CSS selector implementation for Beautiful Soup." -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "soupsieve-2.5-py3-none-any.whl", hash = "sha256:eaa337ff55a1579b6549dc679565eac1e3d000563bcb1c8ab0d0fefbc0c2cdc7"}, + {file = "soupsieve-2.5.tar.gz", hash = "sha256:5663d5a7b3bfaeee0bc4372e7fc48f9cff4940b3eec54a6451cc5299f1097690"}, +] + +[[package]] +name = "tensorboard" +version = "2.15.1" +description = "TensorBoard lets you watch Tensors Flow" +optional = false +python-versions = ">=3.9" +files = [ + {file = "tensorboard-2.15.1-py3-none-any.whl", hash = "sha256:c46c1d1cf13a458c429868a78b2531d8ff5f682058d69ec0840b0bc7a38f1c0f"}, +] + +[package.dependencies] +absl-py = ">=0.4" +google-auth = ">=1.6.3,<3" +google-auth-oauthlib = ">=0.5,<2" +grpcio = ">=1.48.2" +markdown = ">=2.6.8" +numpy = ">=1.12.0" +protobuf = ">=3.19.6,<4.24" +requests = ">=2.21.0,<3" +setuptools = ">=41.0.0" +six = ">1.9" +tensorboard-data-server = ">=0.7.0,<0.8.0" +werkzeug = ">=1.0.1" + +[[package]] +name = "tensorboard-data-server" +version = "0.7.2" +description = "Fast data loading for TensorBoard" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tensorboard_data_server-0.7.2-py3-none-any.whl", hash = "sha256:7e0610d205889588983836ec05dc098e80f97b7e7bbff7e994ebb78f578d0ddb"}, + {file = "tensorboard_data_server-0.7.2-py3-none-macosx_10_9_x86_64.whl", hash = "sha256:9fe5d24221b29625dbc7328b0436ca7fc1c23de4acf4d272f1180856e32f9f60"}, + {file = "tensorboard_data_server-0.7.2-py3-none-manylinux_2_31_x86_64.whl", hash = "sha256:ef687163c24185ae9754ed5650eb5bc4d84ff257aabdc33f0cc6f74d8ba54530"}, +] [[package]] name = "threadpoolctl" version = "3.2.0" description = "threadpoolctl" -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "threadpoolctl-3.2.0-py3-none-any.whl", hash = "sha256:2b7818516e423bdaebb97c723f86a7c6b0a83d3f3b0970328d66f4d9104dc032"}, + {file = "threadpoolctl-3.2.0.tar.gz", hash = "sha256:c96a0ba3bdddeaca37dc4cc7344aafad41cdb8c313f74fdfe387a867bba93355"}, +] [[package]] name = "toml" version = "0.10.2" description = "Python Library for Tom's Obvious, Minimal Language" -category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, + {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, +] [[package]] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] [[package]] name = "torch" version = "1.12.1" description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" -category = "main" optional = false python-versions = ">=3.7.0" +files = [ + {file = "torch-1.12.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:9c038662db894a23e49e385df13d47b2a777ffd56d9bcd5b832593fab0a7e286"}, + {file = "torch-1.12.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:4e1b9c14cf13fd2ab8d769529050629a0e68a6fc5cb8e84b4a3cc1dd8c4fe541"}, + {file = "torch-1.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:e9c8f4a311ac29fc7e8e955cfb7733deb5dbe1bdaabf5d4af2765695824b7e0d"}, + {file = "torch-1.12.1-cp310-none-macosx_10_9_x86_64.whl", hash = "sha256:976c3f997cea38ee91a0dd3c3a42322785414748d1761ef926b789dfa97c6134"}, + {file = "torch-1.12.1-cp310-none-macosx_11_0_arm64.whl", hash = "sha256:68104e4715a55c4bb29a85c6a8d57d820e0757da363be1ba680fa8cc5be17b52"}, + {file = "torch-1.12.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:743784ccea0dc8f2a3fe6a536bec8c4763bd82c1352f314937cb4008d4805de1"}, + {file = "torch-1.12.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b5dbcca369800ce99ba7ae6dee3466607a66958afca3b740690d88168752abcf"}, + {file = "torch-1.12.1-cp37-cp37m-win_amd64.whl", hash = "sha256:f3b52a634e62821e747e872084ab32fbcb01b7fa7dbb7471b6218279f02a178a"}, + {file = "torch-1.12.1-cp37-none-macosx_10_9_x86_64.whl", hash = "sha256:8a34a2fbbaa07c921e1b203f59d3d6e00ed379f2b384445773bd14e328a5b6c8"}, + {file = "torch-1.12.1-cp37-none-macosx_11_0_arm64.whl", hash = "sha256:42f639501928caabb9d1d55ddd17f07cd694de146686c24489ab8c615c2871f2"}, + {file = "torch-1.12.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:0b44601ec56f7dd44ad8afc00846051162ef9c26a8579dda0a02194327f2d55e"}, + {file = "torch-1.12.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:cd26d8c5640c3a28c526d41ccdca14cf1cbca0d0f2e14e8263a7ac17194ab1d2"}, + {file = "torch-1.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:42e115dab26f60c29e298559dbec88444175528b729ae994ec4c65d56fe267dd"}, + {file = "torch-1.12.1-cp38-none-macosx_10_9_x86_64.whl", hash = "sha256:a8320ba9ad87e80ca5a6a016e46ada4d1ba0c54626e135d99b2129a4541c509d"}, + {file = "torch-1.12.1-cp38-none-macosx_11_0_arm64.whl", hash = "sha256:03e31c37711db2cd201e02de5826de875529e45a55631d317aadce2f1ed45aa8"}, + {file = "torch-1.12.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:9b356aea223772cd754edb4d9ecf2a025909b8615a7668ac7d5130f86e7ec421"}, + {file = "torch-1.12.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:6cf6f54b43c0c30335428195589bd00e764a6d27f3b9ba637aaa8c11aaf93073"}, + {file = "torch-1.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:f00c721f489089dc6364a01fd84906348fe02243d0af737f944fddb36003400d"}, + {file = "torch-1.12.1-cp39-none-macosx_10_9_x86_64.whl", hash = "sha256:bfec2843daa654f04fda23ba823af03e7b6f7650a873cdb726752d0e3718dada"}, + {file = "torch-1.12.1-cp39-none-macosx_11_0_arm64.whl", hash = "sha256:69fe2cae7c39ccadd65a123793d30e0db881f1c1927945519c5c17323131437e"}, +] [package.dependencies] typing-extensions = "*" @@ -574,9 +1703,12 @@ typing-extensions = "*" name = "torchmetrics" version = "0.10.3" description = "PyTorch native Metrics" -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "torchmetrics-0.10.3-py3-none-any.whl", hash = "sha256:b12cf92897545e24a825b0d168888c0f3052700c2901e2d4f7d90b252bc4a343"}, + {file = "torchmetrics-0.10.3.tar.gz", hash = "sha256:9e6ab66175f2dc13e246c37485b2c27c77931dfe47fc2b81c76217b8efdc1e57"}, +] [package.dependencies] numpy = ">=1.17.2" @@ -590,20 +1722,40 @@ detection = ["pycocotools", "torchvision (>=0.8)"] docs = ["docutils (>=0.16)", "myst-parser", "nbsphinx (>=0.8)", "pandoc (>=1.0)", "sphinx (>=4.0,<5.0)", "sphinx-autodoc-typehints (>=1.0)", "sphinx-copybutton (>=0.3)", "sphinx-paramlinks (>=0.5.1)", "sphinx-togglebutton (>=0.2)", "sphinxcontrib-fulltoc (>=1.0)", "sphinxcontrib-mockautodoc"] image = ["lpips", "scipy", "torch-fidelity", "torchvision"] integrate = ["pytorch-lightning (>=1.5)"] -test = ["bert-score (==0.3.10)", "check-manifest", "cloudpickle (>=1.3)", "coverage (>5.2)", "fast-bss-eval (>=0.1.0)", "fire", "huggingface-hub (<0.7)", "jiwer (>=2.3.0)", "mir-eval (>=0.6)", "netcal", "phmdoctest (>=1.1.1)", "pre-commit (>=1.0)", "psutil", "pycocotools", "pypesq (>1.2)", "pytest (>=6.0.0,<7.0.0)", "pytest-cov (>2.10)", "pytest-doctestplus (>=0.9.0)", "pytest-timeout", "pytorch-msssim (==0.2.1)", "requests", "rouge-score (>=0.0.4)", "sacrebleu (>=2.0.0)", "scikit-image (>0.17.1)", "scikit-learn (>1.0,<1.1.1)", "torch-complex", "transformers (>=4.0)"] +test = ["bert-score (==0.3.10)", "check-manifest", "cloudpickle (>=1.3)", "coverage (>5.2)", "fast-bss-eval (>=0.1.0)", "fire", "huggingface-hub (<0.7)", "jiwer (>=2.3.0)", "mir-eval (>=0.6)", "netcal", "phmdoctest (>=1.1.1)", "pre-commit (>=1.0)", "psutil", "pycocotools", "pypesq (>1.2)", "pytest (==6.*)", "pytest-cov (>2.10)", "pytest-doctestplus (>=0.9.0)", "pytest-timeout", "pytorch-msssim (==0.2.1)", "requests", "rouge-score (>=0.0.4)", "sacrebleu (>=2.0.0)", "scikit-image (>0.17.1)", "scikit-learn (>1.0,<1.1.1)", "torch-complex", "transformers (>=4.0)"] text = ["nltk (>=3.6)", "regex (>=2021.9.24)", "tqdm (>=4.41.0)"] [[package]] name = "torchvision" version = "0.13.1" description = "image and video datasets and models for torch deep learning" -category = "main" optional = false python-versions = ">=3.7" - -[package.dependencies] +files = [ + {file = "torchvision-0.13.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:19286a733c69dcbd417b86793df807bd227db5786ed787c17297741a9b0d0fc7"}, + {file = "torchvision-0.13.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:08f592ea61836ebeceb5c97f4d7a813b9d7dc651bbf7ce4401563ccfae6a21fc"}, + {file = "torchvision-0.13.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:ef5fe3ec1848123cd0ec74c07658192b3147dcd38e507308c790d5943e87b88c"}, + {file = "torchvision-0.13.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:099874088df104d54d8008f2a28539ca0117b512daed8bf3c2bbfa2b7ccb187a"}, + {file = "torchvision-0.13.1-cp310-cp310-win_amd64.whl", hash = "sha256:8e4d02e4d8a203e0c09c10dfb478214c224d080d31efc0dbf36d9c4051f7f3c6"}, + {file = "torchvision-0.13.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5e631241bee3661de64f83616656224af2e3512eb2580da7c08e08b8c965a8ac"}, + {file = "torchvision-0.13.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:899eec0b9f3b99b96d6f85b9aa58c002db41c672437677b553015b9135b3be7e"}, + {file = "torchvision-0.13.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:83e9e2457f23110fd53b0177e1bc621518d6ea2108f570e853b768ce36b7c679"}, + {file = "torchvision-0.13.1-cp37-cp37m-win_amd64.whl", hash = "sha256:7552e80fa222252b8b217a951c85e172a710ea4cad0ae0c06fbb67addece7871"}, + {file = "torchvision-0.13.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f230a1a40ed70d51e463ce43df243ec520902f8725de2502e485efc5eea9d864"}, + {file = "torchvision-0.13.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e9a563894f9fa40692e24d1aa58c3ef040450017cfed3598ff9637f404f3fe3b"}, + {file = "torchvision-0.13.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7cb789ceefe6dcd0dc8eeda37bfc45efb7cf34770eac9533861d51ca508eb5b3"}, + {file = "torchvision-0.13.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:87c137f343197769a51333076e66bfcd576301d2cd8614b06657187c71b06c4f"}, + {file = "torchvision-0.13.1-cp38-cp38-win_amd64.whl", hash = "sha256:4d8bf321c4380854ef04613935fdd415dce29d1088a7ff99e06e113f0efe9203"}, + {file = "torchvision-0.13.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0298bae3b09ac361866088434008d82b99d6458fe8888c8df90720ef4b347d44"}, + {file = "torchvision-0.13.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c5ed609c8bc88c575226400b2232e0309094477c82af38952e0373edef0003fd"}, + {file = "torchvision-0.13.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:3567fb3def829229ec217c1e38f08c5128ff7fb65854cac17ebac358ff7aa309"}, + {file = "torchvision-0.13.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b167934a5943242da7b1e59318f911d2d253feeca0d13ad5d832b58eed943401"}, + {file = "torchvision-0.13.1-cp39-cp39-win_amd64.whl", hash = "sha256:0e77706cc90462653620e336bb90daf03d7bf1b88c3a9a3037df8d111823a56e"}, +] + +[package.dependencies] numpy = "*" -pillow = ">=5.3.0,<8.3.0 || >=8.4.0" +pillow = ">=5.3.0,<8.3.dev0 || >=8.4.dev0" requests = "*" torch = "1.12.1" typing-extensions = "*" @@ -615,9 +1767,12 @@ scipy = ["scipy"] name = "tqdm" version = "4.66.1" description = "Fast, Extensible Progress Meter" -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "tqdm-4.66.1-py3-none-any.whl", hash = "sha256:d302b3c5b53d47bce91fea46679d9c3c6508cf6332229aa1e7d8653723793386"}, + {file = "tqdm-4.66.1.tar.gz", hash = "sha256:d88e651f9db8d8551a62556d3cff9e3034274ca5d66e93197cf2490e2dcb69c7"}, +] [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} @@ -632,30 +1787,56 @@ telegram = ["requests"] name = "typing-extensions" version = "4.9.0" description = "Backported and Experimental Type Hints for Python 3.8+" -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, + {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, +] [[package]] name = "urllib3" version = "2.1.0" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "urllib3-2.1.0-py3-none-any.whl", hash = "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3"}, + {file = "urllib3-2.1.0.tar.gz", hash = "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54"}, +] [package.extras] brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] +[[package]] +name = "werkzeug" +version = "3.0.1" +description = "The comprehensive WSGI web application library." +optional = false +python-versions = ">=3.8" +files = [ + {file = "werkzeug-3.0.1-py3-none-any.whl", hash = "sha256:90a285dc0e42ad56b34e696398b8122ee4c681833fb35b8334a095d82c56da10"}, + {file = "werkzeug-3.0.1.tar.gz", hash = "sha256:507e811ecea72b18a404947aded4b3390e1db8f826b494d76550ef45bb3b1dcc"}, +] + +[package.dependencies] +MarkupSafe = ">=2.1.1" + +[package.extras] +watchdog = ["watchdog (>=2.3)"] + [[package]] name = "where" version = "1.0.2" description = "Locates absolute file paths like the Windows 'where' or the Linux 'which' utility.\nMakes use of the PATH variable and the current directory." -category = "dev" optional = false python-versions = "*" +files = [ + {file = "where-1.0.2-py2.py3-none-any.whl", hash = "sha256:66abc8edf95be7516e949d08a771f25acacff708ef481618562ab484fe5bc63e"}, + {file = "where-1.0.2.zip", hash = "sha256:325ef3a492a26189a47819f7375bc146887d39edd36fce132e86514334803fb1"}, +] [package.dependencies] itermate = "1.0.2" @@ -664,824 +1845,18 @@ itermate = "1.0.2" name = "zipp" version = "3.17.0" description = "Backport of pathlib-compatible object wrapper for zip files" -category = "main" optional = false python-versions = ">=3.8" +files = [ + {file = "zipp-3.17.0-py3-none-any.whl", hash = "sha256:0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31"}, + {file = "zipp-3.17.0.tar.gz", hash = "sha256:84e64a1c28cf7e91ed2078bb8cc8c259cb19b76942096c8d7b84947690cabaf0"}, +] [package.extras] docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] [metadata] -lock-version = "1.1" +lock-version = "2.0" python-versions = "^3.9" -content-hash = "0c4a82b3972427fc7b1dc3f446e952ae46078d677fa57a8058b41106157c92d2" - -[metadata.files] -atomicwrites = [ - {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, -] -attrs = [ - {file = "attrs-23.1.0-py3-none-any.whl", hash = "sha256:1f28b4522cdc2fb4256ac1a020c78acf9cba2c6b461ccd2c126f3aa8e8335d04"}, - {file = "attrs-23.1.0.tar.gz", hash = "sha256:6279836d581513a26f1bf235f9acd333bc9115683f14f7e8fae46c98fc50e015"}, -] -beautifulsoup4 = [ - {file = "beautifulsoup4-4.12.2-py3-none-any.whl", hash = "sha256:bd2520ca0d9d7d12694a53d44ac482d181b4ec1888909b035a3dbf40d0f57d4a"}, - {file = "beautifulsoup4-4.12.2.tar.gz", hash = "sha256:492bbc69dca35d12daac71c4db1bfff0c876c00ef4a2ffacce226d4638eb72da"}, -] -certifi = [ - {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, - {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, -] -charset-normalizer = [ - {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-win32.whl", hash = "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73"}, - {file = "charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-win32.whl", hash = "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab"}, - {file = "charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-win32.whl", hash = "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7"}, - {file = "charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-win32.whl", hash = "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4"}, - {file = "charset_normalizer-3.3.2-cp37-cp37m-win_amd64.whl", hash = "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-win32.whl", hash = "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25"}, - {file = "charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-win32.whl", hash = "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f"}, - {file = "charset_normalizer-3.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d"}, - {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"}, -] -colorama = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] -contourpy = [ - {file = "contourpy-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0274c1cb63625972c0c007ab14dd9ba9e199c36ae1a231ce45d725cbcbfd10a8"}, - {file = "contourpy-1.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ab459a1cbbf18e8698399c595a01f6dcc5c138220ca3ea9e7e6126232d102bb4"}, - {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fdd887f17c2f4572ce548461e4f96396681212d858cae7bd52ba3310bc6f00f"}, - {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5d16edfc3fc09968e09ddffada434b3bf989bf4911535e04eada58469873e28e"}, - {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1c203f617abc0dde5792beb586f827021069fb6d403d7f4d5c2b543d87edceb9"}, - {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b69303ceb2e4d4f146bf82fda78891ef7bcd80c41bf16bfca3d0d7eb545448aa"}, - {file = "contourpy-1.2.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:884c3f9d42d7218304bc74a8a7693d172685c84bd7ab2bab1ee567b769696df9"}, - {file = "contourpy-1.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4a1b1208102be6e851f20066bf0e7a96b7d48a07c9b0cfe6d0d4545c2f6cadab"}, - {file = "contourpy-1.2.0-cp310-cp310-win32.whl", hash = "sha256:34b9071c040d6fe45d9826cbbe3727d20d83f1b6110d219b83eb0e2a01d79488"}, - {file = "contourpy-1.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:bd2f1ae63998da104f16a8b788f685e55d65760cd1929518fd94cd682bf03e41"}, - {file = "contourpy-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:dd10c26b4eadae44783c45ad6655220426f971c61d9b239e6f7b16d5cdaaa727"}, - {file = "contourpy-1.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5c6b28956b7b232ae801406e529ad7b350d3f09a4fde958dfdf3c0520cdde0dd"}, - {file = "contourpy-1.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ebeac59e9e1eb4b84940d076d9f9a6cec0064e241818bcb6e32124cc5c3e377a"}, - {file = "contourpy-1.2.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:139d8d2e1c1dd52d78682f505e980f592ba53c9f73bd6be102233e358b401063"}, - {file = "contourpy-1.2.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1e9dc350fb4c58adc64df3e0703ab076f60aac06e67d48b3848c23647ae4310e"}, - {file = "contourpy-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18fc2b4ed8e4a8fe849d18dce4bd3c7ea637758c6343a1f2bae1e9bd4c9f4686"}, - {file = "contourpy-1.2.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:16a7380e943a6d52472096cb7ad5264ecee36ed60888e2a3d3814991a0107286"}, - {file = "contourpy-1.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8d8faf05be5ec8e02a4d86f616fc2a0322ff4a4ce26c0f09d9f7fb5330a35c95"}, - {file = "contourpy-1.2.0-cp311-cp311-win32.whl", hash = "sha256:67b7f17679fa62ec82b7e3e611c43a016b887bd64fb933b3ae8638583006c6d6"}, - {file = "contourpy-1.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:99ad97258985328b4f207a5e777c1b44a83bfe7cf1f87b99f9c11d4ee477c4de"}, - {file = "contourpy-1.2.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:575bcaf957a25d1194903a10bc9f316c136c19f24e0985a2b9b5608bdf5dbfe0"}, - {file = "contourpy-1.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9e6c93b5b2dbcedad20a2f18ec22cae47da0d705d454308063421a3b290d9ea4"}, - {file = "contourpy-1.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:464b423bc2a009088f19bdf1f232299e8b6917963e2b7e1d277da5041f33a779"}, - {file = "contourpy-1.2.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:68ce4788b7d93e47f84edd3f1f95acdcd142ae60bc0e5493bfd120683d2d4316"}, - {file = "contourpy-1.2.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d7d1f8871998cdff5d2ff6a087e5e1780139abe2838e85b0b46b7ae6cc25399"}, - {file = "contourpy-1.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e739530c662a8d6d42c37c2ed52a6f0932c2d4a3e8c1f90692ad0ce1274abe0"}, - {file = "contourpy-1.2.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:247b9d16535acaa766d03037d8e8fb20866d054d3c7fbf6fd1f993f11fc60ca0"}, - {file = "contourpy-1.2.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:461e3ae84cd90b30f8d533f07d87c00379644205b1d33a5ea03381edc4b69431"}, - {file = "contourpy-1.2.0-cp312-cp312-win32.whl", hash = "sha256:1c2559d6cffc94890b0529ea7eeecc20d6fadc1539273aa27faf503eb4656d8f"}, - {file = "contourpy-1.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:491b1917afdd8638a05b611a56d46587d5a632cabead889a5440f7c638bc6ed9"}, - {file = "contourpy-1.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5fd1810973a375ca0e097dee059c407913ba35723b111df75671a1976efa04bc"}, - {file = "contourpy-1.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:999c71939aad2780f003979b25ac5b8f2df651dac7b38fb8ce6c46ba5abe6ae9"}, - {file = "contourpy-1.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b7caf9b241464c404613512d5594a6e2ff0cc9cb5615c9475cc1d9b514218ae8"}, - {file = "contourpy-1.2.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:266270c6f6608340f6c9836a0fb9b367be61dde0c9a9a18d5ece97774105ff3e"}, - {file = "contourpy-1.2.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbd50d0a0539ae2e96e537553aff6d02c10ed165ef40c65b0e27e744a0f10af8"}, - {file = "contourpy-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:11f8d2554e52f459918f7b8e6aa20ec2a3bce35ce95c1f0ef4ba36fbda306df5"}, - {file = "contourpy-1.2.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ce96dd400486e80ac7d195b2d800b03e3e6a787e2a522bfb83755938465a819e"}, - {file = "contourpy-1.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6d3364b999c62f539cd403f8123ae426da946e142312a514162adb2addd8d808"}, - {file = "contourpy-1.2.0-cp39-cp39-win32.whl", hash = "sha256:1c88dfb9e0c77612febebb6ac69d44a8d81e3dc60f993215425b62c1161353f4"}, - {file = "contourpy-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:78e6ad33cf2e2e80c5dfaaa0beec3d61face0fb650557100ee36db808bfa6843"}, - {file = "contourpy-1.2.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:be16975d94c320432657ad2402f6760990cb640c161ae6da1363051805fa8108"}, - {file = "contourpy-1.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b95a225d4948b26a28c08307a60ac00fb8671b14f2047fc5476613252a129776"}, - {file = "contourpy-1.2.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:0d7e03c0f9a4f90dc18d4e77e9ef4ec7b7bbb437f7f675be8e530d65ae6ef956"}, - {file = "contourpy-1.2.0.tar.gz", hash = "sha256:171f311cb758de7da13fc53af221ae47a5877be5a0843a9fe150818c51ed276a"}, -] -coverage = [ - {file = "coverage-7.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36b0ea8ab20d6a7564e89cb6135920bc9188fb5f1f7152e94e8300b7b189441a"}, - {file = "coverage-7.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0676cd0ba581e514b7f726495ea75aba3eb20899d824636c6f59b0ed2f88c471"}, - {file = "coverage-7.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0ca5c71a5a1765a0f8f88022c52b6b8be740e512980362f7fdbb03725a0d6b9"}, - {file = "coverage-7.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a7c97726520f784239f6c62506bc70e48d01ae71e9da128259d61ca5e9788516"}, - {file = "coverage-7.4.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:815ac2d0f3398a14286dc2cea223a6f338109f9ecf39a71160cd1628786bc6f5"}, - {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:80b5ee39b7f0131ebec7968baa9b2309eddb35b8403d1869e08f024efd883566"}, - {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:5b2ccb7548a0b65974860a78c9ffe1173cfb5877460e5a229238d985565574ae"}, - {file = "coverage-7.4.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:995ea5c48c4ebfd898eacb098164b3cc826ba273b3049e4a889658548e321b43"}, - {file = "coverage-7.4.0-cp310-cp310-win32.whl", hash = "sha256:79287fd95585ed36e83182794a57a46aeae0b64ca53929d1176db56aacc83451"}, - {file = "coverage-7.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:5b14b4f8760006bfdb6e08667af7bc2d8d9bfdb648351915315ea17645347137"}, - {file = "coverage-7.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:04387a4a6ecb330c1878907ce0dc04078ea72a869263e53c72a1ba5bbdf380ca"}, - {file = "coverage-7.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ea81d8f9691bb53f4fb4db603203029643caffc82bf998ab5b59ca05560f4c06"}, - {file = "coverage-7.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74775198b702868ec2d058cb92720a3c5a9177296f75bd97317c787daf711505"}, - {file = "coverage-7.4.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:76f03940f9973bfaee8cfba70ac991825611b9aac047e5c80d499a44079ec0bc"}, - {file = "coverage-7.4.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:485e9f897cf4856a65a57c7f6ea3dc0d4e6c076c87311d4bc003f82cfe199d25"}, - {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6ae8c9d301207e6856865867d762a4b6fd379c714fcc0607a84b92ee63feff70"}, - {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bf477c355274a72435ceb140dc42de0dc1e1e0bf6e97195be30487d8eaaf1a09"}, - {file = "coverage-7.4.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:83c2dda2666fe32332f8e87481eed056c8b4d163fe18ecc690b02802d36a4d26"}, - {file = "coverage-7.4.0-cp311-cp311-win32.whl", hash = "sha256:697d1317e5290a313ef0d369650cfee1a114abb6021fa239ca12b4849ebbd614"}, - {file = "coverage-7.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:26776ff6c711d9d835557ee453082025d871e30b3fd6c27fcef14733f67f0590"}, - {file = "coverage-7.4.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:13eaf476ec3e883fe3e5fe3707caeb88268a06284484a3daf8250259ef1ba143"}, - {file = "coverage-7.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:846f52f46e212affb5bcf131c952fb4075b55aae6b61adc9856222df89cbe3e2"}, - {file = "coverage-7.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:26f66da8695719ccf90e794ed567a1549bb2644a706b41e9f6eae6816b398c4a"}, - {file = "coverage-7.4.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:164fdcc3246c69a6526a59b744b62e303039a81e42cfbbdc171c91a8cc2f9446"}, - {file = "coverage-7.4.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:316543f71025a6565677d84bc4df2114e9b6a615aa39fb165d697dba06a54af9"}, - {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:bb1de682da0b824411e00a0d4da5a784ec6496b6850fdf8c865c1d68c0e318dd"}, - {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:0e8d06778e8fbffccfe96331a3946237f87b1e1d359d7fbe8b06b96c95a5407a"}, - {file = "coverage-7.4.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a56de34db7b7ff77056a37aedded01b2b98b508227d2d0979d373a9b5d353daa"}, - {file = "coverage-7.4.0-cp312-cp312-win32.whl", hash = "sha256:51456e6fa099a8d9d91497202d9563a320513fcf59f33991b0661a4a6f2ad450"}, - {file = "coverage-7.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:cd3c1e4cb2ff0083758f09be0f77402e1bdf704adb7f89108007300a6da587d0"}, - {file = "coverage-7.4.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e9d1bf53c4c8de58d22e0e956a79a5b37f754ed1ffdbf1a260d9dcfa2d8a325e"}, - {file = "coverage-7.4.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:109f5985182b6b81fe33323ab4707011875198c41964f014579cf82cebf2bb85"}, - {file = "coverage-7.4.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3cc9d4bc55de8003663ec94c2f215d12d42ceea128da8f0f4036235a119c88ac"}, - {file = "coverage-7.4.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cc6d65b21c219ec2072c1293c505cf36e4e913a3f936d80028993dd73c7906b1"}, - {file = "coverage-7.4.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5a10a4920def78bbfff4eff8a05c51be03e42f1c3735be42d851f199144897ba"}, - {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b8e99f06160602bc64da35158bb76c73522a4010f0649be44a4e167ff8555952"}, - {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:7d360587e64d006402b7116623cebf9d48893329ef035278969fa3bbf75b697e"}, - {file = "coverage-7.4.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:29f3abe810930311c0b5d1a7140f6395369c3db1be68345638c33eec07535105"}, - {file = "coverage-7.4.0-cp38-cp38-win32.whl", hash = "sha256:5040148f4ec43644702e7b16ca864c5314ccb8ee0751ef617d49aa0e2d6bf4f2"}, - {file = "coverage-7.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:9864463c1c2f9cb3b5db2cf1ff475eed2f0b4285c2aaf4d357b69959941aa555"}, - {file = "coverage-7.4.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:936d38794044b26c99d3dd004d8af0035ac535b92090f7f2bb5aa9c8e2f5cd42"}, - {file = "coverage-7.4.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:799c8f873794a08cdf216aa5d0531c6a3747793b70c53f70e98259720a6fe2d7"}, - {file = "coverage-7.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e7defbb9737274023e2d7af02cac77043c86ce88a907c58f42b580a97d5bcca9"}, - {file = "coverage-7.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a1526d265743fb49363974b7aa8d5899ff64ee07df47dd8d3e37dcc0818f09ed"}, - {file = "coverage-7.4.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bf635a52fc1ea401baf88843ae8708591aa4adff875e5c23220de43b1ccf575c"}, - {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:756ded44f47f330666843b5781be126ab57bb57c22adbb07d83f6b519783b870"}, - {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:0eb3c2f32dabe3a4aaf6441dde94f35687224dfd7eb2a7f47f3fd9428e421058"}, - {file = "coverage-7.4.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:bfd5db349d15c08311702611f3dccbef4b4e2ec148fcc636cf8739519b4a5c0f"}, - {file = "coverage-7.4.0-cp39-cp39-win32.whl", hash = "sha256:53d7d9158ee03956e0eadac38dfa1ec8068431ef8058fe6447043db1fb40d932"}, - {file = "coverage-7.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:cfd2a8b6b0d8e66e944d47cdec2f47c48fef2ba2f2dff5a9a75757f64172857e"}, - {file = "coverage-7.4.0-pp38.pp39.pp310-none-any.whl", hash = "sha256:c530833afc4707fe48524a44844493f36d8727f04dcce91fb978c414a8556cc6"}, - {file = "coverage-7.4.0.tar.gz", hash = "sha256:707c0f58cb1712b8809ece32b68996ee1e609f71bd14615bd8f87a1293cb610e"}, -] -cycler = [ - {file = "cycler-0.12.1-py3-none-any.whl", hash = "sha256:85cef7cff222d8644161529808465972e51340599459b8ac3ccbac5a854e0d30"}, - {file = "cycler-0.12.1.tar.gz", hash = "sha256:88bb128f02ba341da8ef447245a9e138fae777f6a23943da4540077d3601eb1c"}, -] -filelock = [ - {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, - {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, -] -fonttools = [ - {file = "fonttools-4.46.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d4e69e2c7f93b695d2e6f18f709d501d945f65c1d237dafaabdd23cd935a5276"}, - {file = "fonttools-4.46.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:25852f0c63df0af022f698464a4a80f7d1d5bd974bcd22f995f6b4ad198e32dd"}, - {file = "fonttools-4.46.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:adab73618d0a328b203a0e242b3eba60a2b5662d9cb2bd16ed9c52af8a7d86af"}, - {file = "fonttools-4.46.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2cf923a4a556ab4cc4c52f69a4a2db624cf5a2cf360394368b40c5152fe3321e"}, - {file = "fonttools-4.46.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:87c214197712cc14fd2a4621efce2a9c501a77041232b789568149a8a3161517"}, - {file = "fonttools-4.46.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:156ae342a1ed1fe38e180de471e98fbf5b2b6ae280fa3323138569c4ca215844"}, - {file = "fonttools-4.46.0-cp310-cp310-win32.whl", hash = "sha256:c506e3d3a9e898caee4dc094f34b49c5566870d5a2d1ca2125f0a9f35ecc2205"}, - {file = "fonttools-4.46.0-cp310-cp310-win_amd64.whl", hash = "sha256:f8bc3973ed58893c4107993e0a7ae34901cb572b5e798249cbef35d30801ffd4"}, - {file = "fonttools-4.46.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:982f69855ac258260f51048d9e0c53c5f19881138cc7ca06deb38dc4b97404b6"}, - {file = "fonttools-4.46.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2c23c59d321d62588620f2255cf951270bf637d88070f38ed8b5e5558775b86c"}, - {file = "fonttools-4.46.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0e94244ec24a940ecfbe5b31c975c8a575d5ed2d80f9a280ce3b21fa5dc9c34"}, - {file = "fonttools-4.46.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a9f9cdd7ef63d1b8ac90db335762451452426b3207abd79f60da510cea62da5"}, - {file = "fonttools-4.46.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ca9eceebe70035b057ce549e2054cad73e95cac3fe91a9d827253d1c14618204"}, - {file = "fonttools-4.46.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8be6adfa4e15977075278dd0a0bae74dec59be7b969b5ceed93fb86af52aa5be"}, - {file = "fonttools-4.46.0-cp311-cp311-win32.whl", hash = "sha256:7b5636f5706d49f13b6d610fe54ee662336cdf56b5a6f6683c0b803e23d826d2"}, - {file = "fonttools-4.46.0-cp311-cp311-win_amd64.whl", hash = "sha256:49ea0983e55fd7586a809787cd4644a7ae471e53ab8ddc016f9093b400e32646"}, - {file = "fonttools-4.46.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:7b460720ce81773da1a3e7cc964c48e1e11942b280619582a897fa0117b56a62"}, - {file = "fonttools-4.46.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:8bee9f4fc8c99824a424ae45c789ee8c67cb84f8e747afa7f83b7d3cef439c3b"}, - {file = "fonttools-4.46.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3d7b96aba96e05e8c911ce2dfc5acc6a178b8f44f6aa69371ab91aa587563da"}, - {file = "fonttools-4.46.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e6aeb5c340416d11a3209d75c48d13e72deea9e1517837dd1522c1fd1f17c11"}, - {file = "fonttools-4.46.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c779f8701deedf41908f287aeb775b8a6f59875ad1002b98ac6034ae4ddc1b7b"}, - {file = "fonttools-4.46.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ce199227ce7921eaafdd4f96536f16b232d6b580ce74ce337de544bf06cb2752"}, - {file = "fonttools-4.46.0-cp312-cp312-win32.whl", hash = "sha256:1c9937c4dd1061afd22643389445fabda858af5e805860ec3082a4bc07c7a720"}, - {file = "fonttools-4.46.0-cp312-cp312-win_amd64.whl", hash = "sha256:a9fa52ef8fd14d7eb3d813e1451e7ace3e1eebfa9b7237d3f81fee8f3de6a114"}, - {file = "fonttools-4.46.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:c94564b1f3b5dd87e73577610d85115b1936edcc596deaf84a31bbe70e17456b"}, - {file = "fonttools-4.46.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a4a50a1dfad7f7ba5ca3f99cc73bf5cdac67ceade8e4b355a877521f20ad1b63"}, - {file = "fonttools-4.46.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:89c2c520f9492844ecd6316d20c6c7a157b5c0cb73a1411b3db28ee304f30122"}, - {file = "fonttools-4.46.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e5b7905fd68eacb7cc56a13139da5c312c45baae6950dd00b02563c54508a041"}, - {file = "fonttools-4.46.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:8485cc468288e213f31afdaf1fdda3c79010f542559fbba936a54f4644df2570"}, - {file = "fonttools-4.46.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:87c3299da7da55394fb324349db0ede38114a46aafd0e7dfcabfecd28cdd94c3"}, - {file = "fonttools-4.46.0-cp38-cp38-win32.whl", hash = "sha256:f5f1423a504ccc329efb5aa79738de83d38c072be5308788dde6bd419969d7f5"}, - {file = "fonttools-4.46.0-cp38-cp38-win_amd64.whl", hash = "sha256:6d4a4ebcc76e30898ff3296ea786491c70e183f738319ae2629e0d44f17ece42"}, - {file = "fonttools-4.46.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c9a0e422ab79e5cb2b47913be6a4b5fd20c4c7ac34a24f3691a4e099e965e0b8"}, - {file = "fonttools-4.46.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:13ac0cba2fc63fa4b232f2a7971f35f35c6eaf10bd1271fa96d4ce6253a8acfd"}, - {file = "fonttools-4.46.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:795150d5edc595e1a2cfb3d65e8f4f3d027704fc2579f8990d381bef6b188eb6"}, - {file = "fonttools-4.46.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d00fc63131dcac6b25f50a5a129758438317e54e3ce5587163f7058de4b0e933"}, - {file = "fonttools-4.46.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:3033b55f401a622de2630b3982234d97219d89b058607b87927eccb0f922313c"}, - {file = "fonttools-4.46.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:e26e7fb908ae4f622813e7cb32cd2db6c24e3122bb3b98f25e832a2fe0e7e228"}, - {file = "fonttools-4.46.0-cp39-cp39-win32.whl", hash = "sha256:2d0eba685938c603f2f648dfc0aadbf8c6a4fe1c7ca608c2970a6ef39e00f254"}, - {file = "fonttools-4.46.0-cp39-cp39-win_amd64.whl", hash = "sha256:5200b01f463d97cc2b7ff8a1e3584151f4413e98cb8419da5f17d1dbb84cc214"}, - {file = "fonttools-4.46.0-py3-none-any.whl", hash = "sha256:5b627ed142398ea9202bd752c04311592558964d1a765fb2f78dc441a05633f4"}, - {file = "fonttools-4.46.0.tar.gz", hash = "sha256:2ae45716c27a41807d58a9f3f59983bdc8c0a46cb259e4450ab7e196253a9853"}, -] -gdown = [ - {file = "gdown-4.7.1-py3-none-any.whl", hash = "sha256:65d495699e7c2c61af0d0e9c32748fb4f79abaf80d747a87456c7be14aac2560"}, - {file = "gdown-4.7.1.tar.gz", hash = "sha256:347f23769679aaf7efa73e5655270fcda8ca56be65eb84a4a21d143989541045"}, -] -idna = [ - {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, - {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, -] -importlib-resources = [ - {file = "importlib_resources-6.1.1-py3-none-any.whl", hash = "sha256:e8bf90d8213b486f428c9c39714b920041cb02c184686a3dee24905aaa8105d6"}, - {file = "importlib_resources-6.1.1.tar.gz", hash = "sha256:3893a00122eafde6894c59914446a512f728a0c1a45f9bb9b63721b6bacf0b4a"}, -] -iniconfig = [ - {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, - {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, -] -itermate = [ - {file = "itermate-1.0.2-py2-none-any.whl", hash = "sha256:00308991e0fe54465e0e0fbec4d47180b4f6df0f26c1e5d2ce3641e3373f28a0"}, - {file = "itermate-1.0.2.zip", hash = "sha256:5ee758cbb363493156cee7a29effc2b148a1a19d2be3097e92fc824991901e2a"}, -] -joblib = [ - {file = "joblib-1.3.2-py3-none-any.whl", hash = "sha256:ef4331c65f239985f3f2220ecc87db222f08fd22097a3dd5698f693875f8cbb9"}, - {file = "joblib-1.3.2.tar.gz", hash = "sha256:92f865e621e17784e7955080b6d042489e3b8e294949cc44c6eac304f59772b1"}, -] -kiwisolver = [ - {file = "kiwisolver-1.4.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:05703cf211d585109fcd72207a31bb170a0f22144d68298dc5e61b3c946518af"}, - {file = "kiwisolver-1.4.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:146d14bebb7f1dc4d5fbf74f8a6cb15ac42baadee8912eb84ac0b3b2a3dc6ac3"}, - {file = "kiwisolver-1.4.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6ef7afcd2d281494c0a9101d5c571970708ad911d028137cd558f02b851c08b4"}, - {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:9eaa8b117dc8337728e834b9c6e2611f10c79e38f65157c4c38e9400286f5cb1"}, - {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:ec20916e7b4cbfb1f12380e46486ec4bcbaa91a9c448b97023fde0d5bbf9e4ff"}, - {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:39b42c68602539407884cf70d6a480a469b93b81b7701378ba5e2328660c847a"}, - {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aa12042de0171fad672b6c59df69106d20d5596e4f87b5e8f76df757a7c399aa"}, - {file = "kiwisolver-1.4.5-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2a40773c71d7ccdd3798f6489aaac9eee213d566850a9533f8d26332d626b82c"}, - {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:19df6e621f6d8b4b9c4d45f40a66839294ff2bb235e64d2178f7522d9170ac5b"}, - {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:83d78376d0d4fd884e2c114d0621624b73d2aba4e2788182d286309ebdeed770"}, - {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:e391b1f0a8a5a10ab3b9bb6afcfd74f2175f24f8975fb87ecae700d1503cdee0"}, - {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:852542f9481f4a62dbb5dd99e8ab7aedfeb8fb6342349a181d4036877410f525"}, - {file = "kiwisolver-1.4.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:59edc41b24031bc25108e210c0def6f6c2191210492a972d585a06ff246bb79b"}, - {file = "kiwisolver-1.4.5-cp310-cp310-win32.whl", hash = "sha256:a6aa6315319a052b4ee378aa171959c898a6183f15c1e541821c5c59beaa0238"}, - {file = "kiwisolver-1.4.5-cp310-cp310-win_amd64.whl", hash = "sha256:d0ef46024e6a3d79c01ff13801cb19d0cad7fd859b15037aec74315540acc276"}, - {file = "kiwisolver-1.4.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:11863aa14a51fd6ec28688d76f1735f8f69ab1fabf388851a595d0721af042f5"}, - {file = "kiwisolver-1.4.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8ab3919a9997ab7ef2fbbed0cc99bb28d3c13e6d4b1ad36e97e482558a91be90"}, - {file = "kiwisolver-1.4.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:fcc700eadbbccbf6bc1bcb9dbe0786b4b1cb91ca0dcda336eef5c2beed37b797"}, - {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dfdd7c0b105af050eb3d64997809dc21da247cf44e63dc73ff0fd20b96be55a9"}, - {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:76c6a5964640638cdeaa0c359382e5703e9293030fe730018ca06bc2010c4437"}, - {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bbea0db94288e29afcc4c28afbf3a7ccaf2d7e027489c449cf7e8f83c6346eb9"}, - {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ceec1a6bc6cab1d6ff5d06592a91a692f90ec7505d6463a88a52cc0eb58545da"}, - {file = "kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:040c1aebeda72197ef477a906782b5ab0d387642e93bda547336b8957c61022e"}, - {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:f91de7223d4c7b793867797bacd1ee53bfe7359bd70d27b7b58a04efbb9436c8"}, - {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:faae4860798c31530dd184046a900e652c95513796ef51a12bc086710c2eec4d"}, - {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:b0157420efcb803e71d1b28e2c287518b8808b7cf1ab8af36718fd0a2c453eb0"}, - {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:06f54715b7737c2fecdbf140d1afb11a33d59508a47bf11bb38ecf21dc9ab79f"}, - {file = "kiwisolver-1.4.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:fdb7adb641a0d13bdcd4ef48e062363d8a9ad4a182ac7647ec88f695e719ae9f"}, - {file = "kiwisolver-1.4.5-cp311-cp311-win32.whl", hash = "sha256:bb86433b1cfe686da83ce32a9d3a8dd308e85c76b60896d58f082136f10bffac"}, - {file = "kiwisolver-1.4.5-cp311-cp311-win_amd64.whl", hash = "sha256:6c08e1312a9cf1074d17b17728d3dfce2a5125b2d791527f33ffbe805200a355"}, - {file = "kiwisolver-1.4.5-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:32d5cf40c4f7c7b3ca500f8985eb3fb3a7dfc023215e876f207956b5ea26632a"}, - {file = "kiwisolver-1.4.5-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f846c260f483d1fd217fe5ed7c173fb109efa6b1fc8381c8b7552c5781756192"}, - {file = "kiwisolver-1.4.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5ff5cf3571589b6d13bfbfd6bcd7a3f659e42f96b5fd1c4830c4cf21d4f5ef45"}, - {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7269d9e5f1084a653d575c7ec012ff57f0c042258bf5db0954bf551c158466e7"}, - {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:da802a19d6e15dffe4b0c24b38b3af68e6c1a68e6e1d8f30148c83864f3881db"}, - {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3aba7311af82e335dd1e36ffff68aaca609ca6290c2cb6d821a39aa075d8e3ff"}, - {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:763773d53f07244148ccac5b084da5adb90bfaee39c197554f01b286cf869228"}, - {file = "kiwisolver-1.4.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2270953c0d8cdab5d422bee7d2007f043473f9d2999631c86a223c9db56cbd16"}, - {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d099e745a512f7e3bbe7249ca835f4d357c586d78d79ae8f1dcd4d8adeb9bda9"}, - {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:74db36e14a7d1ce0986fa104f7d5637aea5c82ca6326ed0ec5694280942d1162"}, - {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:7e5bab140c309cb3a6ce373a9e71eb7e4873c70c2dda01df6820474f9889d6d4"}, - {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:0f114aa76dc1b8f636d077979c0ac22e7cd8f3493abbab152f20eb8d3cda71f3"}, - {file = "kiwisolver-1.4.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:88a2df29d4724b9237fc0c6eaf2a1adae0cdc0b3e9f4d8e7dc54b16812d2d81a"}, - {file = "kiwisolver-1.4.5-cp312-cp312-win32.whl", hash = "sha256:72d40b33e834371fd330fb1472ca19d9b8327acb79a5821d4008391db8e29f20"}, - {file = "kiwisolver-1.4.5-cp312-cp312-win_amd64.whl", hash = "sha256:2c5674c4e74d939b9d91dda0fae10597ac7521768fec9e399c70a1f27e2ea2d9"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:3a2b053a0ab7a3960c98725cfb0bf5b48ba82f64ec95fe06f1d06c99b552e130"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3cd32d6c13807e5c66a7cbb79f90b553642f296ae4518a60d8d76243b0ad2898"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:59ec7b7c7e1a61061850d53aaf8e93db63dce0c936db1fda2658b70e4a1be709"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:da4cfb373035def307905d05041c1d06d8936452fe89d464743ae7fb8371078b"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2400873bccc260b6ae184b2b8a4fec0e4082d30648eadb7c3d9a13405d861e89"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:1b04139c4236a0f3aff534479b58f6f849a8b351e1314826c2d230849ed48985"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:4e66e81a5779b65ac21764c295087de82235597a2293d18d943f8e9e32746265"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:7931d8f1f67c4be9ba1dd9c451fb0eeca1a25b89e4d3f89e828fe12a519b782a"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:b3f7e75f3015df442238cca659f8baa5f42ce2a8582727981cbfa15fee0ee205"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:bbf1d63eef84b2e8c89011b7f2235b1e0bf7dacc11cac9431fc6468e99ac77fb"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:4c380469bd3f970ef677bf2bcba2b6b0b4d5c75e7a020fb863ef75084efad66f"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-win32.whl", hash = "sha256:9408acf3270c4b6baad483865191e3e582b638b1654a007c62e3efe96f09a9a3"}, - {file = "kiwisolver-1.4.5-cp37-cp37m-win_amd64.whl", hash = "sha256:5b94529f9b2591b7af5f3e0e730a4e0a41ea174af35a4fd067775f9bdfeee01a"}, - {file = "kiwisolver-1.4.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:11c7de8f692fc99816e8ac50d1d1aef4f75126eefc33ac79aac02c099fd3db71"}, - {file = "kiwisolver-1.4.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:53abb58632235cd154176ced1ae8f0d29a6657aa1aa9decf50b899b755bc2b93"}, - {file = "kiwisolver-1.4.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:88b9f257ca61b838b6f8094a62418421f87ac2a1069f7e896c36a7d86b5d4c29"}, - {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3195782b26fc03aa9c6913d5bad5aeb864bdc372924c093b0f1cebad603dd712"}, - {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fc579bf0f502e54926519451b920e875f433aceb4624a3646b3252b5caa9e0b6"}, - {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5a580c91d686376f0f7c295357595c5a026e6cbc3d77b7c36e290201e7c11ecb"}, - {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:cfe6ab8da05c01ba6fbea630377b5da2cd9bcbc6338510116b01c1bc939a2c18"}, - {file = "kiwisolver-1.4.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:d2e5a98f0ec99beb3c10e13b387f8db39106d53993f498b295f0c914328b1333"}, - {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:a51a263952b1429e429ff236d2f5a21c5125437861baeed77f5e1cc2d2c7c6da"}, - {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:3edd2fa14e68c9be82c5b16689e8d63d89fe927e56debd6e1dbce7a26a17f81b"}, - {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:74d1b44c6cfc897df648cc9fdaa09bc3e7679926e6f96df05775d4fb3946571c"}, - {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:76d9289ed3f7501012e05abb8358bbb129149dbd173f1f57a1bf1c22d19ab7cc"}, - {file = "kiwisolver-1.4.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:92dea1ffe3714fa8eb6a314d2b3c773208d865a0e0d35e713ec54eea08a66250"}, - {file = "kiwisolver-1.4.5-cp38-cp38-win32.whl", hash = "sha256:5c90ae8c8d32e472be041e76f9d2f2dbff4d0b0be8bd4041770eddb18cf49a4e"}, - {file = "kiwisolver-1.4.5-cp38-cp38-win_amd64.whl", hash = "sha256:c7940c1dc63eb37a67721b10d703247552416f719c4188c54e04334321351ced"}, - {file = "kiwisolver-1.4.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:9407b6a5f0d675e8a827ad8742e1d6b49d9c1a1da5d952a67d50ef5f4170b18d"}, - {file = "kiwisolver-1.4.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:15568384086b6df3c65353820a4473575dbad192e35010f622c6ce3eebd57af9"}, - {file = "kiwisolver-1.4.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0dc9db8e79f0036e8173c466d21ef18e1befc02de8bf8aa8dc0813a6dc8a7046"}, - {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:cdc8a402aaee9a798b50d8b827d7ecf75edc5fb35ea0f91f213ff927c15f4ff0"}, - {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6c3bd3cde54cafb87d74d8db50b909705c62b17c2099b8f2e25b461882e544ff"}, - {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:955e8513d07a283056b1396e9a57ceddbd272d9252c14f154d450d227606eb54"}, - {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:346f5343b9e3f00b8db8ba359350eb124b98c99efd0b408728ac6ebf38173958"}, - {file = "kiwisolver-1.4.5-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b9098e0049e88c6a24ff64545cdfc50807818ba6c1b739cae221bbbcbc58aad3"}, - {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:00bd361b903dc4bbf4eb165f24d1acbee754fce22ded24c3d56eec268658a5cf"}, - {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:7b8b454bac16428b22560d0a1cf0a09875339cab69df61d7805bf48919415901"}, - {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:f1d072c2eb0ad60d4c183f3fb44ac6f73fb7a8f16a2694a91f988275cbf352f9"}, - {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:31a82d498054cac9f6d0b53d02bb85811185bcb477d4b60144f915f3b3126342"}, - {file = "kiwisolver-1.4.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6512cb89e334e4700febbffaaa52761b65b4f5a3cf33f960213d5656cea36a77"}, - {file = "kiwisolver-1.4.5-cp39-cp39-win32.whl", hash = "sha256:9db8ea4c388fdb0f780fe91346fd438657ea602d58348753d9fb265ce1bca67f"}, - {file = "kiwisolver-1.4.5-cp39-cp39-win_amd64.whl", hash = "sha256:59415f46a37f7f2efeec758353dd2eae1b07640d8ca0f0c42548ec4125492635"}, - {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:5c7b3b3a728dc6faf3fc372ef24f21d1e3cee2ac3e9596691d746e5a536de920"}, - {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:620ced262a86244e2be10a676b646f29c34537d0d9cc8eb26c08f53d98013390"}, - {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:378a214a1e3bbf5ac4a8708304318b4f890da88c9e6a07699c4ae7174c09a68d"}, - {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aaf7be1207676ac608a50cd08f102f6742dbfc70e8d60c4db1c6897f62f71523"}, - {file = "kiwisolver-1.4.5-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:ba55dce0a9b8ff59495ddd050a0225d58bd0983d09f87cfe2b6aec4f2c1234e4"}, - {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:fd32ea360bcbb92d28933fc05ed09bffcb1704ba3fc7942e81db0fd4f81a7892"}, - {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5e7139af55d1688f8b960ee9ad5adafc4ac17c1c473fe07133ac092310d76544"}, - {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:dced8146011d2bc2e883f9bd68618b8247387f4bbec46d7392b3c3b032640126"}, - {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c9bf3325c47b11b2e51bca0824ea217c7cd84491d8ac4eefd1e409705ef092bd"}, - {file = "kiwisolver-1.4.5-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:5794cf59533bc3f1b1c821f7206a3617999db9fbefc345360aafe2e067514929"}, - {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:e368f200bbc2e4f905b8e71eb38b3c04333bddaa6a2464a6355487b02bb7fb09"}, - {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e5d706eba36b4c4d5bc6c6377bb6568098765e990cfc21ee16d13963fab7b3e7"}, - {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:85267bd1aa8880a9c88a8cb71e18d3d64d2751a790e6ca6c27b8ccc724bcd5ad"}, - {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:210ef2c3a1f03272649aff1ef992df2e724748918c4bc2d5a90352849eb40bea"}, - {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:11d011a7574eb3b82bcc9c1a1d35c1d7075677fdd15de527d91b46bd35e935ee"}, - {file = "kiwisolver-1.4.5.tar.gz", hash = "sha256:e57e563a57fb22a142da34f38acc2fc1a5c864bc29ca1517a88abc963e60d6ec"}, -] -markdown-it-py = [ - {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, - {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, -] -matplotlib = [ - {file = "matplotlib-3.8.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:09796f89fb71a0c0e1e2f4bdaf63fb2cefc84446bb963ecdeb40dfee7dfa98c7"}, - {file = "matplotlib-3.8.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6f9c6976748a25e8b9be51ea028df49b8e561eed7809146da7a47dbecebab367"}, - {file = "matplotlib-3.8.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b78e4f2cedf303869b782071b55fdde5987fda3038e9d09e58c91cc261b5ad18"}, - {file = "matplotlib-3.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4e208f46cf6576a7624195aa047cb344a7f802e113bb1a06cfd4bee431de5e31"}, - {file = "matplotlib-3.8.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:46a569130ff53798ea5f50afce7406e91fdc471ca1e0e26ba976a8c734c9427a"}, - {file = "matplotlib-3.8.2-cp310-cp310-win_amd64.whl", hash = "sha256:830f00640c965c5b7f6bc32f0d4ce0c36dfe0379f7dd65b07a00c801713ec40a"}, - {file = "matplotlib-3.8.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d86593ccf546223eb75a39b44c32788e6f6440d13cfc4750c1c15d0fcb850b63"}, - {file = "matplotlib-3.8.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9a5430836811b7652991939012f43d2808a2db9b64ee240387e8c43e2e5578c8"}, - {file = "matplotlib-3.8.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b9576723858a78751d5aacd2497b8aef29ffea6d1c95981505877f7ac28215c6"}, - {file = "matplotlib-3.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ba9cbd8ac6cf422f3102622b20f8552d601bf8837e49a3afed188d560152788"}, - {file = "matplotlib-3.8.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:03f9d160a29e0b65c0790bb07f4f45d6a181b1ac33eb1bb0dd225986450148f0"}, - {file = "matplotlib-3.8.2-cp311-cp311-win_amd64.whl", hash = "sha256:3773002da767f0a9323ba1a9b9b5d00d6257dbd2a93107233167cfb581f64717"}, - {file = "matplotlib-3.8.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:4c318c1e95e2f5926fba326f68177dee364aa791d6df022ceb91b8221bd0a627"}, - {file = "matplotlib-3.8.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:091275d18d942cf1ee9609c830a1bc36610607d8223b1b981c37d5c9fc3e46a4"}, - {file = "matplotlib-3.8.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b0f3b8ea0e99e233a4bcc44590f01604840d833c280ebb8fe5554fd3e6cfe8d"}, - {file = "matplotlib-3.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7b1704a530395aaf73912be741c04d181f82ca78084fbd80bc737be04848331"}, - {file = "matplotlib-3.8.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:533b0e3b0c6768eef8cbe4b583731ce25a91ab54a22f830db2b031e83cca9213"}, - {file = "matplotlib-3.8.2-cp312-cp312-win_amd64.whl", hash = "sha256:0f4fc5d72b75e2c18e55eb32292659cf731d9d5b312a6eb036506304f4675630"}, - {file = "matplotlib-3.8.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:deaed9ad4da0b1aea77fe0aa0cebb9ef611c70b3177be936a95e5d01fa05094f"}, - {file = "matplotlib-3.8.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:172f4d0fbac3383d39164c6caafd3255ce6fa58f08fc392513a0b1d3b89c4f89"}, - {file = "matplotlib-3.8.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7d36c2209d9136cd8e02fab1c0ddc185ce79bc914c45054a9f514e44c787917"}, - {file = "matplotlib-3.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5864bdd7da445e4e5e011b199bb67168cdad10b501750367c496420f2ad00843"}, - {file = "matplotlib-3.8.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ef8345b48e95cee45ff25192ed1f4857273117917a4dcd48e3905619bcd9c9b8"}, - {file = "matplotlib-3.8.2-cp39-cp39-win_amd64.whl", hash = "sha256:7c48d9e221b637c017232e3760ed30b4e8d5dfd081daf327e829bf2a72c731b4"}, - {file = "matplotlib-3.8.2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:aa11b3c6928a1e496c1a79917d51d4cd5d04f8a2e75f21df4949eeefdf697f4b"}, - {file = "matplotlib-3.8.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d1095fecf99eeb7384dabad4bf44b965f929a5f6079654b681193edf7169ec20"}, - {file = "matplotlib-3.8.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:bddfb1db89bfaa855912261c805bd0e10218923cc262b9159a49c29a7a1c1afa"}, - {file = "matplotlib-3.8.2.tar.gz", hash = "sha256:01a978b871b881ee76017152f1f1a0cbf6bd5f7b8ff8c96df0df1bd57d8755a1"}, -] -mdurl = [ - {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, - {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, -] -numpy = [ - {file = "numpy-1.26.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:3703fc9258a4a122d17043e57b35e5ef1c5a5837c3db8be396c82e04c1cf9b0f"}, - {file = "numpy-1.26.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cc392fdcbd21d4be6ae1bb4475a03ce3b025cd49a9be5345d76d7585aea69440"}, - {file = "numpy-1.26.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:36340109af8da8805d8851ef1d74761b3b88e81a9bd80b290bbfed61bd2b4f75"}, - {file = "numpy-1.26.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bcc008217145b3d77abd3e4d5ef586e3bdfba8fe17940769f8aa09b99e856c00"}, - {file = "numpy-1.26.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:3ced40d4e9e18242f70dd02d739e44698df3dcb010d31f495ff00a31ef6014fe"}, - {file = "numpy-1.26.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b272d4cecc32c9e19911891446b72e986157e6a1809b7b56518b4f3755267523"}, - {file = "numpy-1.26.2-cp310-cp310-win32.whl", hash = "sha256:22f8fc02fdbc829e7a8c578dd8d2e15a9074b630d4da29cda483337e300e3ee9"}, - {file = "numpy-1.26.2-cp310-cp310-win_amd64.whl", hash = "sha256:26c9d33f8e8b846d5a65dd068c14e04018d05533b348d9eaeef6c1bd787f9919"}, - {file = "numpy-1.26.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b96e7b9c624ef3ae2ae0e04fa9b460f6b9f17ad8b4bec6d7756510f1f6c0c841"}, - {file = "numpy-1.26.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aa18428111fb9a591d7a9cc1b48150097ba6a7e8299fb56bdf574df650e7d1f1"}, - {file = "numpy-1.26.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:06fa1ed84aa60ea6ef9f91ba57b5ed963c3729534e6e54055fc151fad0423f0a"}, - {file = "numpy-1.26.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:96ca5482c3dbdd051bcd1fce8034603d6ebfc125a7bd59f55b40d8f5d246832b"}, - {file = "numpy-1.26.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:854ab91a2906ef29dc3925a064fcd365c7b4da743f84b123002f6139bcb3f8a7"}, - {file = "numpy-1.26.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f43740ab089277d403aa07567be138fc2a89d4d9892d113b76153e0e412409f8"}, - {file = "numpy-1.26.2-cp311-cp311-win32.whl", hash = "sha256:a2bbc29fcb1771cd7b7425f98b05307776a6baf43035d3b80c4b0f29e9545186"}, - {file = "numpy-1.26.2-cp311-cp311-win_amd64.whl", hash = "sha256:2b3fca8a5b00184828d12b073af4d0fc5fdd94b1632c2477526f6bd7842d700d"}, - {file = "numpy-1.26.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a4cd6ed4a339c21f1d1b0fdf13426cb3b284555c27ac2f156dfdaaa7e16bfab0"}, - {file = "numpy-1.26.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5d5244aabd6ed7f312268b9247be47343a654ebea52a60f002dc70c769048e75"}, - {file = "numpy-1.26.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6a3cdb4d9c70e6b8c0814239ead47da00934666f668426fc6e94cce869e13fd7"}, - {file = "numpy-1.26.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aa317b2325f7aa0a9471663e6093c210cb2ae9c0ad824732b307d2c51983d5b6"}, - {file = "numpy-1.26.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:174a8880739c16c925799c018f3f55b8130c1f7c8e75ab0a6fa9d41cab092fd6"}, - {file = "numpy-1.26.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:f79b231bf5c16b1f39c7f4875e1ded36abee1591e98742b05d8a0fb55d8a3eec"}, - {file = "numpy-1.26.2-cp312-cp312-win32.whl", hash = "sha256:4a06263321dfd3598cacb252f51e521a8cb4b6df471bb12a7ee5cbab20ea9167"}, - {file = "numpy-1.26.2-cp312-cp312-win_amd64.whl", hash = "sha256:b04f5dc6b3efdaab541f7857351aac359e6ae3c126e2edb376929bd3b7f92d7e"}, - {file = "numpy-1.26.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4eb8df4bf8d3d90d091e0146f6c28492b0be84da3e409ebef54349f71ed271ef"}, - {file = "numpy-1.26.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1a13860fdcd95de7cf58bd6f8bc5a5ef81c0b0625eb2c9a783948847abbef2c2"}, - {file = "numpy-1.26.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:64308ebc366a8ed63fd0bf426b6a9468060962f1a4339ab1074c228fa6ade8e3"}, - {file = "numpy-1.26.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baf8aab04a2c0e859da118f0b38617e5ee65d75b83795055fb66c0d5e9e9b818"}, - {file = "numpy-1.26.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d73a3abcac238250091b11caef9ad12413dab01669511779bc9b29261dd50210"}, - {file = "numpy-1.26.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:b361d369fc7e5e1714cf827b731ca32bff8d411212fccd29ad98ad622449cc36"}, - {file = "numpy-1.26.2-cp39-cp39-win32.whl", hash = "sha256:bd3f0091e845164a20bd5a326860c840fe2af79fa12e0469a12768a3ec578d80"}, - {file = "numpy-1.26.2-cp39-cp39-win_amd64.whl", hash = "sha256:2beef57fb031dcc0dc8fa4fe297a742027b954949cabb52a2a376c144e5e6060"}, - {file = "numpy-1.26.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:1cc3d5029a30fb5f06704ad6b23b35e11309491c999838c31f124fee32107c79"}, - {file = "numpy-1.26.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94cc3c222bb9fb5a12e334d0479b97bb2df446fbe622b470928f5284ffca3f8d"}, - {file = "numpy-1.26.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:fe6b44fb8fcdf7eda4ef4461b97b3f63c466b27ab151bec2366db8b197387841"}, - {file = "numpy-1.26.2.tar.gz", hash = "sha256:f65738447676ab5777f11e6bbbdb8ce11b785e105f690bc45966574816b6d3ea"}, -] -packaging = [ - {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, - {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, -] -pandas = [ - {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3749077d86e3a2f0ed51367f30bf5b82e131cc0f14260c4d3e499186fccc4406"}, - {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:972d8a45395f2a2d26733eb8d0f629b2f90bebe8e8eddbb8829b180c09639572"}, - {file = "pandas-1.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:50869a35cbb0f2e0cd5ec04b191e7b12ed688874bd05dd777c19b28cbea90996"}, - {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3ac844a0fe00bfaeb2c9b51ab1424e5c8744f89860b138434a363b1f620f354"}, - {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a0a56cef15fd1586726dace5616db75ebcfec9179a3a55e78f72c5639fa2a23"}, - {file = "pandas-1.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:478ff646ca42b20376e4ed3fa2e8d7341e8a63105586efe54fa2508ee087f328"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6973549c01ca91ec96199e940495219c887ea815b2083722821f1d7abfa2b4dc"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c39a8da13cede5adcd3be1182883aea1c925476f4e84b2807a46e2775306305d"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f76d097d12c82a535fda9dfe5e8dd4127952b45fea9b0276cb30cca5ea313fbc"}, - {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e474390e60ed609cec869b0da796ad94f420bb057d86784191eefc62b65819ae"}, - {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f2b952406a1588ad4cad5b3f55f520e82e902388a6d5a4a91baa8d38d23c7f6"}, - {file = "pandas-1.5.3-cp311-cp311-win_amd64.whl", hash = "sha256:bc4c368f42b551bf72fac35c5128963a171b40dce866fb066540eeaf46faa003"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:14e45300521902689a81f3f41386dc86f19b8ba8dd5ac5a3c7010ef8d2932813"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9842b6f4b8479e41968eced654487258ed81df7d1c9b7b870ceea24ed9459b31"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:26d9c71772c7afb9d5046e6e9cf42d83dd147b5cf5bcb9d97252077118543792"}, - {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5fbcb19d6fceb9e946b3e23258757c7b225ba450990d9ed63ccceeb8cae609f7"}, - {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:565fa34a5434d38e9d250af3c12ff931abaf88050551d9fbcdfafca50d62babf"}, - {file = "pandas-1.5.3-cp38-cp38-win32.whl", hash = "sha256:87bd9c03da1ac870a6d2c8902a0e1fd4267ca00f13bc494c9e5a9020920e1d51"}, - {file = "pandas-1.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:41179ce559943d83a9b4bbacb736b04c928b095b5f25dd2b7389eda08f46f373"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c74a62747864ed568f5a82a49a23a8d7fe171d0c69038b38cedf0976831296fa"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c4c00e0b0597c8e4f59e8d461f797e5d70b4d025880516a8261b2817c47759ee"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a50d9a4336a9621cab7b8eb3fb11adb82de58f9b91d84c2cd526576b881a0c5a"}, - {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd05f7783b3274aa206a1af06f0ceed3f9b412cf665b7247eacd83be41cf7bf0"}, - {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f69c4029613de47816b1bb30ff5ac778686688751a5e9c99ad8c7031f6508e5"}, - {file = "pandas-1.5.3-cp39-cp39-win32.whl", hash = "sha256:7cec0bee9f294e5de5bbfc14d0573f65526071029d036b753ee6507d2a21480a"}, - {file = "pandas-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:dfd681c5dc216037e0b0a2c821f5ed99ba9f03ebcf119c7dac0e9a7b960b9ec9"}, - {file = "pandas-1.5.3.tar.gz", hash = "sha256:74a3fd7e5a7ec052f183273dc7b0acd3a863edf7520f5d3a1765c04ffdb3b0b1"}, -] -Pillow = [ - {file = "Pillow-9.5.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:ace6ca218308447b9077c14ea4ef381ba0b67ee78d64046b3f19cf4e1139ad16"}, - {file = "Pillow-9.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d3d403753c9d5adc04d4694d35cf0391f0f3d57c8e0030aac09d7678fa8030aa"}, - {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5ba1b81ee69573fe7124881762bb4cd2e4b6ed9dd28c9c60a632902fe8db8b38"}, - {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe7e1c262d3392afcf5071df9afa574544f28eac825284596ac6db56e6d11062"}, - {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f36397bf3f7d7c6a3abdea815ecf6fd14e7fcd4418ab24bae01008d8d8ca15e"}, - {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:252a03f1bdddce077eff2354c3861bf437c892fb1832f75ce813ee94347aa9b5"}, - {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:85ec677246533e27770b0de5cf0f9d6e4ec0c212a1f89dfc941b64b21226009d"}, - {file = "Pillow-9.5.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b416f03d37d27290cb93597335a2f85ed446731200705b22bb927405320de903"}, - {file = "Pillow-9.5.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:1781a624c229cb35a2ac31cc4a77e28cafc8900733a864870c49bfeedacd106a"}, - {file = "Pillow-9.5.0-cp310-cp310-win32.whl", hash = "sha256:8507eda3cd0608a1f94f58c64817e83ec12fa93a9436938b191b80d9e4c0fc44"}, - {file = "Pillow-9.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:d3c6b54e304c60c4181da1c9dadf83e4a54fd266a99c70ba646a9baa626819eb"}, - {file = "Pillow-9.5.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:7ec6f6ce99dab90b52da21cf0dc519e21095e332ff3b399a357c187b1a5eee32"}, - {file = "Pillow-9.5.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:560737e70cb9c6255d6dcba3de6578a9e2ec4b573659943a5e7e4af13f298f5c"}, - {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:96e88745a55b88a7c64fa49bceff363a1a27d9a64e04019c2281049444a571e3"}, - {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d9c206c29b46cfd343ea7cdfe1232443072bbb270d6a46f59c259460db76779a"}, - {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cfcc2c53c06f2ccb8976fb5c71d448bdd0a07d26d8e07e321c103416444c7ad1"}, - {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:a0f9bb6c80e6efcde93ffc51256d5cfb2155ff8f78292f074f60f9e70b942d99"}, - {file = "Pillow-9.5.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:8d935f924bbab8f0a9a28404422da8af4904e36d5c33fc6f677e4c4485515625"}, - {file = "Pillow-9.5.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:fed1e1cf6a42577953abbe8e6cf2fe2f566daebde7c34724ec8803c4c0cda579"}, - {file = "Pillow-9.5.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:c1170d6b195555644f0616fd6ed929dfcf6333b8675fcca044ae5ab110ded296"}, - {file = "Pillow-9.5.0-cp311-cp311-win32.whl", hash = "sha256:54f7102ad31a3de5666827526e248c3530b3a33539dbda27c6843d19d72644ec"}, - {file = "Pillow-9.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:cfa4561277f677ecf651e2b22dc43e8f5368b74a25a8f7d1d4a3a243e573f2d4"}, - {file = "Pillow-9.5.0-cp311-cp311-win_arm64.whl", hash = "sha256:965e4a05ef364e7b973dd17fc765f42233415974d773e82144c9bbaaaea5d089"}, - {file = "Pillow-9.5.0-cp312-cp312-win32.whl", hash = "sha256:22baf0c3cf0c7f26e82d6e1adf118027afb325e703922c8dfc1d5d0156bb2eeb"}, - {file = "Pillow-9.5.0-cp312-cp312-win_amd64.whl", hash = "sha256:432b975c009cf649420615388561c0ce7cc31ce9b2e374db659ee4f7d57a1f8b"}, - {file = "Pillow-9.5.0-cp37-cp37m-macosx_10_10_x86_64.whl", hash = "sha256:5d4ebf8e1db4441a55c509c4baa7a0587a0210f7cd25fcfe74dbbce7a4bd1906"}, - {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:375f6e5ee9620a271acb6820b3d1e94ffa8e741c0601db4c0c4d3cb0a9c224bf"}, - {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:99eb6cafb6ba90e436684e08dad8be1637efb71c4f2180ee6b8f940739406e78"}, - {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2dfaaf10b6172697b9bceb9a3bd7b951819d1ca339a5ef294d1f1ac6d7f63270"}, - {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_28_aarch64.whl", hash = "sha256:763782b2e03e45e2c77d7779875f4432e25121ef002a41829d8868700d119392"}, - {file = "Pillow-9.5.0-cp37-cp37m-manylinux_2_28_x86_64.whl", hash = "sha256:35f6e77122a0c0762268216315bf239cf52b88865bba522999dc38f1c52b9b47"}, - {file = "Pillow-9.5.0-cp37-cp37m-win32.whl", hash = "sha256:aca1c196f407ec7cf04dcbb15d19a43c507a81f7ffc45b690899d6a76ac9fda7"}, - {file = "Pillow-9.5.0-cp37-cp37m-win_amd64.whl", hash = "sha256:322724c0032af6692456cd6ed554bb85f8149214d97398bb80613b04e33769f6"}, - {file = "Pillow-9.5.0-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:a0aa9417994d91301056f3d0038af1199eb7adc86e646a36b9e050b06f526597"}, - {file = "Pillow-9.5.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f8286396b351785801a976b1e85ea88e937712ee2c3ac653710a4a57a8da5d9c"}, - {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c830a02caeb789633863b466b9de10c015bded434deb3ec87c768e53752ad22a"}, - {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fbd359831c1657d69bb81f0db962905ee05e5e9451913b18b831febfe0519082"}, - {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f8fc330c3370a81bbf3f88557097d1ea26cd8b019d6433aa59f71195f5ddebbf"}, - {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:7002d0797a3e4193c7cdee3198d7c14f92c0836d6b4a3f3046a64bd1ce8df2bf"}, - {file = "Pillow-9.5.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:229e2c79c00e85989a34b5981a2b67aa079fd08c903f0aaead522a1d68d79e51"}, - {file = "Pillow-9.5.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:9adf58f5d64e474bed00d69bcd86ec4bcaa4123bfa70a65ce72e424bfb88ed96"}, - {file = "Pillow-9.5.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:662da1f3f89a302cc22faa9f14a262c2e3951f9dbc9617609a47521c69dd9f8f"}, - {file = "Pillow-9.5.0-cp38-cp38-win32.whl", hash = "sha256:6608ff3bf781eee0cd14d0901a2b9cc3d3834516532e3bd673a0a204dc8615fc"}, - {file = "Pillow-9.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:e49eb4e95ff6fd7c0c402508894b1ef0e01b99a44320ba7d8ecbabefddcc5569"}, - {file = "Pillow-9.5.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:482877592e927fd263028c105b36272398e3e1be3269efda09f6ba21fd83ec66"}, - {file = "Pillow-9.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3ded42b9ad70e5f1754fb7c2e2d6465a9c842e41d178f262e08b8c85ed8a1d8e"}, - {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c446d2245ba29820d405315083d55299a796695d747efceb5717a8b450324115"}, - {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8aca1152d93dcc27dc55395604dcfc55bed5f25ef4c98716a928bacba90d33a3"}, - {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:608488bdcbdb4ba7837461442b90ea6f3079397ddc968c31265c1e056964f1ef"}, - {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:60037a8db8750e474af7ffc9faa9b5859e6c6d0a50e55c45576bf28be7419705"}, - {file = "Pillow-9.5.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:07999f5834bdc404c442146942a2ecadd1cb6292f5229f4ed3b31e0a108746b1"}, - {file = "Pillow-9.5.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a127ae76092974abfbfa38ca2d12cbeddcdeac0fb71f9627cc1135bedaf9d51a"}, - {file = "Pillow-9.5.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:489f8389261e5ed43ac8ff7b453162af39c3e8abd730af8363587ba64bb2e865"}, - {file = "Pillow-9.5.0-cp39-cp39-win32.whl", hash = "sha256:9b1af95c3a967bf1da94f253e56b6286b50af23392a886720f563c547e48e964"}, - {file = "Pillow-9.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:77165c4a5e7d5a284f10a6efaa39a0ae8ba839da344f20b111d62cc932fa4e5d"}, - {file = "Pillow-9.5.0-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:833b86a98e0ede388fa29363159c9b1a294b0905b5128baf01db683672f230f5"}, - {file = "Pillow-9.5.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aaf305d6d40bd9632198c766fb64f0c1a83ca5b667f16c1e79e1661ab5060140"}, - {file = "Pillow-9.5.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0852ddb76d85f127c135b6dd1f0bb88dbb9ee990d2cd9aa9e28526c93e794fba"}, - {file = "Pillow-9.5.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:91ec6fe47b5eb5a9968c79ad9ed78c342b1f97a091677ba0e012701add857829"}, - {file = "Pillow-9.5.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:cb841572862f629b99725ebaec3287fc6d275be9b14443ea746c1dd325053cbd"}, - {file = "Pillow-9.5.0-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:c380b27d041209b849ed246b111b7c166ba36d7933ec6e41175fd15ab9eb1572"}, - {file = "Pillow-9.5.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7c9af5a3b406a50e313467e3565fc99929717f780164fe6fbb7704edba0cebbe"}, - {file = "Pillow-9.5.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5671583eab84af046a397d6d0ba25343c00cd50bce03787948e0fff01d4fd9b1"}, - {file = "Pillow-9.5.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:84a6f19ce086c1bf894644b43cd129702f781ba5751ca8572f08aa40ef0ab7b7"}, - {file = "Pillow-9.5.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:1e7723bd90ef94eda669a3c2c19d549874dd5badaeefabefd26053304abe5799"}, - {file = "Pillow-9.5.0.tar.gz", hash = "sha256:bf548479d336726d7a0eceb6e767e179fbde37833ae42794602631a070d630f1"}, -] -pluggy = [ - {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, - {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, -] -py = [ - {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, - {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, -] -Pygments = [ - {file = "pygments-2.17.2-py3-none-any.whl", hash = "sha256:b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c"}, - {file = "pygments-2.17.2.tar.gz", hash = "sha256:da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"}, -] -pyparsing = [ - {file = "pyparsing-3.1.1-py3-none-any.whl", hash = "sha256:32c7c0b711493c72ff18a981d24f28aaf9c1fb7ed5e9667c9e84e3db623bdbfb"}, - {file = "pyparsing-3.1.1.tar.gz", hash = "sha256:ede28a1a32462f5a9705e07aea48001a08f7cf81a021585011deba701581a0db"}, -] -PySocks = [ - {file = "PySocks-1.7.1-py27-none-any.whl", hash = "sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299"}, - {file = "PySocks-1.7.1-py3-none-any.whl", hash = "sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5"}, - {file = "PySocks-1.7.1.tar.gz", hash = "sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0"}, -] -pytest = [ - {file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"}, - {file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"}, -] -pytest-cov = [ - {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, - {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, -] -pytest-shell = [ - {file = "pytest-shell-0.3.2.tar.gz", hash = "sha256:7e30cf518a5271328f25eaa9013e1639607f169d7396a4b85204a8b34dacbab1"}, - {file = "pytest_shell-0.3.2-py3-none-any.whl", hash = "sha256:f60716134fc30e2c1fe9facb9fe60121d18b4d7b95e692b2c6f29271350aa12b"}, -] -python-dateutil = [ - {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, - {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, -] -pytz = [ - {file = "pytz-2023.3.post1-py2.py3-none-any.whl", hash = "sha256:ce42d816b81b68506614c11e8937d3aa9e41007ceb50bfdcb0749b921bf646c7"}, - {file = "pytz-2023.3.post1.tar.gz", hash = "sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b"}, -] -PyYAML = [ - {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, - {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, - {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, - {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, - {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, - {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, - {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, - {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, - {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, - {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, - {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, - {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, - {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, - {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, - {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, - {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, - {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, - {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, - {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, - {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, - {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, - {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, -] -requests = [ - {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"}, - {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, -] -rich = [ - {file = "rich-13.7.0-py3-none-any.whl", hash = "sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235"}, - {file = "rich-13.7.0.tar.gz", hash = "sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa"}, -] -scikit-learn = [ - {file = "scikit-learn-1.3.2.tar.gz", hash = "sha256:a2f54c76accc15a34bfb9066e6c7a56c1e7235dda5762b990792330b52ccfb05"}, - {file = "scikit_learn-1.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e326c0eb5cf4d6ba40f93776a20e9a7a69524c4db0757e7ce24ba222471ee8a1"}, - {file = "scikit_learn-1.3.2-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:535805c2a01ccb40ca4ab7d081d771aea67e535153e35a1fd99418fcedd1648a"}, - {file = "scikit_learn-1.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1215e5e58e9880b554b01187b8c9390bf4dc4692eedeaf542d3273f4785e342c"}, - {file = "scikit_learn-1.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ee107923a623b9f517754ea2f69ea3b62fc898a3641766cb7deb2f2ce450161"}, - {file = "scikit_learn-1.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:35a22e8015048c628ad099da9df5ab3004cdbf81edc75b396fd0cff8699ac58c"}, - {file = "scikit_learn-1.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6fb6bc98f234fda43163ddbe36df8bcde1d13ee176c6dc9b92bb7d3fc842eb66"}, - {file = "scikit_learn-1.3.2-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:18424efee518a1cde7b0b53a422cde2f6625197de6af36da0b57ec502f126157"}, - {file = "scikit_learn-1.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3271552a5eb16f208a6f7f617b8cc6d1f137b52c8a1ef8edf547db0259b2c9fb"}, - {file = "scikit_learn-1.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc4144a5004a676d5022b798d9e573b05139e77f271253a4703eed295bde0433"}, - {file = "scikit_learn-1.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:67f37d708f042a9b8d59551cf94d30431e01374e00dc2645fa186059c6c5d78b"}, - {file = "scikit_learn-1.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:8db94cd8a2e038b37a80a04df8783e09caac77cbe052146432e67800e430c028"}, - {file = "scikit_learn-1.3.2-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:61a6efd384258789aa89415a410dcdb39a50e19d3d8410bd29be365bcdd512d5"}, - {file = "scikit_learn-1.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb06f8dce3f5ddc5dee1715a9b9f19f20d295bed8e3cd4fa51e1d050347de525"}, - {file = "scikit_learn-1.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5b2de18d86f630d68fe1f87af690d451388bb186480afc719e5f770590c2ef6c"}, - {file = "scikit_learn-1.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:0402638c9a7c219ee52c94cbebc8fcb5eb9fe9c773717965c1f4185588ad3107"}, - {file = "scikit_learn-1.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a19f90f95ba93c1a7f7924906d0576a84da7f3b2282ac3bfb7a08a32801add93"}, - {file = "scikit_learn-1.3.2-cp38-cp38-macosx_12_0_arm64.whl", hash = "sha256:b8692e395a03a60cd927125eef3a8e3424d86dde9b2370d544f0ea35f78a8073"}, - {file = "scikit_learn-1.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:15e1e94cc23d04d39da797ee34236ce2375ddea158b10bee3c343647d615581d"}, - {file = "scikit_learn-1.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:785a2213086b7b1abf037aeadbbd6d67159feb3e30263434139c98425e3dcfcf"}, - {file = "scikit_learn-1.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:64381066f8aa63c2710e6b56edc9f0894cc7bf59bd71b8ce5613a4559b6145e0"}, - {file = "scikit_learn-1.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6c43290337f7a4b969d207e620658372ba3c1ffb611f8bc2b6f031dc5c6d1d03"}, - {file = "scikit_learn-1.3.2-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:dc9002fc200bed597d5d34e90c752b74df516d592db162f756cc52836b38fe0e"}, - {file = "scikit_learn-1.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1d08ada33e955c54355d909b9c06a4789a729977f165b8bae6f225ff0a60ec4a"}, - {file = "scikit_learn-1.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:763f0ae4b79b0ff9cca0bf3716bcc9915bdacff3cebea15ec79652d1cc4fa5c9"}, - {file = "scikit_learn-1.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:ed932ea780517b00dae7431e031faae6b49b20eb6950918eb83bd043237950e0"}, -] -scipy = [ - {file = "scipy-1.11.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bc9a714581f561af0848e6b69947fda0614915f072dfd14142ed1bfe1b806710"}, - {file = "scipy-1.11.4-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:cf00bd2b1b0211888d4dc75656c0412213a8b25e80d73898083f402b50f47e41"}, - {file = "scipy-1.11.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b9999c008ccf00e8fbcce1236f85ade5c569d13144f77a1946bef8863e8f6eb4"}, - {file = "scipy-1.11.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:933baf588daa8dc9a92c20a0be32f56d43faf3d1a60ab11b3f08c356430f6e56"}, - {file = "scipy-1.11.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8fce70f39076a5aa62e92e69a7f62349f9574d8405c0a5de6ed3ef72de07f446"}, - {file = "scipy-1.11.4-cp310-cp310-win_amd64.whl", hash = "sha256:6550466fbeec7453d7465e74d4f4b19f905642c89a7525571ee91dd7adabb5a3"}, - {file = "scipy-1.11.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f313b39a7e94f296025e3cffc2c567618174c0b1dde173960cf23808f9fae4be"}, - {file = "scipy-1.11.4-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:1b7c3dca977f30a739e0409fb001056484661cb2541a01aba0bb0029f7b68db8"}, - {file = "scipy-1.11.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:00150c5eae7b610c32589dda259eacc7c4f1665aedf25d921907f4d08a951b1c"}, - {file = "scipy-1.11.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:530f9ad26440e85766509dbf78edcfe13ffd0ab7fec2560ee5c36ff74d6269ff"}, - {file = "scipy-1.11.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5e347b14fe01003d3b78e196e84bd3f48ffe4c8a7b8a1afbcb8f5505cb710993"}, - {file = "scipy-1.11.4-cp311-cp311-win_amd64.whl", hash = "sha256:acf8ed278cc03f5aff035e69cb511741e0418681d25fbbb86ca65429c4f4d9cd"}, - {file = "scipy-1.11.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:028eccd22e654b3ea01ee63705681ee79933652b2d8f873e7949898dda6d11b6"}, - {file = "scipy-1.11.4-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:2c6ff6ef9cc27f9b3db93a6f8b38f97387e6e0591600369a297a50a8e96e835d"}, - {file = "scipy-1.11.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b030c6674b9230d37c5c60ab456e2cf12f6784596d15ce8da9365e70896effc4"}, - {file = "scipy-1.11.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ad669df80528aeca5f557712102538f4f37e503f0c5b9541655016dd0932ca79"}, - {file = "scipy-1.11.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ce7fff2e23ab2cc81ff452a9444c215c28e6305f396b2ba88343a567feec9660"}, - {file = "scipy-1.11.4-cp312-cp312-win_amd64.whl", hash = "sha256:36750b7733d960d7994888f0d148d31ea3017ac15eef664194b4ef68d36a4a97"}, - {file = "scipy-1.11.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6e619aba2df228a9b34718efb023966da781e89dd3d21637b27f2e54db0410d7"}, - {file = "scipy-1.11.4-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:f3cd9e7b3c2c1ec26364856f9fbe78695fe631150f94cd1c22228456404cf1ec"}, - {file = "scipy-1.11.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d10e45a6c50211fe256da61a11c34927c68f277e03138777bdebedd933712fea"}, - {file = "scipy-1.11.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:91af76a68eeae0064887a48e25c4e616fa519fa0d38602eda7e0f97d65d57937"}, - {file = "scipy-1.11.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6df1468153a31cf55ed5ed39647279beb9cfb5d3f84369453b49e4b8502394fd"}, - {file = "scipy-1.11.4-cp39-cp39-win_amd64.whl", hash = "sha256:ee410e6de8f88fd5cf6eadd73c135020bfbbbdfcd0f6162c36a7638a1ea8cc65"}, - {file = "scipy-1.11.4.tar.gz", hash = "sha256:90a2b78e7f5733b9de748f589f09225013685f9b218275257f8a8168ededaeaa"}, -] -seaborn = [ - {file = "seaborn-0.12.2-py3-none-any.whl", hash = "sha256:ebf15355a4dba46037dfd65b7350f014ceb1f13c05e814eda2c9f5fd731afc08"}, - {file = "seaborn-0.12.2.tar.gz", hash = "sha256:374645f36509d0dcab895cba5b47daf0586f77bfe3b36c97c607db7da5be0139"}, -] -six = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, -] -soupsieve = [ - {file = "soupsieve-2.5-py3-none-any.whl", hash = "sha256:eaa337ff55a1579b6549dc679565eac1e3d000563bcb1c8ab0d0fefbc0c2cdc7"}, - {file = "soupsieve-2.5.tar.gz", hash = "sha256:5663d5a7b3bfaeee0bc4372e7fc48f9cff4940b3eec54a6451cc5299f1097690"}, -] -threadpoolctl = [ - {file = "threadpoolctl-3.2.0-py3-none-any.whl", hash = "sha256:2b7818516e423bdaebb97c723f86a7c6b0a83d3f3b0970328d66f4d9104dc032"}, - {file = "threadpoolctl-3.2.0.tar.gz", hash = "sha256:c96a0ba3bdddeaca37dc4cc7344aafad41cdb8c313f74fdfe387a867bba93355"}, -] -toml = [ - {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, - {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, -] -tomli = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, -] -torch = [ - {file = "torch-1.12.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:9c038662db894a23e49e385df13d47b2a777ffd56d9bcd5b832593fab0a7e286"}, - {file = "torch-1.12.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:4e1b9c14cf13fd2ab8d769529050629a0e68a6fc5cb8e84b4a3cc1dd8c4fe541"}, - {file = "torch-1.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:e9c8f4a311ac29fc7e8e955cfb7733deb5dbe1bdaabf5d4af2765695824b7e0d"}, - {file = "torch-1.12.1-cp310-none-macosx_10_9_x86_64.whl", hash = "sha256:976c3f997cea38ee91a0dd3c3a42322785414748d1761ef926b789dfa97c6134"}, - {file = "torch-1.12.1-cp310-none-macosx_11_0_arm64.whl", hash = "sha256:68104e4715a55c4bb29a85c6a8d57d820e0757da363be1ba680fa8cc5be17b52"}, - {file = "torch-1.12.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:743784ccea0dc8f2a3fe6a536bec8c4763bd82c1352f314937cb4008d4805de1"}, - {file = "torch-1.12.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b5dbcca369800ce99ba7ae6dee3466607a66958afca3b740690d88168752abcf"}, - {file = "torch-1.12.1-cp37-cp37m-win_amd64.whl", hash = "sha256:f3b52a634e62821e747e872084ab32fbcb01b7fa7dbb7471b6218279f02a178a"}, - {file = "torch-1.12.1-cp37-none-macosx_10_9_x86_64.whl", hash = "sha256:8a34a2fbbaa07c921e1b203f59d3d6e00ed379f2b384445773bd14e328a5b6c8"}, - {file = "torch-1.12.1-cp37-none-macosx_11_0_arm64.whl", hash = "sha256:42f639501928caabb9d1d55ddd17f07cd694de146686c24489ab8c615c2871f2"}, - {file = "torch-1.12.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:0b44601ec56f7dd44ad8afc00846051162ef9c26a8579dda0a02194327f2d55e"}, - {file = "torch-1.12.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:cd26d8c5640c3a28c526d41ccdca14cf1cbca0d0f2e14e8263a7ac17194ab1d2"}, - {file = "torch-1.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:42e115dab26f60c29e298559dbec88444175528b729ae994ec4c65d56fe267dd"}, - {file = "torch-1.12.1-cp38-none-macosx_10_9_x86_64.whl", hash = "sha256:a8320ba9ad87e80ca5a6a016e46ada4d1ba0c54626e135d99b2129a4541c509d"}, - {file = "torch-1.12.1-cp38-none-macosx_11_0_arm64.whl", hash = "sha256:03e31c37711db2cd201e02de5826de875529e45a55631d317aadce2f1ed45aa8"}, - {file = "torch-1.12.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:9b356aea223772cd754edb4d9ecf2a025909b8615a7668ac7d5130f86e7ec421"}, - {file = "torch-1.12.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:6cf6f54b43c0c30335428195589bd00e764a6d27f3b9ba637aaa8c11aaf93073"}, - {file = "torch-1.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:f00c721f489089dc6364a01fd84906348fe02243d0af737f944fddb36003400d"}, - {file = "torch-1.12.1-cp39-none-macosx_10_9_x86_64.whl", hash = "sha256:bfec2843daa654f04fda23ba823af03e7b6f7650a873cdb726752d0e3718dada"}, - {file = "torch-1.12.1-cp39-none-macosx_11_0_arm64.whl", hash = "sha256:69fe2cae7c39ccadd65a123793d30e0db881f1c1927945519c5c17323131437e"}, -] -torchmetrics = [ - {file = "torchmetrics-0.10.3-py3-none-any.whl", hash = "sha256:b12cf92897545e24a825b0d168888c0f3052700c2901e2d4f7d90b252bc4a343"}, - {file = "torchmetrics-0.10.3.tar.gz", hash = "sha256:9e6ab66175f2dc13e246c37485b2c27c77931dfe47fc2b81c76217b8efdc1e57"}, -] -torchvision = [ - {file = "torchvision-0.13.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:19286a733c69dcbd417b86793df807bd227db5786ed787c17297741a9b0d0fc7"}, - {file = "torchvision-0.13.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:08f592ea61836ebeceb5c97f4d7a813b9d7dc651bbf7ce4401563ccfae6a21fc"}, - {file = "torchvision-0.13.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:ef5fe3ec1848123cd0ec74c07658192b3147dcd38e507308c790d5943e87b88c"}, - {file = "torchvision-0.13.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:099874088df104d54d8008f2a28539ca0117b512daed8bf3c2bbfa2b7ccb187a"}, - {file = "torchvision-0.13.1-cp310-cp310-win_amd64.whl", hash = "sha256:8e4d02e4d8a203e0c09c10dfb478214c224d080d31efc0dbf36d9c4051f7f3c6"}, - {file = "torchvision-0.13.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5e631241bee3661de64f83616656224af2e3512eb2580da7c08e08b8c965a8ac"}, - {file = "torchvision-0.13.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:899eec0b9f3b99b96d6f85b9aa58c002db41c672437677b553015b9135b3be7e"}, - {file = "torchvision-0.13.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:83e9e2457f23110fd53b0177e1bc621518d6ea2108f570e853b768ce36b7c679"}, - {file = "torchvision-0.13.1-cp37-cp37m-win_amd64.whl", hash = "sha256:7552e80fa222252b8b217a951c85e172a710ea4cad0ae0c06fbb67addece7871"}, - {file = "torchvision-0.13.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f230a1a40ed70d51e463ce43df243ec520902f8725de2502e485efc5eea9d864"}, - {file = "torchvision-0.13.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e9a563894f9fa40692e24d1aa58c3ef040450017cfed3598ff9637f404f3fe3b"}, - {file = "torchvision-0.13.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7cb789ceefe6dcd0dc8eeda37bfc45efb7cf34770eac9533861d51ca508eb5b3"}, - {file = "torchvision-0.13.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:87c137f343197769a51333076e66bfcd576301d2cd8614b06657187c71b06c4f"}, - {file = "torchvision-0.13.1-cp38-cp38-win_amd64.whl", hash = "sha256:4d8bf321c4380854ef04613935fdd415dce29d1088a7ff99e06e113f0efe9203"}, - {file = "torchvision-0.13.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0298bae3b09ac361866088434008d82b99d6458fe8888c8df90720ef4b347d44"}, - {file = "torchvision-0.13.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c5ed609c8bc88c575226400b2232e0309094477c82af38952e0373edef0003fd"}, - {file = "torchvision-0.13.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:3567fb3def829229ec217c1e38f08c5128ff7fb65854cac17ebac358ff7aa309"}, - {file = "torchvision-0.13.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b167934a5943242da7b1e59318f911d2d253feeca0d13ad5d832b58eed943401"}, - {file = "torchvision-0.13.1-cp39-cp39-win_amd64.whl", hash = "sha256:0e77706cc90462653620e336bb90daf03d7bf1b88c3a9a3037df8d111823a56e"}, -] -tqdm = [ - {file = "tqdm-4.66.1-py3-none-any.whl", hash = "sha256:d302b3c5b53d47bce91fea46679d9c3c6508cf6332229aa1e7d8653723793386"}, - {file = "tqdm-4.66.1.tar.gz", hash = "sha256:d88e651f9db8d8551a62556d3cff9e3034274ca5d66e93197cf2490e2dcb69c7"}, -] -typing-extensions = [ - {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, - {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, -] -urllib3 = [ - {file = "urllib3-2.1.0-py3-none-any.whl", hash = "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3"}, - {file = "urllib3-2.1.0.tar.gz", hash = "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54"}, -] -where = [ - {file = "where-1.0.2-py2.py3-none-any.whl", hash = "sha256:66abc8edf95be7516e949d08a771f25acacff708ef481618562ab484fe5bc63e"}, - {file = "where-1.0.2.zip", hash = "sha256:325ef3a492a26189a47819f7375bc146887d39edd36fce132e86514334803fb1"}, -] -zipp = [ - {file = "zipp-3.17.0-py3-none-any.whl", hash = "sha256:0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31"}, - {file = "zipp-3.17.0.tar.gz", hash = "sha256:84e64a1c28cf7e91ed2078bb8cc8c259cb19b76942096c8d7b84947690cabaf0"}, -] +content-hash = "2bd8cd888296608cf8d150b9d2e33336d89785d2ef5718eed54ffdaed1dbc2b6" From 486d81a1e0c269725d6058faf81e31c474e1fa96 Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:19:21 -0500 Subject: [PATCH 708/762] update dependencies --- poetry.lock | 1911 +++++++++++++++++++++++----------------------- pyproject.toml | 2 +- requirements.txt | 43 +- 3 files changed, 1004 insertions(+), 952 deletions(-) diff --git a/poetry.lock b/poetry.lock index 301d0c87e..a4b0e3fa8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,95 +1,935 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +[[package]] +name = "absl-py" +version = "2.1.0" +description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py." +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "atomicwrites" +version = "1.4.1" +description = "Atomic file writes." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "attrs" +version = "23.2.0" +description = "Classes Without Boilerplate" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] +dev = ["attrs[tests]", "pre-commit"] +docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] +tests = ["attrs[tests-no-zope]", "zope-interface"] +tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] +tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] + +[[package]] +name = "beautifulsoup4" +version = "4.12.3" +description = "Screen-scraping library" +category = "main" +optional = false +python-versions = ">=3.6.0" + +[package.dependencies] +soupsieve = ">1.2" + +[package.extras] +cchardet = ["cchardet"] +chardet = ["chardet"] +charset-normalizer = ["charset-normalizer"] +html5lib = ["html5lib"] +lxml = ["lxml"] + +[[package]] +name = "cachetools" +version = "5.3.2" +description = "Extensible memoizing collections and decorators" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "certifi" +version = "2023.11.17" +description = "Python package for providing Mozilla's CA Bundle." +category = "main" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "charset-normalizer" +version = "3.3.2" +description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." +category = "main" +optional = false +python-versions = ">=3.7.0" + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" + +[[package]] +name = "contourpy" +version = "1.2.0" +description = "Python library for calculating contours of 2D quadrilateral grids" +category = "main" +optional = false +python-versions = ">=3.9" + +[package.dependencies] +numpy = ">=1.20,<2.0" + +[package.extras] +bokeh = ["bokeh", "selenium"] +docs = ["furo", "sphinx (>=7.2)", "sphinx-copybutton"] +mypy = ["contourpy[bokeh,docs]", "docutils-stubs", "mypy (==1.6.1)", "types-Pillow"] +test = ["Pillow", "contourpy[test-no-images]", "matplotlib"] +test-no-images = ["pytest", "pytest-cov", "pytest-xdist", "wurlitzer"] + +[[package]] +name = "coverage" +version = "7.4.0" +description = "Code coverage measurement for Python" +category = "dev" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} + +[package.extras] +toml = ["tomli"] + +[[package]] +name = "cycler" +version = "0.12.1" +description = "Composable style cycles" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.extras] +docs = ["ipython", "matplotlib", "numpydoc", "sphinx"] +tests = ["pytest", "pytest-cov", "pytest-xdist"] + +[[package]] +name = "filelock" +version = "3.13.1" +description = "A platform independent file lock." +category = "main" +optional = false +python-versions = ">=3.8" + +[package.extras] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +typing = ["typing-extensions (>=4.8)"] + +[[package]] +name = "fonttools" +version = "4.47.2" +description = "Tools to manipulate font files" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.extras] +all = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "fs (>=2.2.0,<3)", "lxml (>=4.0,<5)", "lz4 (>=1.7.4.2)", "matplotlib", "munkres", "pycairo", "scipy", "skia-pathops (>=0.5.0)", "sympy", "uharfbuzz (>=0.23.0)", "unicodedata2 (>=15.1.0)", "xattr", "zopfli (>=0.1.4)"] +graphite = ["lz4 (>=1.7.4.2)"] +interpolatable = ["munkres", "pycairo", "scipy"] +lxml = ["lxml (>=4.0,<5)"] +pathops = ["skia-pathops (>=0.5.0)"] +plot = ["matplotlib"] +repacker = ["uharfbuzz (>=0.23.0)"] +symfont = ["sympy"] +type1 = ["xattr"] +ufo = ["fs (>=2.2.0,<3)"] +unicode = ["unicodedata2 (>=15.1.0)"] +woff = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "zopfli (>=0.1.4)"] + +[[package]] +name = "gdown" +version = "4.7.3" +description = "Google Drive direct download of big files." +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +beautifulsoup4 = "*" +filelock = "*" +requests = {version = "*", extras = ["socks"]} +six = "*" +tqdm = "*" + +[[package]] +name = "google-auth" +version = "2.26.2" +description = "Google Authentication Library" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +cachetools = ">=2.0.0,<6.0" +pyasn1-modules = ">=0.2.1" +rsa = ">=3.1.4,<5" + +[package.extras] +aiohttp = ["aiohttp (>=3.6.2,<4.0.0.dev0)", "requests (>=2.20.0,<3.0.0.dev0)"] +enterprise-cert = ["cryptography (==36.0.2)", "pyopenssl (==22.0.0)"] +pyopenssl = ["cryptography (>=38.0.3)", "pyopenssl (>=20.0.0)"] +reauth = ["pyu2f (>=0.1.5)"] +requests = ["requests (>=2.20.0,<3.0.0.dev0)"] + +[[package]] +name = "google-auth-oauthlib" +version = "1.2.0" +description = "Google Authentication Library" +category = "main" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +google-auth = ">=2.15.0" +requests-oauthlib = ">=0.7.0" + +[package.extras] +tool = ["click (>=6.0.0)"] + +[[package]] +name = "grpcio" +version = "1.60.0" +description = "HTTP/2-based RPC framework" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +protobuf = ["grpcio-tools (>=1.60.0)"] + +[[package]] +name = "idna" +version = "3.6" +description = "Internationalized Domain Names in Applications (IDNA)" +category = "main" +optional = false +python-versions = ">=3.5" + +[[package]] +name = "importlib-metadata" +version = "7.0.1" +description = "Read metadata from Python packages" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] + +[[package]] +name = "importlib-resources" +version = "6.1.1" +description = "Read resources from Python packages" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-ruff", "zipp (>=3.17)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +category = "dev" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "itermate" +version = "1.0.2" +description = "Iterator-tools for functional programming." +category = "dev" +optional = false +python-versions = "*" + +[[package]] +name = "joblib" +version = "1.3.2" +description = "Lightweight pipelining with Python functions" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "kiwisolver" +version = "1.4.5" +description = "A fast implementation of the Cassowary constraint solver" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "markdown" +version = "3.5.2" +description = "Python implementation of John Gruber's Markdown." +category = "main" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +importlib-metadata = {version = ">=4.4", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["mdx-gh-links (>=0.2)", "mkdocs (>=1.5)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"] +testing = ["coverage", "pyyaml"] + +[[package]] +name = "markdown-it-py" +version = "3.0.0" +description = "Python port of markdown-it. Markdown parsing, done right!" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +mdurl = ">=0.1,<1.0" + +[package.extras] +benchmarking = ["psutil", "pytest", "pytest-benchmark"] +code-style = ["pre-commit (>=3.0,<4.0)"] +compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"] +linkify = ["linkify-it-py (>=1,<3)"] +plugins = ["mdit-py-plugins"] +profiling = ["gprof2dot"] +rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] +testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] + +[[package]] +name = "markupsafe" +version = "2.1.4" +description = "Safely add untrusted strings to HTML/XML markup." +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "matplotlib" +version = "3.8.2" +description = "Python plotting package" +category = "main" +optional = false +python-versions = ">=3.9" + +[package.dependencies] +contourpy = ">=1.0.1" +cycler = ">=0.10" +fonttools = ">=4.22.0" +importlib-resources = {version = ">=3.2.0", markers = "python_version < \"3.10\""} +kiwisolver = ">=1.3.1" +numpy = ">=1.21,<2" +packaging = ">=20.0" +pillow = ">=8" +pyparsing = ">=2.3.1" +python-dateutil = ">=2.7" + +[[package]] +name = "mdurl" +version = "0.1.2" +description = "Markdown URL utilities" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "numpy" +version = "1.26.3" +description = "Fundamental package for array computing in Python" +category = "main" +optional = false +python-versions = ">=3.9" + +[[package]] +name = "oauthlib" +version = "3.2.2" +description = "A generic, spec-compliant, thorough implementation of the OAuth request-signing logic" +category = "main" +optional = false +python-versions = ">=3.6" + +[package.extras] +rsa = ["cryptography (>=3.0.0)"] +signals = ["blinker (>=1.4.0)"] +signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"] + +[[package]] +name = "packaging" +version = "23.2" +description = "Core utilities for Python packages" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "pandas" +version = "1.5.3" +description = "Powerful data structures for data analysis, time series, and statistics" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +numpy = [ + {version = ">=1.20.3", markers = "python_version < \"3.10\""}, + {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, + {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, +] +python-dateutil = ">=2.8.1" +pytz = ">=2020.1" + +[package.extras] +test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] + +[[package]] +name = "pillow" +version = "9.5.0" +description = "Python Imaging Library (Fork)" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] +tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] + +[[package]] +name = "pluggy" +version = "1.3.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=3.8" + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "protobuf" +version = "4.23.4" +description = "" +category = "main" +optional = false +python-versions = ">=3.7" + +[[package]] +name = "py" +version = "1.11.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" + +[[package]] +name = "pyasn1" +version = "0.5.1" +description = "Pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208)" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" + +[[package]] +name = "pyasn1-modules" +version = "0.3.0" +description = "A collection of ASN.1-based protocols modules" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" + +[package.dependencies] +pyasn1 = ">=0.4.6,<0.6.0" + +[[package]] +name = "pygments" +version = "2.17.2" +description = "Pygments is a syntax highlighting package written in Python." +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +plugins = ["importlib-metadata"] +windows-terminal = ["colorama (>=0.4.6)"] + +[[package]] +name = "pyparsing" +version = "3.1.1" +description = "pyparsing module - Classes and methods to define and execute parsing grammars" +category = "main" +optional = false +python-versions = ">=3.6.8" + +[package.extras] +diagrams = ["jinja2", "railroad-diagrams"] + +[[package]] +name = "pysocks" +version = "1.7.1" +description = "A Python SOCKS client module. See https://github.com/Anorov/PySocks for more information." +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[[package]] +name = "pytest" +version = "6.2.5" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.dependencies] +atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} +attrs = ">=19.2.0" +colorama = {version = "*", markers = "sys_platform == \"win32\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +py = ">=1.8.2" +toml = "*" + +[package.extras] +testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] + +[[package]] +name = "pytest-cov" +version = "4.1.0" +description = "Pytest plugin for measuring coverage." +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +coverage = {version = ">=5.2.1", extras = ["toml"]} +pytest = ">=4.6" + +[package.extras] +testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] + +[[package]] +name = "pytest-shell" +version = "0.3.2" +description = "A pytest plugin to help with testing shell scripts / black box commands" +category = "dev" +optional = false +python-versions = ">=3.7,<4.0" + +[package.dependencies] +where = ">=1.0.2,<2.0.0" + +[[package]] +name = "python-dateutil" +version = "2.8.2" +description = "Extensions to the standard Python datetime module" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "pytz" +version = "2023.3.post1" +description = "World timezone definitions, modern and historical" +category = "main" +optional = false +python-versions = "*" + +[[package]] +name = "pyyaml" +version = "6.0.1" +description = "YAML parser and emitter for Python" +category = "main" +optional = false +python-versions = ">=3.6" + +[[package]] +name = "requests" +version = "2.31.0" +description = "Python HTTP for Humans." +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +certifi = ">=2017.4.17" +charset-normalizer = ">=2,<4" +idna = ">=2.5,<4" +PySocks = {version = ">=1.5.6,<1.5.7 || >1.5.7", optional = true, markers = "extra == \"socks\""} +urllib3 = ">=1.21.1,<3" + +[package.extras] +socks = ["PySocks (>=1.5.6,!=1.5.7)"] +use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] + +[[package]] +name = "requests-oauthlib" +version = "1.3.1" +description = "OAuthlib authentication support for Requests." +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[package.dependencies] +oauthlib = ">=3.0.0" +requests = ">=2.0.0" + +[package.extras] +rsa = ["oauthlib[signedtoken] (>=3.0.0)"] + +[[package]] +name = "rich" +version = "13.7.0" +description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" +category = "main" +optional = false +python-versions = ">=3.7.0" + +[package.dependencies] +markdown-it-py = ">=2.2.0" +pygments = ">=2.13.0,<3.0.0" + +[package.extras] +jupyter = ["ipywidgets (>=7.5.1,<9)"] + +[[package]] +name = "rsa" +version = "4.9" +description = "Pure-Python RSA implementation" +category = "main" +optional = false +python-versions = ">=3.6,<4" + +[package.dependencies] +pyasn1 = ">=0.1.3" + +[[package]] +name = "scikit-learn" +version = "1.4.0" +description = "A set of python modules for machine learning and data mining" +category = "main" +optional = false +python-versions = ">=3.9" + +[package.dependencies] +joblib = ">=1.2.0" +numpy = ">=1.19.5" +scipy = ">=1.6.0" +threadpoolctl = ">=2.0.0" + +[package.extras] +benchmark = ["matplotlib (>=3.3.4)", "memory-profiler (>=0.57.0)", "pandas (>=1.1.5)"] +docs = ["Pillow (>=7.1.2)", "matplotlib (>=3.3.4)", "memory-profiler (>=0.57.0)", "numpydoc (>=1.2.0)", "pandas (>=1.1.5)", "plotly (>=5.14.0)", "pooch (>=1.6.0)", "scikit-image (>=0.17.2)", "seaborn (>=0.9.0)", "sphinx (>=6.0.0)", "sphinx-copybutton (>=0.5.2)", "sphinx-gallery (>=0.15.0)", "sphinx-prompt (>=1.3.0)", "sphinxext-opengraph (>=0.4.2)"] +examples = ["matplotlib (>=3.3.4)", "pandas (>=1.1.5)", "plotly (>=5.14.0)", "pooch (>=1.6.0)", "scikit-image (>=0.17.2)", "seaborn (>=0.9.0)"] +tests = ["black (>=23.3.0)", "matplotlib (>=3.3.4)", "mypy (>=1.3)", "numpydoc (>=1.2.0)", "pandas (>=1.1.5)", "polars (>=0.19.12)", "pooch (>=1.6.0)", "pyamg (>=4.0.0)", "pyarrow (>=12.0.0)", "pytest (>=7.1.2)", "pytest-cov (>=2.9.0)", "ruff (>=0.0.272)", "scikit-image (>=0.17.2)"] + +[[package]] +name = "scipy" +version = "1.12.0" +description = "Fundamental algorithms for scientific computing in Python" +category = "main" +optional = false +python-versions = ">=3.9" + +[package.dependencies] +numpy = ">=1.22.4,<1.29.0" + +[package.extras] +dev = ["click", "cython-lint (>=0.12.2)", "doit (>=0.36.0)", "mypy", "pycodestyle", "pydevtool", "rich-click", "ruff", "types-psutil", "typing_extensions"] +doc = ["jupytext", "matplotlib (>2)", "myst-nb", "numpydoc", "pooch", "pydata-sphinx-theme (==0.9.0)", "sphinx (!=4.1.0)", "sphinx-design (>=0.2.0)"] +test = ["asv", "gmpy2", "hypothesis", "mpmath", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] + +[[package]] +name = "seaborn" +version = "0.12.2" +description = "Statistical data visualization" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +matplotlib = ">=3.1,<3.6.1 || >3.6.1" +numpy = ">=1.17,<1.24.0 || >1.24.0" +pandas = ">=0.25" + +[package.extras] +dev = ["flake8", "flit", "mypy", "pandas-stubs", "pre-commit", "pytest", "pytest-cov", "pytest-xdist"] +docs = ["ipykernel", "nbconvert", "numpydoc", "pydata_sphinx_theme (==0.10.0rc2)", "pyyaml", "sphinx-copybutton", "sphinx-design", "sphinx-issues"] +stats = ["scipy (>=1.3)", "statsmodels (>=0.10)"] [[package]] -name = "absl-py" -version = "2.1.0" -description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py." +name = "setuptools" +version = "69.0.3" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.1)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" + +[[package]] +name = "soupsieve" +version = "2.5" +description = "A modern CSS selector implementation for Beautiful Soup." +category = "main" +optional = false +python-versions = ">=3.8" + +[[package]] +name = "tensorboard" +version = "2.15.1" +description = "TensorBoard lets you watch Tensors Flow" +category = "main" +optional = false +python-versions = ">=3.9" + +[package.dependencies] +absl-py = ">=0.4" +google-auth = ">=1.6.3,<3" +google-auth-oauthlib = ">=0.5,<2" +grpcio = ">=1.48.2" +markdown = ">=2.6.8" +numpy = ">=1.12.0" +protobuf = ">=3.19.6,<4.24" +requests = ">=2.21.0,<3" +setuptools = ">=41.0.0" +six = ">1.9" +tensorboard-data-server = ">=0.7.0,<0.8.0" +werkzeug = ">=1.0.1" + +[[package]] +name = "tensorboard-data-server" +version = "0.7.2" +description = "Fast data loading for TensorBoard" +category = "main" optional = false python-versions = ">=3.7" -files = [ - {file = "absl-py-2.1.0.tar.gz", hash = "sha256:7820790efbb316739cde8b4e19357243fc3608a152024288513dd968d7d959ff"}, - {file = "absl_py-2.1.0-py3-none-any.whl", hash = "sha256:526a04eadab8b4ee719ce68f204172ead1027549089702d99b9059f129ff1308"}, -] [[package]] -name = "atomicwrites" -version = "1.4.1" -description = "Atomic file writes." +name = "threadpoolctl" +version = "3.2.0" +description = "threadpoolctl" +category = "main" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, -] +python-versions = ">=3.8" [[package]] -name = "attrs" -version = "23.2.0" -description = "Classes Without Boilerplate" +name = "toml" +version = "0.10.2" +description = "Python Library for Tom's Obvious, Minimal Language" +category = "dev" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +category = "dev" optional = false python-versions = ">=3.7" -files = [ - {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, - {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, -] + +[[package]] +name = "torch" +version = "1.12.1" +description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" +category = "main" +optional = false +python-versions = ">=3.7.0" + +[package.dependencies] +typing-extensions = "*" + +[[package]] +name = "torchmetrics" +version = "0.10.3" +description = "PyTorch native Metrics" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +numpy = ">=1.17.2" +packaging = "*" +torch = ">=1.3.1" [package.extras] -cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] -dev = ["attrs[tests]", "pre-commit"] -docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] -tests = ["attrs[tests-no-zope]", "zope-interface"] -tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] -tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] +all = ["lpips", "nltk (>=3.6)", "pycocotools", "pystoi", "pytorch-lightning (>=1.5)", "regex (>=2021.9.24)", "scipy", "torch-fidelity", "torchvision", "torchvision (>=0.8)", "tqdm (>=4.41.0)"] +audio = ["pystoi"] +detection = ["pycocotools", "torchvision (>=0.8)"] +docs = ["docutils (>=0.16)", "myst-parser", "nbsphinx (>=0.8)", "pandoc (>=1.0)", "sphinx (>=4.0,<5.0)", "sphinx-autodoc-typehints (>=1.0)", "sphinx-copybutton (>=0.3)", "sphinx-paramlinks (>=0.5.1)", "sphinx-togglebutton (>=0.2)", "sphinxcontrib-fulltoc (>=1.0)", "sphinxcontrib-mockautodoc"] +image = ["lpips", "scipy", "torch-fidelity", "torchvision"] +integrate = ["pytorch-lightning (>=1.5)"] +test = ["bert-score (==0.3.10)", "check-manifest", "cloudpickle (>=1.3)", "coverage (>5.2)", "fast-bss-eval (>=0.1.0)", "fire", "huggingface-hub (<0.7)", "jiwer (>=2.3.0)", "mir-eval (>=0.6)", "netcal", "phmdoctest (>=1.1.1)", "pre-commit (>=1.0)", "psutil", "pycocotools", "pypesq (>1.2)", "pytest (>=6.0.0,<7.0.0)", "pytest-cov (>2.10)", "pytest-doctestplus (>=0.9.0)", "pytest-timeout", "pytorch-msssim (==0.2.1)", "requests", "rouge-score (>=0.0.4)", "sacrebleu (>=2.0.0)", "scikit-image (>0.17.1)", "scikit-learn (>1.0,<1.1.1)", "torch-complex", "transformers (>=4.0)"] +text = ["nltk (>=3.6)", "regex (>=2021.9.24)", "tqdm (>=4.41.0)"] [[package]] -name = "beautifulsoup4" -version = "4.12.3" -description = "Screen-scraping library" +name = "torchvision" +version = "0.13.1" +description = "image and video datasets and models for torch deep learning" +category = "main" optional = false -python-versions = ">=3.6.0" -files = [ - {file = "beautifulsoup4-4.12.3-py3-none-any.whl", hash = "sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed"}, - {file = "beautifulsoup4-4.12.3.tar.gz", hash = "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"}, -] +python-versions = ">=3.7" [package.dependencies] -soupsieve = ">1.2" +numpy = "*" +pillow = ">=5.3.0,<8.3.0 || >=8.4.0" +requests = "*" +torch = "1.12.1" +typing-extensions = "*" [package.extras] -cchardet = ["cchardet"] -chardet = ["chardet"] -charset-normalizer = ["charset-normalizer"] -html5lib = ["html5lib"] -lxml = ["lxml"] +scipy = ["scipy"] [[package]] -name = "cachetools" -version = "5.3.2" -description = "Extensible memoizing collections and decorators" +name = "tqdm" +version = "4.66.1" +description = "Fast, Extensible Progress Meter" +category = "main" optional = false python-versions = ">=3.7" -files = [ - {file = "cachetools-5.3.2-py3-none-any.whl", hash = "sha256:861f35a13a451f94e301ce2bec7cac63e881232ccce7ed67fab9b5df4d3beaa1"}, - {file = "cachetools-5.3.2.tar.gz", hash = "sha256:086ee420196f7b2ab9ca2db2520aca326318b68fe5ba8bc4d49cca91add450f2"}, -] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[package.extras] +dev = ["pytest (>=6)", "pytest-cov", "pytest-timeout", "pytest-xdist"] +notebook = ["ipywidgets (>=6)"] +slack = ["slack-sdk"] +telegram = ["requests"] [[package]] -name = "certifi" -version = "2023.11.17" -description = "Python package for providing Mozilla's CA Bundle." +name = "typing-extensions" +version = "4.9.0" +description = "Backported and Experimental Type Hints for Python 3.8+" +category = "main" optional = false -python-versions = ">=3.6" -files = [ - {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, - {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, -] +python-versions = ">=3.8" [[package]] -name = "charset-normalizer" -version = "3.3.2" -description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." +name = "urllib3" +version = "2.1.0" +description = "HTTP library with thread-safe connection pooling, file post, and more." +category = "main" optional = false -python-versions = ">=3.7.0" -files = [ +python-versions = ">=3.8" + +[package.extras] +brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] +zstd = ["zstandard (>=0.18.0)"] + +[[package]] +name = "werkzeug" +version = "3.0.1" +description = "The comprehensive WSGI web application library." +category = "main" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +MarkupSafe = ">=2.1.1" + +[package.extras] +watchdog = ["watchdog (>=2.3)"] + +[[package]] +name = "where" +version = "1.0.2" +description = "Locates absolute file paths like the Windows 'where' or the Linux 'which' utility.\nMakes use of the PATH variable and the current directory." +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +itermate = "1.0.2" + +[[package]] +name = "zipp" +version = "3.17.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] + +[metadata] +lock-version = "1.1" +python-versions = "^3.9" +content-hash = "2c1407d821336fe731631fd9c0dbcd05f1dfef2808786d8da85a2ddbc9bcdb45" + +[metadata.files] +absl-py = [ + {file = "absl-py-2.1.0.tar.gz", hash = "sha256:7820790efbb316739cde8b4e19357243fc3608a152024288513dd968d7d959ff"}, + {file = "absl_py-2.1.0-py3-none-any.whl", hash = "sha256:526a04eadab8b4ee719ce68f204172ead1027549089702d99b9059f129ff1308"}, +] +atomicwrites = [ + {file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, +] +attrs = [ + {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, + {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, +] +beautifulsoup4 = [ + {file = "beautifulsoup4-4.12.3-py3-none-any.whl", hash = "sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed"}, + {file = "beautifulsoup4-4.12.3.tar.gz", hash = "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"}, +] +cachetools = [ + {file = "cachetools-5.3.2-py3-none-any.whl", hash = "sha256:861f35a13a451f94e301ce2bec7cac63e881232ccce7ed67fab9b5df4d3beaa1"}, + {file = "cachetools-5.3.2.tar.gz", hash = "sha256:086ee420196f7b2ab9ca2db2520aca326318b68fe5ba8bc4d49cca91add450f2"}, +] +certifi = [ + {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, + {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, +] +charset-normalizer = [ {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"}, {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"}, {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027"}, @@ -181,25 +1021,11 @@ files = [ {file = "charset_normalizer-3.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d"}, {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"}, ] - -[[package]] -name = "colorama" -version = "0.4.6" -description = "Cross-platform colored terminal text." -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -files = [ +colorama = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] - -[[package]] -name = "contourpy" -version = "1.2.0" -description = "Python library for calculating contours of 2D quadrilateral grids" -optional = false -python-versions = ">=3.9" -files = [ +contourpy = [ {file = "contourpy-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0274c1cb63625972c0c007ab14dd9ba9e199c36ae1a231ce45d725cbcbfd10a8"}, {file = "contourpy-1.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ab459a1cbbf18e8698399c595a01f6dcc5c138220ca3ea9e7e6126232d102bb4"}, {file = "contourpy-1.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fdd887f17c2f4572ce548461e4f96396681212d858cae7bd52ba3310bc6f00f"}, @@ -245,24 +1071,7 @@ files = [ {file = "contourpy-1.2.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:0d7e03c0f9a4f90dc18d4e77e9ef4ec7b7bbb437f7f675be8e530d65ae6ef956"}, {file = "contourpy-1.2.0.tar.gz", hash = "sha256:171f311cb758de7da13fc53af221ae47a5877be5a0843a9fe150818c51ed276a"}, ] - -[package.dependencies] -numpy = ">=1.20,<2.0" - -[package.extras] -bokeh = ["bokeh", "selenium"] -docs = ["furo", "sphinx (>=7.2)", "sphinx-copybutton"] -mypy = ["contourpy[bokeh,docs]", "docutils-stubs", "mypy (==1.6.1)", "types-Pillow"] -test = ["Pillow", "contourpy[test-no-images]", "matplotlib"] -test-no-images = ["pytest", "pytest-cov", "pytest-xdist", "wurlitzer"] - -[[package]] -name = "coverage" -version = "7.4.0" -description = "Code coverage measurement for Python" -optional = false -python-versions = ">=3.8" -files = [ +coverage = [ {file = "coverage-7.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36b0ea8ab20d6a7564e89cb6135920bc9188fb5f1f7152e94e8300b7b189441a"}, {file = "coverage-7.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0676cd0ba581e514b7f726495ea75aba3eb20899d824636c6f59b0ed2f88c471"}, {file = "coverage-7.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0ca5c71a5a1765a0f8f88022c52b6b8be740e512980362f7fdbb03725a0d6b9"}, @@ -316,51 +1125,15 @@ files = [ {file = "coverage-7.4.0-pp38.pp39.pp310-none-any.whl", hash = "sha256:c530833afc4707fe48524a44844493f36d8727f04dcce91fb978c414a8556cc6"}, {file = "coverage-7.4.0.tar.gz", hash = "sha256:707c0f58cb1712b8809ece32b68996ee1e609f71bd14615bd8f87a1293cb610e"}, ] - -[package.dependencies] -tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} - -[package.extras] -toml = ["tomli"] - -[[package]] -name = "cycler" -version = "0.12.1" -description = "Composable style cycles" -optional = false -python-versions = ">=3.8" -files = [ +cycler = [ {file = "cycler-0.12.1-py3-none-any.whl", hash = "sha256:85cef7cff222d8644161529808465972e51340599459b8ac3ccbac5a854e0d30"}, {file = "cycler-0.12.1.tar.gz", hash = "sha256:88bb128f02ba341da8ef447245a9e138fae777f6a23943da4540077d3601eb1c"}, ] - -[package.extras] -docs = ["ipython", "matplotlib", "numpydoc", "sphinx"] -tests = ["pytest", "pytest-cov", "pytest-xdist"] - -[[package]] -name = "filelock" -version = "3.13.1" -description = "A platform independent file lock." -optional = false -python-versions = ">=3.8" -files = [ +filelock = [ {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, ] - -[package.extras] -docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] -typing = ["typing-extensions (>=4.8)"] - -[[package]] -name = "fonttools" -version = "4.47.2" -description = "Tools to manipulate font files" -optional = false -python-versions = ">=3.8" -files = [ +fonttools = [ {file = "fonttools-4.47.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3b629108351d25512d4ea1a8393a2dba325b7b7d7308116b605ea3f8e1be88df"}, {file = "fonttools-4.47.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c19044256c44fe299d9a73456aabee4b4d06c6b930287be93b533b4737d70aa1"}, {file = "fonttools-4.47.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b8be28c036b9f186e8c7eaf8a11b42373e7e4949f9e9f370202b9da4c4c3f56c"}, @@ -404,87 +1177,19 @@ files = [ {file = "fonttools-4.47.2-py3-none-any.whl", hash = "sha256:7eb7ad665258fba68fd22228a09f347469d95a97fb88198e133595947a20a184"}, {file = "fonttools-4.47.2.tar.gz", hash = "sha256:7df26dd3650e98ca45f1e29883c96a0b9f5bb6af8d632a6a108bc744fa0bd9b3"}, ] - -[package.extras] -all = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "fs (>=2.2.0,<3)", "lxml (>=4.0,<5)", "lz4 (>=1.7.4.2)", "matplotlib", "munkres", "pycairo", "scipy", "skia-pathops (>=0.5.0)", "sympy", "uharfbuzz (>=0.23.0)", "unicodedata2 (>=15.1.0)", "xattr", "zopfli (>=0.1.4)"] -graphite = ["lz4 (>=1.7.4.2)"] -interpolatable = ["munkres", "pycairo", "scipy"] -lxml = ["lxml (>=4.0,<5)"] -pathops = ["skia-pathops (>=0.5.0)"] -plot = ["matplotlib"] -repacker = ["uharfbuzz (>=0.23.0)"] -symfont = ["sympy"] -type1 = ["xattr"] -ufo = ["fs (>=2.2.0,<3)"] -unicode = ["unicodedata2 (>=15.1.0)"] -woff = ["brotli (>=1.0.1)", "brotlicffi (>=0.8.0)", "zopfli (>=0.1.4)"] - -[[package]] -name = "gdown" -version = "4.7.3" -description = "Google Drive direct download of big files." -optional = false -python-versions = "*" -files = [ +gdown = [ {file = "gdown-4.7.3-py3-none-any.whl", hash = "sha256:aeb7b979b35efd007d0c12fee17350f007aeb5fa84a9def09381d765075ba9ce"}, {file = "gdown-4.7.3.tar.gz", hash = "sha256:37edc3a0edda1a7fe5ebcc631c3aad0612582766460630ee52f481ba1ec7aefe"}, ] - -[package.dependencies] -beautifulsoup4 = "*" -filelock = "*" -requests = {version = "*", extras = ["socks"]} -six = "*" -tqdm = "*" - -[[package]] -name = "google-auth" -version = "2.26.2" -description = "Google Authentication Library" -optional = false -python-versions = ">=3.7" -files = [ +google-auth = [ {file = "google-auth-2.26.2.tar.gz", hash = "sha256:97327dbbf58cccb58fc5a1712bba403ae76668e64814eb30f7316f7e27126b81"}, {file = "google_auth-2.26.2-py2.py3-none-any.whl", hash = "sha256:3f445c8ce9b61ed6459aad86d8ccdba4a9afed841b2d1451a11ef4db08957424"}, ] - -[package.dependencies] -cachetools = ">=2.0.0,<6.0" -pyasn1-modules = ">=0.2.1" -rsa = ">=3.1.4,<5" - -[package.extras] -aiohttp = ["aiohttp (>=3.6.2,<4.0.0.dev0)", "requests (>=2.20.0,<3.0.0.dev0)"] -enterprise-cert = ["cryptography (==36.0.2)", "pyopenssl (==22.0.0)"] -pyopenssl = ["cryptography (>=38.0.3)", "pyopenssl (>=20.0.0)"] -reauth = ["pyu2f (>=0.1.5)"] -requests = ["requests (>=2.20.0,<3.0.0.dev0)"] - -[[package]] -name = "google-auth-oauthlib" -version = "1.2.0" -description = "Google Authentication Library" -optional = false -python-versions = ">=3.6" -files = [ +google-auth-oauthlib = [ {file = "google-auth-oauthlib-1.2.0.tar.gz", hash = "sha256:292d2d3783349f2b0734a0a0207b1e1e322ac193c2c09d8f7c613fb7cc501ea8"}, {file = "google_auth_oauthlib-1.2.0-py2.py3-none-any.whl", hash = "sha256:297c1ce4cb13a99b5834c74a1fe03252e1e499716718b190f56bcb9c4abc4faf"}, ] - -[package.dependencies] -google-auth = ">=2.15.0" -requests-oauthlib = ">=0.7.0" - -[package.extras] -tool = ["click (>=6.0.0)"] - -[[package]] -name = "grpcio" -version = "1.60.0" -description = "HTTP/2-based RPC framework" -optional = false -python-versions = ">=3.7" -files = [ +grpcio = [ {file = "grpcio-1.60.0-cp310-cp310-linux_armv7l.whl", hash = "sha256:d020cfa595d1f8f5c6b343530cd3ca16ae5aefdd1e832b777f9f0eb105f5b139"}, {file = "grpcio-1.60.0-cp310-cp310-macosx_12_0_universal2.whl", hash = "sha256:b98f43fcdb16172dec5f4b49f2fece4b16a99fd284d81c6bbac1b3b69fcbe0ff"}, {file = "grpcio-1.60.0-cp310-cp310-manylinux_2_17_aarch64.whl", hash = "sha256:20e7a4f7ded59097c84059d28230907cd97130fa74f4a8bfd1d8e5ba18c81491"}, @@ -540,98 +1245,31 @@ files = [ {file = "grpcio-1.60.0-cp39-cp39-win_amd64.whl", hash = "sha256:8a97a681e82bc11a42d4372fe57898d270a2707f36c45c6676e49ce0d5c41353"}, {file = "grpcio-1.60.0.tar.gz", hash = "sha256:2199165a1affb666aa24adf0c97436686d0a61bc5fc113c037701fb7c7fceb96"}, ] - -[package.extras] -protobuf = ["grpcio-tools (>=1.60.0)"] - -[[package]] -name = "idna" -version = "3.6" -description = "Internationalized Domain Names in Applications (IDNA)" -optional = false -python-versions = ">=3.5" -files = [ +idna = [ {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, ] - -[[package]] -name = "importlib-metadata" -version = "7.0.1" -description = "Read metadata from Python packages" -optional = false -python-versions = ">=3.8" -files = [ +importlib-metadata = [ {file = "importlib_metadata-7.0.1-py3-none-any.whl", hash = "sha256:4805911c3a4ec7c3966410053e9ec6a1fecd629117df5adee56dfc9432a1081e"}, {file = "importlib_metadata-7.0.1.tar.gz", hash = "sha256:f238736bb06590ae52ac1fab06a3a9ef1d8dce2b7a35b5ab329371d6c8f5d2cc"}, ] - -[package.dependencies] -zipp = ">=0.5" - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -perf = ["ipython"] -testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] - -[[package]] -name = "importlib-resources" -version = "6.1.1" -description = "Read resources from Python packages" -optional = false -python-versions = ">=3.8" -files = [ +importlib-resources = [ {file = "importlib_resources-6.1.1-py3-none-any.whl", hash = "sha256:e8bf90d8213b486f428c9c39714b920041cb02c184686a3dee24905aaa8105d6"}, {file = "importlib_resources-6.1.1.tar.gz", hash = "sha256:3893a00122eafde6894c59914446a512f728a0c1a45f9bb9b63721b6bacf0b4a"}, ] - -[package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-ruff", "zipp (>=3.17)"] - -[[package]] -name = "iniconfig" -version = "2.0.0" -description = "brain-dead simple config-ini parsing" -optional = false -python-versions = ">=3.7" -files = [ +iniconfig = [ {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] - -[[package]] -name = "itermate" -version = "1.0.2" -description = "Iterator-tools for functional programming." -optional = false -python-versions = "*" -files = [ +itermate = [ {file = "itermate-1.0.2-py2-none-any.whl", hash = "sha256:00308991e0fe54465e0e0fbec4d47180b4f6df0f26c1e5d2ce3641e3373f28a0"}, {file = "itermate-1.0.2.zip", hash = "sha256:5ee758cbb363493156cee7a29effc2b148a1a19d2be3097e92fc824991901e2a"}, ] - -[[package]] -name = "joblib" -version = "1.3.2" -description = "Lightweight pipelining with Python functions" -optional = false -python-versions = ">=3.7" -files = [ +joblib = [ {file = "joblib-1.3.2-py3-none-any.whl", hash = "sha256:ef4331c65f239985f3f2220ecc87db222f08fd22097a3dd5698f693875f8cbb9"}, {file = "joblib-1.3.2.tar.gz", hash = "sha256:92f865e621e17784e7955080b6d042489e3b8e294949cc44c6eac304f59772b1"}, ] - -[[package]] -name = "kiwisolver" -version = "1.4.5" -description = "A fast implementation of the Cassowary constraint solver" -optional = false -python-versions = ">=3.7" -files = [ +kiwisolver = [ {file = "kiwisolver-1.4.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:05703cf211d585109fcd72207a31bb170a0f22144d68298dc5e61b3c946518af"}, {file = "kiwisolver-1.4.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:146d14bebb7f1dc4d5fbf74f8a6cb15ac42baadee8912eb84ac0b3b2a3dc6ac3"}, {file = "kiwisolver-1.4.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6ef7afcd2d281494c0a9101d5c571970708ad911d028137cd558f02b851c08b4"}, @@ -737,56 +1375,15 @@ files = [ {file = "kiwisolver-1.4.5-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:11d011a7574eb3b82bcc9c1a1d35c1d7075677fdd15de527d91b46bd35e935ee"}, {file = "kiwisolver-1.4.5.tar.gz", hash = "sha256:e57e563a57fb22a142da34f38acc2fc1a5c864bc29ca1517a88abc963e60d6ec"}, ] - -[[package]] -name = "markdown" -version = "3.5.2" -description = "Python implementation of John Gruber's Markdown." -optional = false -python-versions = ">=3.8" -files = [ +markdown = [ {file = "Markdown-3.5.2-py3-none-any.whl", hash = "sha256:d43323865d89fc0cb9b20c75fc8ad313af307cc087e84b657d9eec768eddeadd"}, {file = "Markdown-3.5.2.tar.gz", hash = "sha256:e1ac7b3dc550ee80e602e71c1d168002f062e49f1b11e26a36264dafd4df2ef8"}, ] - -[package.dependencies] -importlib-metadata = {version = ">=4.4", markers = "python_version < \"3.10\""} - -[package.extras] -docs = ["mdx-gh-links (>=0.2)", "mkdocs (>=1.5)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"] -testing = ["coverage", "pyyaml"] - -[[package]] -name = "markdown-it-py" -version = "3.0.0" -description = "Python port of markdown-it. Markdown parsing, done right!" -optional = false -python-versions = ">=3.8" -files = [ +markdown-it-py = [ {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, ] - -[package.dependencies] -mdurl = ">=0.1,<1.0" - -[package.extras] -benchmarking = ["psutil", "pytest", "pytest-benchmark"] -code-style = ["pre-commit (>=3.0,<4.0)"] -compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"] -linkify = ["linkify-it-py (>=1,<3)"] -plugins = ["mdit-py-plugins"] -profiling = ["gprof2dot"] -rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] -testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] - -[[package]] -name = "markupsafe" -version = "2.1.4" -description = "Safely add untrusted strings to HTML/XML markup." -optional = false -python-versions = ">=3.7" -files = [ +markupsafe = [ {file = "MarkupSafe-2.1.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:de8153a7aae3835484ac168a9a9bdaa0c5eee4e0bc595503c95d53b942879c84"}, {file = "MarkupSafe-2.1.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e888ff76ceb39601c59e219f281466c6d7e66bd375b4ec1ce83bcdc68306796b"}, {file = "MarkupSafe-2.1.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0b838c37ba596fcbfca71651a104a611543077156cb0a26fe0c475e1f152ee8"}, @@ -848,14 +1445,7 @@ files = [ {file = "MarkupSafe-2.1.4-cp39-cp39-win_amd64.whl", hash = "sha256:8b570a1537367b52396e53325769608f2a687ec9a4363647af1cded8928af959"}, {file = "MarkupSafe-2.1.4.tar.gz", hash = "sha256:3aae9af4cac263007fd6309c64c6ab4506dd2b79382d9d19a1994f9240b8db4f"}, ] - -[[package]] -name = "matplotlib" -version = "3.8.2" -description = "Python plotting package" -optional = false -python-versions = ">=3.9" -files = [ +matplotlib = [ {file = "matplotlib-3.8.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:09796f89fb71a0c0e1e2f4bdaf63fb2cefc84446bb963ecdeb40dfee7dfa98c7"}, {file = "matplotlib-3.8.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6f9c6976748a25e8b9be51ea028df49b8e561eed7809146da7a47dbecebab367"}, {file = "matplotlib-3.8.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b78e4f2cedf303869b782071b55fdde5987fda3038e9d09e58c91cc261b5ad18"}, @@ -884,38 +1474,12 @@ files = [ {file = "matplotlib-3.8.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d1095fecf99eeb7384dabad4bf44b965f929a5f6079654b681193edf7169ec20"}, {file = "matplotlib-3.8.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:bddfb1db89bfaa855912261c805bd0e10218923cc262b9159a49c29a7a1c1afa"}, {file = "matplotlib-3.8.2.tar.gz", hash = "sha256:01a978b871b881ee76017152f1f1a0cbf6bd5f7b8ff8c96df0df1bd57d8755a1"}, -] - -[package.dependencies] -contourpy = ">=1.0.1" -cycler = ">=0.10" -fonttools = ">=4.22.0" -importlib-resources = {version = ">=3.2.0", markers = "python_version < \"3.10\""} -kiwisolver = ">=1.3.1" -numpy = ">=1.21,<2" -packaging = ">=20.0" -pillow = ">=8" -pyparsing = ">=2.3.1" -python-dateutil = ">=2.7" - -[[package]] -name = "mdurl" -version = "0.1.2" -description = "Markdown URL utilities" -optional = false -python-versions = ">=3.7" -files = [ +] +mdurl = [ {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, ] - -[[package]] -name = "numpy" -version = "1.26.3" -description = "Fundamental package for array computing in Python" -optional = false -python-versions = ">=3.9" -files = [ +numpy = [ {file = "numpy-1.26.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:806dd64230dbbfaca8a27faa64e2f414bf1c6622ab78cc4264f7f5f028fee3bf"}, {file = "numpy-1.26.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:02f98011ba4ab17f46f80f7f8f1c291ee7d855fcef0a5a98db80767a468c85cd"}, {file = "numpy-1.26.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d45b3ec2faed4baca41c76617fcdcfa4f684ff7a151ce6fc78ad3b6e85af0a6"}, @@ -953,41 +1517,15 @@ files = [ {file = "numpy-1.26.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a8474703bffc65ca15853d5fd4d06b18138ae90c17c8d12169968e998e448bb5"}, {file = "numpy-1.26.3.tar.gz", hash = "sha256:697df43e2b6310ecc9d95f05d5ef20eacc09c7c4ecc9da3f235d39e71b7da1e4"}, ] - -[[package]] -name = "oauthlib" -version = "3.2.2" -description = "A generic, spec-compliant, thorough implementation of the OAuth request-signing logic" -optional = false -python-versions = ">=3.6" -files = [ +oauthlib = [ {file = "oauthlib-3.2.2-py3-none-any.whl", hash = "sha256:8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca"}, {file = "oauthlib-3.2.2.tar.gz", hash = "sha256:9859c40929662bec5d64f34d01c99e093149682a3f38915dc0655d5a633dd918"}, ] - -[package.extras] -rsa = ["cryptography (>=3.0.0)"] -signals = ["blinker (>=1.4.0)"] -signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"] - -[[package]] -name = "packaging" -version = "23.2" -description = "Core utilities for Python packages" -optional = false -python-versions = ">=3.7" -files = [ +packaging = [ {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, ] - -[[package]] -name = "pandas" -version = "1.5.3" -description = "Powerful data structures for data analysis, time series, and statistics" -optional = false -python-versions = ">=3.8" -files = [ +pandas = [ {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3749077d86e3a2f0ed51367f30bf5b82e131cc0f14260c4d3e499186fccc4406"}, {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:972d8a45395f2a2d26733eb8d0f629b2f90bebe8e8eddbb8829b180c09639572"}, {file = "pandas-1.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:50869a35cbb0f2e0cd5ec04b191e7b12ed688874bd05dd777c19b28cbea90996"}, @@ -1016,26 +1554,7 @@ files = [ {file = "pandas-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:dfd681c5dc216037e0b0a2c821f5ed99ba9f03ebcf119c7dac0e9a7b960b9ec9"}, {file = "pandas-1.5.3.tar.gz", hash = "sha256:74a3fd7e5a7ec052f183273dc7b0acd3a863edf7520f5d3a1765c04ffdb3b0b1"}, ] - -[package.dependencies] -numpy = [ - {version = ">=1.20.3", markers = "python_version < \"3.10\""}, - {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, - {version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""}, -] -python-dateutil = ">=2.8.1" -pytz = ">=2020.1" - -[package.extras] -test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] - -[[package]] -name = "pillow" -version = "9.5.0" -description = "Python Imaging Library (Fork)" -optional = false -python-versions = ">=3.7" -files = [ +pillow = [ {file = "Pillow-9.5.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:ace6ca218308447b9077c14ea4ef381ba0b67ee78d64046b3f19cf4e1139ad16"}, {file = "Pillow-9.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d3d403753c9d5adc04d4694d35cf0391f0f3d57c8e0030aac09d7678fa8030aa"}, {file = "Pillow-9.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5ba1b81ee69573fe7124881762bb4cd2e4b6ed9dd28c9c60a632902fe8db8b38"}, @@ -1103,33 +1622,11 @@ files = [ {file = "Pillow-9.5.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:1e7723bd90ef94eda669a3c2c19d549874dd5badaeefabefd26053304abe5799"}, {file = "Pillow-9.5.0.tar.gz", hash = "sha256:bf548479d336726d7a0eceb6e767e179fbde37833ae42794602631a070d630f1"}, ] - -[package.extras] -docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] -tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] - -[[package]] -name = "pluggy" -version = "1.3.0" -description = "plugin and hook calling mechanisms for python" -optional = false -python-versions = ">=3.8" -files = [ +pluggy = [ {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, ] - -[package.extras] -dev = ["pre-commit", "tox"] -testing = ["pytest", "pytest-benchmark"] - -[[package]] -name = "protobuf" -version = "4.23.4" -description = "" -optional = false -python-versions = ">=3.7" -files = [ +protobuf = [ {file = "protobuf-4.23.4-cp310-abi3-win32.whl", hash = "sha256:5fea3c64d41ea5ecf5697b83e41d09b9589e6f20b677ab3c48e5f242d9b7897b"}, {file = "protobuf-4.23.4-cp310-abi3-win_amd64.whl", hash = "sha256:7b19b6266d92ca6a2a87effa88ecc4af73ebc5cfde194dc737cf8ef23a9a3b12"}, {file = "protobuf-4.23.4-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:8547bf44fe8cec3c69e3042f5c4fb3e36eb2a7a013bb0a44c018fc1e427aafbd"}, @@ -1144,178 +1641,57 @@ files = [ {file = "protobuf-4.23.4-py3-none-any.whl", hash = "sha256:e9d0be5bf34b275b9f87ba7407796556abeeba635455d036c7351f7c183ef8ff"}, {file = "protobuf-4.23.4.tar.gz", hash = "sha256:ccd9430c0719dce806b93f89c91de7977304729e55377f872a92465d548329a9"}, ] - -[[package]] -name = "py" -version = "1.11.0" -description = "library with cross-python path, ini-parsing, io, code, log facilities" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -files = [ +py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] - -[[package]] -name = "pyasn1" -version = "0.5.1" -description = "Pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208)" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" -files = [ +pyasn1 = [ {file = "pyasn1-0.5.1-py2.py3-none-any.whl", hash = "sha256:4439847c58d40b1d0a573d07e3856e95333f1976294494c325775aeca506eb58"}, {file = "pyasn1-0.5.1.tar.gz", hash = "sha256:6d391a96e59b23130a5cfa74d6fd7f388dbbe26cc8f1edf39fdddf08d9d6676c"}, ] - -[[package]] -name = "pyasn1-modules" -version = "0.3.0" -description = "A collection of ASN.1-based protocols modules" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" -files = [ +pyasn1-modules = [ {file = "pyasn1_modules-0.3.0-py2.py3-none-any.whl", hash = "sha256:d3ccd6ed470d9ffbc716be08bd90efbd44d0734bc9303818f7336070984a162d"}, {file = "pyasn1_modules-0.3.0.tar.gz", hash = "sha256:5bd01446b736eb9d31512a30d46c1ac3395d676c6f3cafa4c03eb54b9925631c"}, ] - -[package.dependencies] -pyasn1 = ">=0.4.6,<0.6.0" - -[[package]] -name = "pygments" -version = "2.17.2" -description = "Pygments is a syntax highlighting package written in Python." -optional = false -python-versions = ">=3.7" -files = [ +pygments = [ {file = "pygments-2.17.2-py3-none-any.whl", hash = "sha256:b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c"}, {file = "pygments-2.17.2.tar.gz", hash = "sha256:da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"}, ] - -[package.extras] -plugins = ["importlib-metadata"] -windows-terminal = ["colorama (>=0.4.6)"] - -[[package]] -name = "pyparsing" -version = "3.1.1" -description = "pyparsing module - Classes and methods to define and execute parsing grammars" -optional = false -python-versions = ">=3.6.8" -files = [ +pyparsing = [ {file = "pyparsing-3.1.1-py3-none-any.whl", hash = "sha256:32c7c0b711493c72ff18a981d24f28aaf9c1fb7ed5e9667c9e84e3db623bdbfb"}, {file = "pyparsing-3.1.1.tar.gz", hash = "sha256:ede28a1a32462f5a9705e07aea48001a08f7cf81a021585011deba701581a0db"}, ] - -[package.extras] -diagrams = ["jinja2", "railroad-diagrams"] - -[[package]] -name = "pysocks" -version = "1.7.1" -description = "A Python SOCKS client module. See https://github.com/Anorov/PySocks for more information." -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ +pysocks = [ {file = "PySocks-1.7.1-py27-none-any.whl", hash = "sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299"}, {file = "PySocks-1.7.1-py3-none-any.whl", hash = "sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5"}, {file = "PySocks-1.7.1.tar.gz", hash = "sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0"}, ] - -[[package]] -name = "pytest" -version = "6.2.5" -description = "pytest: simple powerful testing with Python" -optional = false -python-versions = ">=3.6" -files = [ +pytest = [ {file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"}, {file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"}, ] - -[package.dependencies] -atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} -attrs = ">=19.2.0" -colorama = {version = "*", markers = "sys_platform == \"win32\""} -iniconfig = "*" -packaging = "*" -pluggy = ">=0.12,<2.0" -py = ">=1.8.2" -toml = "*" - -[package.extras] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] - -[[package]] -name = "pytest-cov" -version = "4.1.0" -description = "Pytest plugin for measuring coverage." -optional = false -python-versions = ">=3.7" -files = [ +pytest-cov = [ {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, ] - -[package.dependencies] -coverage = {version = ">=5.2.1", extras = ["toml"]} -pytest = ">=4.6" - -[package.extras] -testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] - -[[package]] -name = "pytest-shell" -version = "0.3.2" -description = "A pytest plugin to help with testing shell scripts / black box commands" -optional = false -python-versions = ">=3.7,<4.0" -files = [ +pytest-shell = [ {file = "pytest-shell-0.3.2.tar.gz", hash = "sha256:7e30cf518a5271328f25eaa9013e1639607f169d7396a4b85204a8b34dacbab1"}, {file = "pytest_shell-0.3.2-py3-none-any.whl", hash = "sha256:f60716134fc30e2c1fe9facb9fe60121d18b4d7b95e692b2c6f29271350aa12b"}, ] - -[package.dependencies] -where = ">=1.0.2,<2.0.0" - -[[package]] -name = "python-dateutil" -version = "2.8.2" -description = "Extensions to the standard Python datetime module" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -files = [ +python-dateutil = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, ] - -[package.dependencies] -six = ">=1.5" - -[[package]] -name = "pytz" -version = "2023.3.post1" -description = "World timezone definitions, modern and historical" -optional = false -python-versions = "*" -files = [ +pytz = [ {file = "pytz-2023.3.post1-py2.py3-none-any.whl", hash = "sha256:ce42d816b81b68506614c11e8937d3aa9e41007ceb50bfdcb0749b921bf646c7"}, {file = "pytz-2023.3.post1.tar.gz", hash = "sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b"}, ] - -[[package]] -name = "pyyaml" -version = "6.0.1" -description = "YAML parser and emitter for Python" -optional = false -python-versions = ">=3.6" -files = [ +pyyaml = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, - {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -1323,16 +1699,8 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, - {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, - {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, - {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, - {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1349,7 +1717,6 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, - {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1357,112 +1724,28 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, - {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, ] - -[[package]] -name = "requests" -version = "2.31.0" -description = "Python HTTP for Humans." -optional = false -python-versions = ">=3.7" -files = [ +requests = [ {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"}, - {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, -] - -[package.dependencies] -certifi = ">=2017.4.17" -charset-normalizer = ">=2,<4" -idna = ">=2.5,<4" -PySocks = {version = ">=1.5.6,<1.5.7 || >1.5.7", optional = true, markers = "extra == \"socks\""} -urllib3 = ">=1.21.1,<3" - -[package.extras] -socks = ["PySocks (>=1.5.6,!=1.5.7)"] -use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] - -[[package]] -name = "requests-oauthlib" -version = "1.3.1" -description = "OAuthlib authentication support for Requests." -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "requests-oauthlib-1.3.1.tar.gz", hash = "sha256:75beac4a47881eeb94d5ea5d6ad31ef88856affe2332b9aafb52c6452ccf0d7a"}, - {file = "requests_oauthlib-1.3.1-py2.py3-none-any.whl", hash = "sha256:2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5"}, -] - -[package.dependencies] -oauthlib = ">=3.0.0" -requests = ">=2.0.0" - -[package.extras] -rsa = ["oauthlib[signedtoken] (>=3.0.0)"] - -[[package]] -name = "rich" -version = "13.7.0" -description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -optional = false -python-versions = ">=3.7.0" -files = [ - {file = "rich-13.7.0-py3-none-any.whl", hash = "sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235"}, - {file = "rich-13.7.0.tar.gz", hash = "sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa"}, -] - -[package.dependencies] -markdown-it-py = ">=2.2.0" -pygments = ">=2.13.0,<3.0.0" - -[package.extras] -jupyter = ["ipywidgets (>=7.5.1,<9)"] - -[[package]] -name = "rsa" -version = "4.9" -description = "Pure-Python RSA implementation" -optional = false -python-versions = ">=3.6,<4" -files = [ + {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, +] +requests-oauthlib = [ + {file = "requests-oauthlib-1.3.1.tar.gz", hash = "sha256:75beac4a47881eeb94d5ea5d6ad31ef88856affe2332b9aafb52c6452ccf0d7a"}, + {file = "requests_oauthlib-1.3.1-py2.py3-none-any.whl", hash = "sha256:2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5"}, +] +rich = [ + {file = "rich-13.7.0-py3-none-any.whl", hash = "sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235"}, + {file = "rich-13.7.0.tar.gz", hash = "sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa"}, +] +rsa = [ {file = "rsa-4.9-py3-none-any.whl", hash = "sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7"}, {file = "rsa-4.9.tar.gz", hash = "sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21"}, ] - -[package.dependencies] -pyasn1 = ">=0.1.3" - -[[package]] -name = "scikit-learn" -version = "1.4.0" -description = "A set of python modules for machine learning and data mining" -optional = false -python-versions = ">=3.9" -files = [ +scikit-learn = [ {file = "scikit-learn-1.4.0.tar.gz", hash = "sha256:d4373c984eba20e393216edd51a3e3eede56cbe93d4247516d205643c3b93121"}, - {file = "scikit_learn-1.4.0-1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:fce93a7473e2f4ee4cc280210968288d6a7d7ad8dc6fa7bb7892145e407085f9"}, - {file = "scikit_learn-1.4.0-1-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:d77df3d1e15fc37a9329999979fa7868ba8655dbab21fe97fc7ddabac9e08cc7"}, - {file = "scikit_learn-1.4.0-1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2404659fedec40eeafa310cd14d613e564d13dbf8f3c752d31c095195ec05de6"}, - {file = "scikit_learn-1.4.0-1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e98632da8f6410e6fb6bf66937712c949b4010600ccd3f22a5388a83e610cc3c"}, - {file = "scikit_learn-1.4.0-1-cp310-cp310-win_amd64.whl", hash = "sha256:11b3b140f70fbc9f6a08884631ae8dd60a4bb2d7d6d1de92738ea42b740d8992"}, - {file = "scikit_learn-1.4.0-1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a8341eabdc754d5ab91641a7763243845e96b6d68e03e472531e88a4f1b09f21"}, - {file = "scikit_learn-1.4.0-1-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:d1f6bce875ac2bb6b52514f67c185c564ccd299a05b65b7bab091a4c13dde12d"}, - {file = "scikit_learn-1.4.0-1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c408b46b2fd61952d519ea1af2f8f0a7a703e1433923ab1704c4131520b2083b"}, - {file = "scikit_learn-1.4.0-1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2b465dd1dcd237b7b1dcd1a9048ccbf70a98c659474324fa708464c3a2533fad"}, - {file = "scikit_learn-1.4.0-1-cp311-cp311-win_amd64.whl", hash = "sha256:0db8e22c42f7980fe5eb22069b1f84c48966f3e0d23a01afde5999e3987a2501"}, - {file = "scikit_learn-1.4.0-1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:e7eef6ea2ed289af40e88c0be9f7704ca8b5de18508a06897c3fe21e0905efdf"}, - {file = "scikit_learn-1.4.0-1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:349669b01435bc4dbf25c6410b0892073befdaec52637d1a1d1ff53865dc8db3"}, - {file = "scikit_learn-1.4.0-1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d439c584e58434d0350701bd33f6c10b309e851fccaf41c121aed55f6851d8cf"}, - {file = "scikit_learn-1.4.0-1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0e2427d9ef46477625ab9b55c1882844fe6fc500f418c3f8e650200182457bc"}, - {file = "scikit_learn-1.4.0-1-cp312-cp312-win_amd64.whl", hash = "sha256:d3d75343940e7bf9b85c830c93d34039fa015eeb341c5c0b4cd7a90dadfe00d4"}, - {file = "scikit_learn-1.4.0-1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:76986d22e884ab062b1beecdd92379656e9d3789ecc1f9870923c178de55f9fe"}, - {file = "scikit_learn-1.4.0-1-cp39-cp39-macosx_12_0_arm64.whl", hash = "sha256:e22446ad89f1cb7657f0d849dcdc345b48e2d10afa3daf2925fdb740f85b714c"}, - {file = "scikit_learn-1.4.0-1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74812c9eabb265be69d738a8ea8d4884917a59637fcbf88a5f0e9020498bc6b3"}, - {file = "scikit_learn-1.4.0-1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aad2a63e0dd386b92da3270887a29b308af4d7c750d8c4995dfd9a4798691bcc"}, - {file = "scikit_learn-1.4.0-1-cp39-cp39-win_amd64.whl", hash = "sha256:53b9e29177897c37e2ff9d4ba6ca12fdb156e22523e463db05def303f5c72b5c"}, {file = "scikit_learn-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:cb8f044a8f5962613ce1feb4351d66f8d784bd072d36393582f351859b065f7d"}, {file = "scikit_learn-1.4.0-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:a6372c90bbf302387792108379f1ec77719c1618d88496d0df30cb8e370b4661"}, {file = "scikit_learn-1.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:785ce3c352bf697adfda357c3922c94517a9376002971bc5ea50896144bc8916"}, @@ -1484,26 +1767,7 @@ files = [ {file = "scikit_learn-1.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:923d778f378ebacca2c672ab1740e5a413e437fb45ab45ab02578f8b689e5d43"}, {file = "scikit_learn-1.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:1d041bc95006b545b59e458399e3175ab11ca7a03dc9a74a573ac891f5df1489"}, ] - -[package.dependencies] -joblib = ">=1.2.0" -numpy = ">=1.19.5" -scipy = ">=1.6.0" -threadpoolctl = ">=2.0.0" - -[package.extras] -benchmark = ["matplotlib (>=3.3.4)", "memory-profiler (>=0.57.0)", "pandas (>=1.1.5)"] -docs = ["Pillow (>=7.1.2)", "matplotlib (>=3.3.4)", "memory-profiler (>=0.57.0)", "numpydoc (>=1.2.0)", "pandas (>=1.1.5)", "plotly (>=5.14.0)", "pooch (>=1.6.0)", "scikit-image (>=0.17.2)", "seaborn (>=0.9.0)", "sphinx (>=6.0.0)", "sphinx-copybutton (>=0.5.2)", "sphinx-gallery (>=0.15.0)", "sphinx-prompt (>=1.3.0)", "sphinxext-opengraph (>=0.4.2)"] -examples = ["matplotlib (>=3.3.4)", "pandas (>=1.1.5)", "plotly (>=5.14.0)", "pooch (>=1.6.0)", "scikit-image (>=0.17.2)", "seaborn (>=0.9.0)"] -tests = ["black (>=23.3.0)", "matplotlib (>=3.3.4)", "mypy (>=1.3)", "numpydoc (>=1.2.0)", "pandas (>=1.1.5)", "polars (>=0.19.12)", "pooch (>=1.6.0)", "pyamg (>=4.0.0)", "pyarrow (>=12.0.0)", "pytest (>=7.1.2)", "pytest-cov (>=2.9.0)", "ruff (>=0.0.272)", "scikit-image (>=0.17.2)"] - -[[package]] -name = "scipy" -version = "1.12.0" -description = "Fundamental algorithms for scientific computing in Python" -optional = false -python-versions = ">=3.9" -files = [ +scipy = [ {file = "scipy-1.12.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:78e4402e140879387187f7f25d91cc592b3501a2e51dfb320f48dfb73565f10b"}, {file = "scipy-1.12.0-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:f5f00ebaf8de24d14b8449981a2842d404152774c1a1d880c901bf454cb8e2a1"}, {file = "scipy-1.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e53958531a7c695ff66c2e7bb7b79560ffdc562e2051644c5576c39ff8efb563"}, @@ -1530,150 +1794,43 @@ files = [ {file = "scipy-1.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:b360f1b6b2f742781299514e99ff560d1fe9bd1bff2712894b52abe528d1fd1e"}, {file = "scipy-1.12.0.tar.gz", hash = "sha256:4bf5abab8a36d20193c698b0f1fc282c1d083c94723902c447e5d2f1780936a3"}, ] - -[package.dependencies] -numpy = ">=1.22.4,<1.29.0" - -[package.extras] -dev = ["click", "cython-lint (>=0.12.2)", "doit (>=0.36.0)", "mypy", "pycodestyle", "pydevtool", "rich-click", "ruff", "types-psutil", "typing_extensions"] -doc = ["jupytext", "matplotlib (>2)", "myst-nb", "numpydoc", "pooch", "pydata-sphinx-theme (==0.9.0)", "sphinx (!=4.1.0)", "sphinx-design (>=0.2.0)"] -test = ["asv", "gmpy2", "hypothesis", "mpmath", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] - -[[package]] -name = "seaborn" -version = "0.12.2" -description = "Statistical data visualization" -optional = false -python-versions = ">=3.7" -files = [ +seaborn = [ {file = "seaborn-0.12.2-py3-none-any.whl", hash = "sha256:ebf15355a4dba46037dfd65b7350f014ceb1f13c05e814eda2c9f5fd731afc08"}, {file = "seaborn-0.12.2.tar.gz", hash = "sha256:374645f36509d0dcab895cba5b47daf0586f77bfe3b36c97c607db7da5be0139"}, ] - -[package.dependencies] -matplotlib = ">=3.1,<3.6.1 || >3.6.1" -numpy = ">=1.17,<1.24.0 || >1.24.0" -pandas = ">=0.25" - -[package.extras] -dev = ["flake8", "flit", "mypy", "pandas-stubs", "pre-commit", "pytest", "pytest-cov", "pytest-xdist"] -docs = ["ipykernel", "nbconvert", "numpydoc", "pydata_sphinx_theme (==0.10.0rc2)", "pyyaml", "sphinx-copybutton", "sphinx-design", "sphinx-issues"] -stats = ["scipy (>=1.3)", "statsmodels (>=0.10)"] - -[[package]] -name = "setuptools" -version = "69.0.3" -description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = false -python-versions = ">=3.8" -files = [ +setuptools = [ {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, {file = "setuptools-69.0.3.tar.gz", hash = "sha256:be1af57fc409f93647f2e8e4573a142ed38724b8cdd389706a867bb4efcf1e78"}, ] - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] -testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.1)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] - -[[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ +six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] - -[[package]] -name = "soupsieve" -version = "2.5" -description = "A modern CSS selector implementation for Beautiful Soup." -optional = false -python-versions = ">=3.8" -files = [ +soupsieve = [ {file = "soupsieve-2.5-py3-none-any.whl", hash = "sha256:eaa337ff55a1579b6549dc679565eac1e3d000563bcb1c8ab0d0fefbc0c2cdc7"}, {file = "soupsieve-2.5.tar.gz", hash = "sha256:5663d5a7b3bfaeee0bc4372e7fc48f9cff4940b3eec54a6451cc5299f1097690"}, ] - -[[package]] -name = "tensorboard" -version = "2.15.1" -description = "TensorBoard lets you watch Tensors Flow" -optional = false -python-versions = ">=3.9" -files = [ +tensorboard = [ {file = "tensorboard-2.15.1-py3-none-any.whl", hash = "sha256:c46c1d1cf13a458c429868a78b2531d8ff5f682058d69ec0840b0bc7a38f1c0f"}, ] - -[package.dependencies] -absl-py = ">=0.4" -google-auth = ">=1.6.3,<3" -google-auth-oauthlib = ">=0.5,<2" -grpcio = ">=1.48.2" -markdown = ">=2.6.8" -numpy = ">=1.12.0" -protobuf = ">=3.19.6,<4.24" -requests = ">=2.21.0,<3" -setuptools = ">=41.0.0" -six = ">1.9" -tensorboard-data-server = ">=0.7.0,<0.8.0" -werkzeug = ">=1.0.1" - -[[package]] -name = "tensorboard-data-server" -version = "0.7.2" -description = "Fast data loading for TensorBoard" -optional = false -python-versions = ">=3.7" -files = [ +tensorboard-data-server = [ {file = "tensorboard_data_server-0.7.2-py3-none-any.whl", hash = "sha256:7e0610d205889588983836ec05dc098e80f97b7e7bbff7e994ebb78f578d0ddb"}, {file = "tensorboard_data_server-0.7.2-py3-none-macosx_10_9_x86_64.whl", hash = "sha256:9fe5d24221b29625dbc7328b0436ca7fc1c23de4acf4d272f1180856e32f9f60"}, {file = "tensorboard_data_server-0.7.2-py3-none-manylinux_2_31_x86_64.whl", hash = "sha256:ef687163c24185ae9754ed5650eb5bc4d84ff257aabdc33f0cc6f74d8ba54530"}, ] - -[[package]] -name = "threadpoolctl" -version = "3.2.0" -description = "threadpoolctl" -optional = false -python-versions = ">=3.8" -files = [ +threadpoolctl = [ {file = "threadpoolctl-3.2.0-py3-none-any.whl", hash = "sha256:2b7818516e423bdaebb97c723f86a7c6b0a83d3f3b0970328d66f4d9104dc032"}, {file = "threadpoolctl-3.2.0.tar.gz", hash = "sha256:c96a0ba3bdddeaca37dc4cc7344aafad41cdb8c313f74fdfe387a867bba93355"}, ] - -[[package]] -name = "toml" -version = "0.10.2" -description = "Python Library for Tom's Obvious, Minimal Language" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ +toml = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] - -[[package]] -name = "tomli" -version = "2.0.1" -description = "A lil' TOML parser" -optional = false -python-versions = ">=3.7" -files = [ +tomli = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] - -[[package]] -name = "torch" -version = "1.12.1" -description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" -optional = false -python-versions = ">=3.7.0" -files = [ +torch = [ {file = "torch-1.12.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:9c038662db894a23e49e385df13d47b2a777ffd56d9bcd5b832593fab0a7e286"}, {file = "torch-1.12.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:4e1b9c14cf13fd2ab8d769529050629a0e68a6fc5cb8e84b4a3cc1dd8c4fe541"}, {file = "torch-1.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:e9c8f4a311ac29fc7e8e955cfb7733deb5dbe1bdaabf5d4af2765695824b7e0d"}, @@ -1695,43 +1852,11 @@ files = [ {file = "torch-1.12.1-cp39-none-macosx_10_9_x86_64.whl", hash = "sha256:bfec2843daa654f04fda23ba823af03e7b6f7650a873cdb726752d0e3718dada"}, {file = "torch-1.12.1-cp39-none-macosx_11_0_arm64.whl", hash = "sha256:69fe2cae7c39ccadd65a123793d30e0db881f1c1927945519c5c17323131437e"}, ] - -[package.dependencies] -typing-extensions = "*" - -[[package]] -name = "torchmetrics" -version = "0.10.3" -description = "PyTorch native Metrics" -optional = false -python-versions = ">=3.7" -files = [ +torchmetrics = [ {file = "torchmetrics-0.10.3-py3-none-any.whl", hash = "sha256:b12cf92897545e24a825b0d168888c0f3052700c2901e2d4f7d90b252bc4a343"}, {file = "torchmetrics-0.10.3.tar.gz", hash = "sha256:9e6ab66175f2dc13e246c37485b2c27c77931dfe47fc2b81c76217b8efdc1e57"}, ] - -[package.dependencies] -numpy = ">=1.17.2" -packaging = "*" -torch = ">=1.3.1" - -[package.extras] -all = ["lpips", "nltk (>=3.6)", "pycocotools", "pystoi", "pytorch-lightning (>=1.5)", "regex (>=2021.9.24)", "scipy", "torch-fidelity", "torchvision", "torchvision (>=0.8)", "tqdm (>=4.41.0)"] -audio = ["pystoi"] -detection = ["pycocotools", "torchvision (>=0.8)"] -docs = ["docutils (>=0.16)", "myst-parser", "nbsphinx (>=0.8)", "pandoc (>=1.0)", "sphinx (>=4.0,<5.0)", "sphinx-autodoc-typehints (>=1.0)", "sphinx-copybutton (>=0.3)", "sphinx-paramlinks (>=0.5.1)", "sphinx-togglebutton (>=0.2)", "sphinxcontrib-fulltoc (>=1.0)", "sphinxcontrib-mockautodoc"] -image = ["lpips", "scipy", "torch-fidelity", "torchvision"] -integrate = ["pytorch-lightning (>=1.5)"] -test = ["bert-score (==0.3.10)", "check-manifest", "cloudpickle (>=1.3)", "coverage (>5.2)", "fast-bss-eval (>=0.1.0)", "fire", "huggingface-hub (<0.7)", "jiwer (>=2.3.0)", "mir-eval (>=0.6)", "netcal", "phmdoctest (>=1.1.1)", "pre-commit (>=1.0)", "psutil", "pycocotools", "pypesq (>1.2)", "pytest (==6.*)", "pytest-cov (>2.10)", "pytest-doctestplus (>=0.9.0)", "pytest-timeout", "pytorch-msssim (==0.2.1)", "requests", "rouge-score (>=0.0.4)", "sacrebleu (>=2.0.0)", "scikit-image (>0.17.1)", "scikit-learn (>1.0,<1.1.1)", "torch-complex", "transformers (>=4.0)"] -text = ["nltk (>=3.6)", "regex (>=2021.9.24)", "tqdm (>=4.41.0)"] - -[[package]] -name = "torchvision" -version = "0.13.1" -description = "image and video datasets and models for torch deep learning" -optional = false -python-versions = ">=3.7" -files = [ +torchvision = [ {file = "torchvision-0.13.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:19286a733c69dcbd417b86793df807bd227db5786ed787c17297741a9b0d0fc7"}, {file = "torchvision-0.13.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:08f592ea61836ebeceb5c97f4d7a813b9d7dc651bbf7ce4401563ccfae6a21fc"}, {file = "torchvision-0.13.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:ef5fe3ec1848123cd0ec74c07658192b3147dcd38e507308c790d5943e87b88c"}, @@ -1752,111 +1877,27 @@ files = [ {file = "torchvision-0.13.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b167934a5943242da7b1e59318f911d2d253feeca0d13ad5d832b58eed943401"}, {file = "torchvision-0.13.1-cp39-cp39-win_amd64.whl", hash = "sha256:0e77706cc90462653620e336bb90daf03d7bf1b88c3a9a3037df8d111823a56e"}, ] - -[package.dependencies] -numpy = "*" -pillow = ">=5.3.0,<8.3.dev0 || >=8.4.dev0" -requests = "*" -torch = "1.12.1" -typing-extensions = "*" - -[package.extras] -scipy = ["scipy"] - -[[package]] -name = "tqdm" -version = "4.66.1" -description = "Fast, Extensible Progress Meter" -optional = false -python-versions = ">=3.7" -files = [ +tqdm = [ {file = "tqdm-4.66.1-py3-none-any.whl", hash = "sha256:d302b3c5b53d47bce91fea46679d9c3c6508cf6332229aa1e7d8653723793386"}, {file = "tqdm-4.66.1.tar.gz", hash = "sha256:d88e651f9db8d8551a62556d3cff9e3034274ca5d66e93197cf2490e2dcb69c7"}, ] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - -[package.extras] -dev = ["pytest (>=6)", "pytest-cov", "pytest-timeout", "pytest-xdist"] -notebook = ["ipywidgets (>=6)"] -slack = ["slack-sdk"] -telegram = ["requests"] - -[[package]] -name = "typing-extensions" -version = "4.9.0" -description = "Backported and Experimental Type Hints for Python 3.8+" -optional = false -python-versions = ">=3.8" -files = [ +typing-extensions = [ {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, ] - -[[package]] -name = "urllib3" -version = "2.1.0" -description = "HTTP library with thread-safe connection pooling, file post, and more." -optional = false -python-versions = ">=3.8" -files = [ +urllib3 = [ {file = "urllib3-2.1.0-py3-none-any.whl", hash = "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3"}, {file = "urllib3-2.1.0.tar.gz", hash = "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54"}, ] - -[package.extras] -brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] -socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] -zstd = ["zstandard (>=0.18.0)"] - -[[package]] -name = "werkzeug" -version = "3.0.1" -description = "The comprehensive WSGI web application library." -optional = false -python-versions = ">=3.8" -files = [ +werkzeug = [ {file = "werkzeug-3.0.1-py3-none-any.whl", hash = "sha256:90a285dc0e42ad56b34e696398b8122ee4c681833fb35b8334a095d82c56da10"}, {file = "werkzeug-3.0.1.tar.gz", hash = "sha256:507e811ecea72b18a404947aded4b3390e1db8f826b494d76550ef45bb3b1dcc"}, ] - -[package.dependencies] -MarkupSafe = ">=2.1.1" - -[package.extras] -watchdog = ["watchdog (>=2.3)"] - -[[package]] -name = "where" -version = "1.0.2" -description = "Locates absolute file paths like the Windows 'where' or the Linux 'which' utility.\nMakes use of the PATH variable and the current directory." -optional = false -python-versions = "*" -files = [ +where = [ {file = "where-1.0.2-py2.py3-none-any.whl", hash = "sha256:66abc8edf95be7516e949d08a771f25acacff708ef481618562ab484fe5bc63e"}, {file = "where-1.0.2.zip", hash = "sha256:325ef3a492a26189a47819f7375bc146887d39edd36fce132e86514334803fb1"}, ] - -[package.dependencies] -itermate = "1.0.2" - -[[package]] -name = "zipp" -version = "3.17.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.8" -files = [ +zipp = [ {file = "zipp-3.17.0-py3-none-any.whl", hash = "sha256:0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31"}, {file = "zipp-3.17.0.tar.gz", hash = "sha256:84e64a1c28cf7e91ed2078bb8cc8c259cb19b76942096c8d7b84947690cabaf0"}, ] - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] - -[metadata] -lock-version = "2.0" -python-versions = "^3.9" -content-hash = "2bd8cd888296608cf8d150b9d2e33336d89785d2ef5718eed54ffdaed1dbc2b6" diff --git a/pyproject.toml b/pyproject.toml index 545a508a7..18804078e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ pandas = "^1.5.1" scikit-learn = "^1.2.1" pyyaml = "^6.0" gdown = "^4.7.1" -tensorboard = "^2.14.0" +tensorboard = "^2.15.1" [tool.poetry.scripts] domainlab = 'domainlab.cli:domainlab_cli' diff --git a/requirements.txt b/requirements.txt index 90ea7fe0e..e48a87cad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,49 +1,60 @@ -beautifulsoup4==4.12.2 ; python_version >= "3.9" and python_version < "4.0" +absl-py==2.1.0 ; python_version >= "3.9" and python_version < "4.0" +beautifulsoup4==4.12.3 ; python_version >= "3.9" and python_version < "4.0" +cachetools==5.3.2 ; python_version >= "3.9" and python_version < "4.0" certifi==2023.11.17 ; python_version >= "3.9" and python_version < "4.0" charset-normalizer==3.3.2 ; python_version >= "3.9" and python_version < "4.0" colorama==0.4.6 ; python_version >= "3.9" and python_version < "4.0" and platform_system == "Windows" contourpy==1.2.0 ; python_version >= "3.9" and python_version < "4.0" cycler==0.12.1 ; python_version >= "3.9" and python_version < "4.0" filelock==3.13.1 ; python_version >= "3.9" and python_version < "4.0" -fonttools==4.46.0 ; python_version >= "3.9" and python_version < "4.0" -gdown==4.7.1 ; python_version >= "3.9" and python_version < "4.0" +fonttools==4.47.2 ; python_version >= "3.9" and python_version < "4.0" +gdown==4.7.3 ; python_version >= "3.9" and python_version < "4.0" +google-auth-oauthlib==1.2.0 ; python_version >= "3.9" and python_version < "4.0" +google-auth==2.26.2 ; python_version >= "3.9" and python_version < "4.0" +grpcio==1.60.0 ; python_version >= "3.9" and python_version < "4.0" idna==3.6 ; python_version >= "3.9" and python_version < "4.0" +importlib-metadata==7.0.1 ; python_version >= "3.9" and python_version < "3.10" importlib-resources==6.1.1 ; python_version >= "3.9" and python_version < "3.10" joblib==1.3.2 ; python_version >= "3.9" and python_version < "4.0" kiwisolver==1.4.5 ; python_version >= "3.9" and python_version < "4.0" markdown-it-py==3.0.0 ; python_version >= "3.9" and python_version < "4.0" +markdown==3.5.2 ; python_version >= "3.9" and python_version < "4.0" +markupsafe==2.1.4 ; python_version >= "3.9" and python_version < "4.0" matplotlib==3.8.2 ; python_version >= "3.9" and python_version < "4.0" mdurl==0.1.2 ; python_version >= "3.9" and python_version < "4.0" -numpy==1.26.2 ; python_version < "4.0" and python_version >= "3.9" +numpy==1.26.3 ; python_version < "4.0" and python_version >= "3.9" +oauthlib==3.2.2 ; python_version >= "3.9" and python_version < "4.0" packaging==23.2 ; python_version >= "3.9" and python_version < "4.0" pandas==1.5.3 ; python_version >= "3.9" and python_version < "4.0" pillow==9.5.0 ; python_version >= "3.9" and python_version < "4.0" +protobuf==4.23.4 ; python_version >= "3.9" and python_version < "4.0" +pyasn1-modules==0.3.0 ; python_version >= "3.9" and python_version < "4.0" +pyasn1==0.5.1 ; python_version >= "3.9" and python_version < "4.0" pygments==2.17.2 ; python_version >= "3.9" and python_version < "4.0" pyparsing==3.1.1 ; python_version >= "3.9" and python_version < "4.0" pysocks==1.7.1 ; python_version >= "3.9" and python_version < "4.0" python-dateutil==2.8.2 ; python_version >= "3.9" and python_version < "4.0" pytz==2023.3.post1 ; python_version >= "3.9" and python_version < "4.0" pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "4.0" +requests-oauthlib==1.3.1 ; python_version >= "3.9" and python_version < "4.0" requests==2.31.0 ; python_version >= "3.9" and python_version < "4.0" requests[socks]==2.31.0 ; python_version >= "3.9" and python_version < "4.0" rich==13.7.0 ; python_version >= "3.9" and python_version < "4.0" -scikit-learn==1.3.2 ; python_version >= "3.9" and python_version < "4.0" -scipy==1.11.4 ; python_version >= "3.9" and python_version < "4.0" +rsa==4.9 ; python_version >= "3.9" and python_version < "4" +scikit-learn==1.4.0 ; python_version >= "3.9" and python_version < "4.0" +scipy==1.12.0 ; python_version >= "3.9" and python_version < "4.0" seaborn==0.12.2 ; python_version >= "3.9" and python_version < "4.0" +setuptools==69.0.3 ; python_version >= "3.9" and python_version < "4.0" six==1.16.0 ; python_version >= "3.9" and python_version < "4.0" soupsieve==2.5 ; python_version >= "3.9" and python_version < "4.0" +tensorboard-data-server==0.7.2 ; python_version >= "3.9" and python_version < "4.0" +tensorboard==2.15.1 ; python_version >= "3.9" and python_version < "4.0" threadpoolctl==3.2.0 ; python_version >= "3.9" and python_version < "4.0" -throttler==1.2.2 ; python_version >= "3.9" and python_version < "4.0" -tomli==2.0.1 ; python_version >= "3.9" and python_version < "3.11" -toposort==1.10 ; python_version >= "3.9" and python_version < "4.0" -tqdm==4.66.1 ; python_version >= "3.9" and python_version < "4.0" torch==1.12.1 ; python_version >= "3.9" and python_version < "4.0" torchmetrics==0.10.3 ; python_version >= "3.9" and python_version < "4.0" torchvision==0.13.1 ; python_version >= "3.9" and python_version < "4.0" -tensorboard==2.14.0 ; python_version >= "3.9" and python_version < "4.0" -traitlets==5.11.2 ; python_version >= "3.9" and python_version < "4.0" -typing-extensions==4.8.0 ; python_version >= "3.9" and python_version < "4.0" -urllib3==2.0.6 ; python_version >= "3.9" and python_version < "4.0" -wrapt==1.15.0 ; python_version >= "3.9" and python_version < "4.0" -yte==1.5.1 ; python_version >= "3.9" and python_version < "4.0" +tqdm==4.66.1 ; python_version >= "3.9" and python_version < "4.0" +typing-extensions==4.9.0 ; python_version >= "3.9" and python_version < "4.0" +urllib3==2.1.0 ; python_version >= "3.9" and python_version < "4.0" +werkzeug==3.0.1 ; python_version >= "3.9" and python_version < "4.0" zipp==3.17.0 ; python_version >= "3.9" and python_version < "3.10" From 1c4dfd159a179840a55386ea3e8e60ca38372e20 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 29 Jan 2024 16:50:25 +0100 Subject: [PATCH 709/762] reduce nubmer of iterations --- examples/benchmark/pacs_diva_fbopt_and_baselines.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index 10df43448..9298713ec 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 500 - epos_min: 200 + epos_min: 10 es: 1 bs: 32 san_check: False From eb812c24c69c7ccd7efd7f49e207fd7de555b9ca Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 29 Jan 2024 16:52:38 +0100 Subject: [PATCH 710/762] . --- examples/benchmark/pacs_diva_fbopt_and_baselines.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index 9298713ec..98a2b8743 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -5,7 +5,7 @@ output_dir: zoutput/benchmarks/pacs_diva_fbopt_and_baselines_aug sampling_seed: 0 startseed: 0 -endseed: 3 +endseed: 6 test_domains: - sketch From 1374b3360bc8a7713a46c3847e86299edc661611 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 1 Feb 2024 09:10:40 +0100 Subject: [PATCH 711/762] use aug pac --- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index 8c87ddafe..3f633a3f2 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -11,7 +11,7 @@ test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py + tpath: examples/tasks/task_pacs_aug.py dmem: False lr: 5e-5 epos: 200 From b763838c608ede64409eb7eb4a6579f36dba9bcb Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 1 Feb 2024 10:53:14 +0100 Subject: [PATCH 712/762] Update pacs_diva_fbopt_alone_es1.yaml: batch 64 to 32 --- examples/benchmark/pacs_diva_fbopt_alone_es1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml index 3f633a3f2..24177c0bc 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml @@ -17,7 +17,7 @@ domainlab_args: epos: 200 epos_min: 20 es: 1 - bs: 64 + bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py From 6d34ab4da7680f4c43b91ca8f6cade77ad90f5ea Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 1 Feb 2024 11:09:40 +0100 Subject: [PATCH 713/762] Update pacs_diva_fbopt_alone_es1_autoki.yaml --- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 22b5ee4d8..156bf32ef 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -15,7 +15,7 @@ domainlab_args: dmem: False lr: 5e-5 epos: 500 - epos_min: 200 + epos_min: 20 es: 1 bs: 32 san_check: False From a3fa38259f01fd13b2b5bfd99a505086bb9a9d93 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 6 Feb 2024 11:39:32 +0100 Subject: [PATCH 714/762] es=10 --- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 156bf32ef..d09bed651 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -16,7 +16,7 @@ domainlab_args: lr: 5e-5 epos: 500 epos_min: 20 - es: 1 + es: 10 bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py From 964c89259087a7c159df1fdb1d1f348055384178 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 6 Feb 2024 17:44:08 +0100 Subject: [PATCH 715/762] . --- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index d09bed651..3540a19b1 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -101,8 +101,6 @@ diva_fbopt_full: gamma_y: 1.0 ini_setpoint_ratio: 0.99 str_diva_multiplier_type: gammad_recon - coeff_ma_output_state: 0 - coeff_ma_setpoint: 0 mu_init: 1e-6 shared: - k_i_gain_ratio From 4c69a52b207d01b2128aa28184eddcc0758b61ce Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 7 Feb 2024 07:54:46 +0100 Subject: [PATCH 716/762] force setpoint change once --- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 3540a19b1..4d0334c78 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -16,7 +16,7 @@ domainlab_args: lr: 5e-5 epos: 500 epos_min: 20 - es: 10 + es: 1 bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py @@ -98,6 +98,7 @@ Shared params: diva_fbopt_full: model: diva trainer: fbopt + force_setpoint_change_once: True gamma_y: 1.0 ini_setpoint_ratio: 0.99 str_diva_multiplier_type: gammad_recon From 775e41ffed55ad8ca2e11251cc56171aa490ba29 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Thu, 8 Feb 2024 08:20:21 +0100 Subject: [PATCH 717/762] Update pacs_diva_fbopt_alone_es1_autoki.yaml --- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 4d0334c78..22a048864 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -11,7 +11,7 @@ test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py + tpath: examples/tasks/task_pacs_aug.py dmem: False lr: 5e-5 epos: 500 @@ -67,7 +67,7 @@ Shared params: k_i_gain_ratio: min: 0.1 max: 1 - num: 10 + num: 3 distribution: uniform mu_init: @@ -105,3 +105,4 @@ diva_fbopt_full: mu_init: 1e-6 shared: - k_i_gain_ratio + - mu_clip From 600e39e053f6d068393c32106980f899dbdac2f3 Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:18:07 -0500 Subject: [PATCH 718/762] attempt to reproduce previous diva results on pacs data --- a_reproduce_pacs_diva.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 a_reproduce_pacs_diva.yaml diff --git a/a_reproduce_pacs_diva.yaml b/a_reproduce_pacs_diva.yaml new file mode 100644 index 000000000..e7b08a0ef --- /dev/null +++ b/a_reproduce_pacs_diva.yaml @@ -0,0 +1,24 @@ +te_d: sketch +tpath: examples/tasks/task_pacs_aug.py +bs: 32 +model: diva +trainer: fbopt +gamma_y: 1.0 +ini_setpoint_ratio: 0.99 +str_diva_multiplier_type: gammad_recon +coeff_ma_output_state: 0.1 +coeff_ma_setpoint: 0.9 +exp_shoulder_clip: 5 +mu_init: 1e-6 +k_i_gain_ratio: 0.5 +mu_clip: 10 +epos: 1000 +epos_min: 200 +npath: examples/nets/resnet50domainbed.py +npath_dom: examples/nets/resnet50domainbed.py +es: 2 +lr: 5e-5 +zx_dim: 0 +zy_dim: 64 +zd_dim: 64 +force_setpoint_change_once: True From 1c3f26a065deb180701ce2711fec453adcfca47a Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:10:33 -0500 Subject: [PATCH 719/762] 1e-5 type notation not supported for yaml file --- a_reproduce_pacs_diva.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/a_reproduce_pacs_diva.yaml b/a_reproduce_pacs_diva.yaml index e7b08a0ef..db3c234eb 100644 --- a/a_reproduce_pacs_diva.yaml +++ b/a_reproduce_pacs_diva.yaml @@ -9,7 +9,7 @@ str_diva_multiplier_type: gammad_recon coeff_ma_output_state: 0.1 coeff_ma_setpoint: 0.9 exp_shoulder_clip: 5 -mu_init: 1e-6 +mu_init: 0.000001 k_i_gain_ratio: 0.5 mu_clip: 10 epos: 1000 @@ -17,7 +17,7 @@ epos_min: 200 npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py es: 2 -lr: 5e-5 +lr: 0.00005 zx_dim: 0 zy_dim: 64 zd_dim: 64 From 8b9d92117a904967535afc6747c7ab0fa837e2c0 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 8 Feb 2024 17:53:29 +0100 Subject: [PATCH 720/762] . --- examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 22a048864..9a7cf3044 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -15,8 +15,8 @@ domainlab_args: dmem: False lr: 5e-5 epos: 500 - epos_min: 20 - es: 1 + epos_min: 200 + es: 5 bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py From 180f2b8ddf2c249abaa98a8530bb2988b91d978b Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 9 Feb 2024 12:43:45 +0100 Subject: [PATCH 721/762] better yaml for benchmark --- examples/benchmark/pacs_diva_fbopt_and_baselines.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index 98a2b8743..4d448face 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -16,13 +16,11 @@ domainlab_args: lr: 5e-5 epos: 500 epos_min: 10 - es: 1 + es: 10 bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 @@ -85,6 +83,7 @@ diva_fbopt_a: trainer: fbopt gamma_y: 1.0 ini_setpoint_ratio: 0.99 + force_setpoint_change_once: True str_diva_multiplier_type: gammad_recon coeff_ma_output_state: 0.1 mu_init: 1e-6 From 6541cd46aaa3866e4a4a32d96cf78aef56063e7a Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 9 Feb 2024 13:09:22 +0100 Subject: [PATCH 722/762] refine yaml file --- .../pacs_diva_fbopt_alone_es1_autoki.yaml | 2 -- .../pacs_diva_fbopt_and_baselines.yaml | 4 +-- examples/benchmark/pacs_diva_others.yaml | 30 ++++--------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml index 9a7cf3044..35c93c236 100644 --- a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki.yaml @@ -21,8 +21,6 @@ domainlab_args: san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 16 zy_dim: 64 zd_dim: 64 diff --git a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml index 4d448face..7ea54939e 100644 --- a/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml +++ b/examples/benchmark/pacs_diva_fbopt_and_baselines.yaml @@ -15,8 +15,8 @@ domainlab_args: dmem: False lr: 5e-5 epos: 500 - epos_min: 10 - es: 10 + epos_min: 200 + es: 5 bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml index 2699687d8..0b1c3833d 100644 --- a/examples/benchmark/pacs_diva_others.yaml +++ b/examples/benchmark/pacs_diva_others.yaml @@ -5,23 +5,22 @@ output_dir: zoutput/benchmarks/pacs_diva_others sampling_seed: 0 startseed: 0 -endseed: 5 +endseed: 6 test_domains: - sketch domainlab_args: - tpath: examples/tasks/task_pacs_path_list.py + tpath: examples/tasks/task_pacs_aug.py dmem: False lr: 5e-5 - epos: 200 - es: 10 - bs: 64 + epos: 500 + epos_min: 200 + es: 5 + bs: 32 san_check: False npath: examples/nets/resnet50domainbed.py npath_dom: examples/nets/resnet50domainbed.py - npath_encoder_x2topic_h: examples/nets/resnet50domainbed.py - npath_encoder_sandwich_x2h4zd: examples/nets/resnet50domainbed.py zx_dim: 0 zy_dim: 64 zd_dim: 64 @@ -30,23 +29,6 @@ domainlab_args: Shared params: - ini_setpoint_ratio: - min: 0.9 - max: 0.99 - num: 3 - distribution: uniform - - k_i_gain: - min: 0.0001 - max: 0.01 - num: 3 - distribution: uniform - - mu_init: - min: 0.000001 - max: 0.00001 - num: 3 - distribution: loguniform gamma_y: min: 1.0 From e05081a557e42b67db62917fdd17040db3f05b79 Mon Sep 17 00:00:00 2001 From: Xudong Sun Date: Tue, 13 Feb 2024 17:18:31 +0100 Subject: [PATCH 723/762] Rename pacs_diva_fbopt_alone_es1.yaml to pacs_diva_fbopt_alone_es1_random_ki.yaml --- ...pt_alone_es1.yaml => pacs_diva_fbopt_alone_es1_random_ki.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/benchmark/{pacs_diva_fbopt_alone_es1.yaml => pacs_diva_fbopt_alone_es1_random_ki.yaml} (100%) diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_random_ki.yaml similarity index 100% rename from examples/benchmark/pacs_diva_fbopt_alone_es1.yaml rename to examples/benchmark/pacs_diva_fbopt_alone_es1_random_ki.yaml From b0e679f8bab039ef3244a3da447d879f6889931d Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 15 Feb 2024 13:32:46 +0100 Subject: [PATCH 724/762] add gamma-y sample --- examples/benchmark/pacs_diva_others.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/examples/benchmark/pacs_diva_others.yaml b/examples/benchmark/pacs_diva_others.yaml index 0b1c3833d..55d6a7f37 100644 --- a/examples/benchmark/pacs_diva_others.yaml +++ b/examples/benchmark/pacs_diva_others.yaml @@ -6,9 +6,7 @@ sampling_seed: 0 startseed: 0 endseed: 6 - -test_domains: - - sketch +test_domains: - sketch domainlab_args: tpath: examples/tasks/task_pacs_aug.py @@ -49,9 +47,9 @@ diva_feedforward_full: model: diva trainer: hyperscheduler str_diva_multiplier_type: gammad_recon - gamma_y: 1.0 shared: - gamma_d + - gamma_y diva_default: model: diva @@ -68,6 +66,3 @@ diva_fixed_penalty: shared: - gamma_d - gamma_y - -erm: - model: erm From 99c9ad2d2d8347a61e311f7ecfa7f87433bb54df Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:59:48 -0500 Subject: [PATCH 725/762] minor improvements to generation of figures for the fbopt experiments --- .../utils/generate_fbopt_phase_portrait.py | 24 +++++++++++++------ script_generate_all_figures_diva.sh | 20 ++++++++++++---- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 2b9baae07..ac3ec5581 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -68,6 +68,7 @@ def phase_portrait_combined( legend1=None, legend2=None, plot_len=None, + skip_first_n=0, output_dir=".", ): """ @@ -83,7 +84,8 @@ def phase_portrait_combined( if plot_len is None: plot_len = len(x) # truncate x and y to the desired length: - x, y = x[:plot_len], y[:plot_len] + x = x[skip_first_n:(plot_len+skip_first_n)] + y = y[skip_first_n:(plot_len+skip_first_n)] head_w_glob = min((max(x) - min(x)) / 100.0, (max(y) - min(y)) / 100.0) for i in range(plot_len - 1): @@ -123,9 +125,11 @@ def phase_portrait_combined( if not os.path.exists(output_dir): os.makedirs(output_dir) legend22 = legend2.split(os.sep)[-1] - plt.savefig( - os.path.join(output_dir, f"phase_portrait_combined_{legend22}.png"), dpi=300 - ) + + fname = os.path.join(output_dir, f"phase_portrait_combined_{legend22}") + plt.savefig(fname+".png", dpi=300) + plt.savefig(fname+".pdf", format="pdf") + plt.savefig(fname+".svg", format="svg") def two_curves_combined( @@ -161,9 +165,11 @@ def two_curves_combined( if not os.path.exists(output_dir): os.makedirs(output_dir) - plt.savefig( - os.path.join(output_dir, f"timecourse_{legend11}_{legend22}.png"), dpi=300 - ) + + fname = os.path.join(output_dir, f"timecourse_{legend11}_{legend22}") + plt.savefig(fname+".png", dpi=300) + plt.savefig(fname+".pdf", format="pdf") + plt.savefig(fname+".svg", format="svg") def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): @@ -185,6 +191,8 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): if not os.path.exists(output_dir): os.makedirs(output_dir) plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.png"), dpi=300) + plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.pdf"), format="pdf") + plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.svg"), format="svg") if __name__ == "__main__": @@ -194,6 +202,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): parser.add_argument("-legend1", "--legend1", default=None, type=str) parser.add_argument("-legend2", "--legend2", default=None, type=str) parser.add_argument("-plot_len", "--plot_len", default=None, type=int) + parser.add_argument("-skip_first_n", "--skip_first_n", default=None, type=int) parser.add_argument("-title", "--title", default=None, type=str) parser.add_argument("--output_dir", default=".", type=str) parser.add_argument( @@ -225,6 +234,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): legend1=args.legend1, legend2=args.legend2, plot_len=args.plot_len, + skip_first_n=args.skip_first_n, output_dir=args.output_dir, ) else: diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 3a4dce58b..e29302acf 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -1,15 +1,25 @@ #!/bin/bash # Phase portraits -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait +# a command line argument can be passed to this script, in order to skip the first few large jumps on the phase plots; if no argument is provided then all points will be plotted: +# Check if an argument is provided +if [ $# -eq 0 ]; then + # Check if an argument is provided + skip_n=0 +else + # Use the provided argument + skip_n=$1 +fi -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait # Plot R and the corresponding set point curves (both in the same figure) From e38e9b575ce49dd7ceaeac74165990de1cb470cf Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 23 Feb 2024 14:06:01 +0100 Subject: [PATCH 726/762] add class to put tensorboard data to text file --- .../utils/generate_fbopt_phase_portrait.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 2b9baae07..34a2cabaa 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -11,6 +11,33 @@ from tensorboard.backend.event_processing.event_accumulator import EventAccumulator +class ListFileHandler: + def __init__(self, file_path): + self.file_path = file_path + + def write_lists_to_file(self, list1, list2=None): + with open(self.file_path, 'w') as file: + if list2 is None: + for val1 in list1: + file.write(f"{val1}\n") + else: + for val1, val2 in zip(list1, list2): + file.write(f"{val1} {val2}\n") + + def read_lists_from_file(self): + list1 = [] + list2 = [] + with open(self.file_path, 'r') as file: + for line in file: + values = list(map(float, line.strip().split())) + if len(values) == 1: + list1.append(values[0]) + elif len(values) == 2: + list1.append(values[0]) + list2.append(values[1]) + return list1, list2 + + # pylint: disable=too-many-arguments def get_xy_from_event_file( event_file, From e6ffee6723205a8c0d8101b77f1f20a2a07b5de3 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 23 Feb 2024 14:16:57 +0100 Subject: [PATCH 727/762] make fbopt script into separate folder --- run_benchmark_slurm.sh => scripts_fbopt/run_benchmark_slurm.sh | 0 .../run_benchmark_standalone.sh | 0 run_erm.sh => scripts_fbopt/run_erm.sh | 0 run_fbopt_dann.sh => scripts_fbopt/run_fbopt_dann.sh | 0 run_fbopt_diva.sh => scripts_fbopt/run_fbopt_diva.sh | 0 run_fbopt_diva_cpu.sh => scripts_fbopt/run_fbopt_diva_cpu.sh | 0 run_fbopt_hduva_cpu.sh => scripts_fbopt/run_fbopt_hduva_cpu.sh | 0 run_fbopt_match_diva.sh => scripts_fbopt/run_fbopt_match_diva.sh | 0 run_fbopt_mnist.sh => scripts_fbopt/run_fbopt_mnist.sh | 0 run_fbopt_mnist_diva.sh => scripts_fbopt/run_fbopt_mnist_diva.sh | 0 .../run_fbopt_mnist_diva_autoki.sh | 0 .../run_fbopt_mnist_feedforward.sh | 0 .../run_fbopt_mnist_jigen_autoki.sh | 0 run_fbopt_small_pacs.sh => scripts_fbopt/run_fbopt_small_pacs.sh | 0 run_mnist_jigen.sh => scripts_fbopt/run_mnist_jigen.sh | 0 run_pacs_diva_fbopt.sh => scripts_fbopt/run_pacs_diva_fbopt.sh | 0 run_pacs_jigen_fbopt.sh => scripts_fbopt/run_pacs_jigen_fbopt.sh | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename run_benchmark_slurm.sh => scripts_fbopt/run_benchmark_slurm.sh (100%) rename run_benchmark_standalone.sh => scripts_fbopt/run_benchmark_standalone.sh (100%) rename run_erm.sh => scripts_fbopt/run_erm.sh (100%) rename run_fbopt_dann.sh => scripts_fbopt/run_fbopt_dann.sh (100%) rename run_fbopt_diva.sh => scripts_fbopt/run_fbopt_diva.sh (100%) rename run_fbopt_diva_cpu.sh => scripts_fbopt/run_fbopt_diva_cpu.sh (100%) rename run_fbopt_hduva_cpu.sh => scripts_fbopt/run_fbopt_hduva_cpu.sh (100%) rename run_fbopt_match_diva.sh => scripts_fbopt/run_fbopt_match_diva.sh (100%) rename run_fbopt_mnist.sh => scripts_fbopt/run_fbopt_mnist.sh (100%) rename run_fbopt_mnist_diva.sh => scripts_fbopt/run_fbopt_mnist_diva.sh (100%) rename run_fbopt_mnist_diva_autoki.sh => scripts_fbopt/run_fbopt_mnist_diva_autoki.sh (100%) rename run_fbopt_mnist_feedforward.sh => scripts_fbopt/run_fbopt_mnist_feedforward.sh (100%) rename run_fbopt_mnist_jigen_autoki.sh => scripts_fbopt/run_fbopt_mnist_jigen_autoki.sh (100%) rename run_fbopt_small_pacs.sh => scripts_fbopt/run_fbopt_small_pacs.sh (100%) rename run_mnist_jigen.sh => scripts_fbopt/run_mnist_jigen.sh (100%) rename run_pacs_diva_fbopt.sh => scripts_fbopt/run_pacs_diva_fbopt.sh (100%) rename run_pacs_jigen_fbopt.sh => scripts_fbopt/run_pacs_jigen_fbopt.sh (100%) diff --git a/run_benchmark_slurm.sh b/scripts_fbopt/run_benchmark_slurm.sh similarity index 100% rename from run_benchmark_slurm.sh rename to scripts_fbopt/run_benchmark_slurm.sh diff --git a/run_benchmark_standalone.sh b/scripts_fbopt/run_benchmark_standalone.sh similarity index 100% rename from run_benchmark_standalone.sh rename to scripts_fbopt/run_benchmark_standalone.sh diff --git a/run_erm.sh b/scripts_fbopt/run_erm.sh similarity index 100% rename from run_erm.sh rename to scripts_fbopt/run_erm.sh diff --git a/run_fbopt_dann.sh b/scripts_fbopt/run_fbopt_dann.sh similarity index 100% rename from run_fbopt_dann.sh rename to scripts_fbopt/run_fbopt_dann.sh diff --git a/run_fbopt_diva.sh b/scripts_fbopt/run_fbopt_diva.sh similarity index 100% rename from run_fbopt_diva.sh rename to scripts_fbopt/run_fbopt_diva.sh diff --git a/run_fbopt_diva_cpu.sh b/scripts_fbopt/run_fbopt_diva_cpu.sh similarity index 100% rename from run_fbopt_diva_cpu.sh rename to scripts_fbopt/run_fbopt_diva_cpu.sh diff --git a/run_fbopt_hduva_cpu.sh b/scripts_fbopt/run_fbopt_hduva_cpu.sh similarity index 100% rename from run_fbopt_hduva_cpu.sh rename to scripts_fbopt/run_fbopt_hduva_cpu.sh diff --git a/run_fbopt_match_diva.sh b/scripts_fbopt/run_fbopt_match_diva.sh similarity index 100% rename from run_fbopt_match_diva.sh rename to scripts_fbopt/run_fbopt_match_diva.sh diff --git a/run_fbopt_mnist.sh b/scripts_fbopt/run_fbopt_mnist.sh similarity index 100% rename from run_fbopt_mnist.sh rename to scripts_fbopt/run_fbopt_mnist.sh diff --git a/run_fbopt_mnist_diva.sh b/scripts_fbopt/run_fbopt_mnist_diva.sh similarity index 100% rename from run_fbopt_mnist_diva.sh rename to scripts_fbopt/run_fbopt_mnist_diva.sh diff --git a/run_fbopt_mnist_diva_autoki.sh b/scripts_fbopt/run_fbopt_mnist_diva_autoki.sh similarity index 100% rename from run_fbopt_mnist_diva_autoki.sh rename to scripts_fbopt/run_fbopt_mnist_diva_autoki.sh diff --git a/run_fbopt_mnist_feedforward.sh b/scripts_fbopt/run_fbopt_mnist_feedforward.sh similarity index 100% rename from run_fbopt_mnist_feedforward.sh rename to scripts_fbopt/run_fbopt_mnist_feedforward.sh diff --git a/run_fbopt_mnist_jigen_autoki.sh b/scripts_fbopt/run_fbopt_mnist_jigen_autoki.sh similarity index 100% rename from run_fbopt_mnist_jigen_autoki.sh rename to scripts_fbopt/run_fbopt_mnist_jigen_autoki.sh diff --git a/run_fbopt_small_pacs.sh b/scripts_fbopt/run_fbopt_small_pacs.sh similarity index 100% rename from run_fbopt_small_pacs.sh rename to scripts_fbopt/run_fbopt_small_pacs.sh diff --git a/run_mnist_jigen.sh b/scripts_fbopt/run_mnist_jigen.sh similarity index 100% rename from run_mnist_jigen.sh rename to scripts_fbopt/run_mnist_jigen.sh diff --git a/run_pacs_diva_fbopt.sh b/scripts_fbopt/run_pacs_diva_fbopt.sh similarity index 100% rename from run_pacs_diva_fbopt.sh rename to scripts_fbopt/run_pacs_diva_fbopt.sh diff --git a/run_pacs_jigen_fbopt.sh b/scripts_fbopt/run_pacs_jigen_fbopt.sh similarity index 100% rename from run_pacs_jigen_fbopt.sh rename to scripts_fbopt/run_pacs_jigen_fbopt.sh From 9ecb520c63c74376bfbe557d5d9cc8905ec20d77 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 23 Feb 2024 15:20:46 +0100 Subject: [PATCH 728/762] improve code --- domainlab/utils/generate_fbopt_phase_portrait.py | 6 +++++- script_generate_all_figures_diva.sh | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 34a2cabaa..101ef570e 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -223,6 +223,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): parser.add_argument("-plot_len", "--plot_len", default=None, type=int) parser.add_argument("-title", "--title", default=None, type=str) parser.add_argument("--output_dir", default=".", type=str) + parser.add_argument("--runs_dir", default="runs", type=str) parser.add_argument( "--phase_portrait", action="store_true", @@ -232,7 +233,10 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): args = parser.parse_args() # get event files from all available runs - event_files = glob.glob("runs/*/events*") + # Tensorboard: * could be the date information, this intermediate directory + # always exist + # events* means all the event folders + event_files = glob.glob(f"{args.runs_dir}/*/events*") print( "Using the following tensorboard event files:\n{}".format( "\n".join(event_files) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 3a4dce58b..d8340c88a 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -1,6 +1,14 @@ #!/bin/bash +STR_LOSS_ELL = "loss_task/ell" + + +# README: +# The following scripts will check event files from the 'runs' folder of the working directory. +# To generate example tensorboard 'runs' folder, one could execute e.g. `sh run_fbopt_mnist_diva_autoki.sh` such that there will be 'runs' folder. + # Phase portraits + python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="loss_task/ell" --plot_len 30 --output_dir="./figures_diva" --phase_portrait From 8cca9cfa8c2e1de1da3739017ea45772632aa0b8 Mon Sep 17 00:00:00 2001 From: Alexej Gossmann <11449372+agisga@users.noreply.github.com> Date: Fri, 23 Feb 2024 09:49:13 -0500 Subject: [PATCH 729/762] minor adjustments to the visualizations --- .../utils/generate_fbopt_phase_portrait.py | 6 ++- script_generate_all_figures_diva.sh | 38 ++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 229b5b17a..5cc8aed2e 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -245,7 +245,11 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): # Tensorboard: * could be the date information, this intermediate directory # always exist # events* means all the event folders - event_files = glob.glob(f"{args.runs_dir}/*/events*") + # this would combine plots from all subfolders in the runs directory (i.e., all graphs combined in each plot): + #event_files = glob.glob(f"{args.runs_dir}/*/events*") + # this needs the user to specify a specific run (subfolder in the runs directory): + event_files = glob.glob(f"{args.runs_dir}/events*") + if not os.path.isdir(args.runs_dir): raise RuntimeError("runs_dir should be a directory.") print( "Using the following tensorboard event files:\n{}".format( "\n".join(event_files) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 685a18451..3a90af391 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -7,39 +7,49 @@ STR_LOSS_ELL = "loss_task/ell" # The following scripts will check event files from the 'runs' folder of the working directory. # To generate example tensorboard 'runs' folder, one could execute e.g. `sh run_fbopt_mnist_diva_autoki.sh` such that there will be 'runs' folder. +if [ -z "$1" ]; then + # Check if an argument is provided + runs_dir="runs/*" +else + # Use the provided argument + runs_dir=$1 +fi + # Phase portraits # a command line argument can be passed to this script, in order to skip the first few large jumps on the phase plots; if no argument is provided then all points will be plotted: -# Check if an argument is provided -if [ $# -eq 0 ]; then +if [ -z "$2" ]; then # Check if an argument is provided skip_n=0 else # Use the provided argument - skip_n=$1 + skip_n=$2 fi -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +# Number of points to plot: +phase_portrait_plot_len=50 + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len 30 --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait # Plot R and the corresponding set point curves (both in the same figure) -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss (gamma_d)" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss (gamma_d)" --legend2="setpoint" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL (beta_d)" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL (beta_d)" --legend2="setpoint" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir="./figures_diva" -python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir="./figures_diva" # Other plots (one curve per figure) @@ -47,5 +57,5 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="lossrd/dyn_beta # Loop over the array for val in "${values[@]}" do - python domainlab/utils/generate_fbopt_phase_portrait.py --plot1="$val" --legend1="$val" --output_dir="./figures_diva" + python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="$val" --legend1="$val" --output_dir="./figures_diva" done From 6dd6b2d86d9d1ec9468dd30682b7f90d4b7782dd Mon Sep 17 00:00:00 2001 From: Alexej Gossmann <11449372+agisga@users.noreply.github.com> Date: Fri, 23 Feb 2024 09:55:53 -0500 Subject: [PATCH 730/762] fbopt figures: backup x and y data to txt files --- domainlab/utils/generate_fbopt_phase_portrait.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 5cc8aed2e..3a3b9cb4b 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -83,6 +83,11 @@ def get_xy_from_event_file( if sanity_check: for i in range(len(x)): assert int(x[i]) == x_int[i] + + # write x and y data to a text file: + fh = ListFileHandler(event_file + "_backup.txt") + fh.write_lists_to_file(x, y) + return x, y From e53897084660241708aefad931f2605ed2cbdbde Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:17:39 -0500 Subject: [PATCH 731/762] bug fix for the last commit --- domainlab/utils/generate_fbopt_phase_portrait.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 3a3b9cb4b..5f8908e89 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -84,10 +84,6 @@ def get_xy_from_event_file( for i in range(len(x)): assert int(x[i]) == x_int[i] - # write x and y data to a text file: - fh = ListFileHandler(event_file + "_backup.txt") - fh.write_lists_to_file(x, y) - return x, y @@ -154,6 +150,11 @@ def phase_portrait_combined( plt.ylabel(legend2) plt.title("phase portrait") + # write x and y data to a text file: + txt_name = os.path.join(output_dir, event_files[event_i] + "_backup.txt") + fh = ListFileHandler(txt_name) + fh.write_lists_to_file(x, y) + if not os.path.exists(output_dir): os.makedirs(output_dir) legend22 = legend2.split(os.sep)[-1] From 76b73a313f78c76a822d141f02b7cfeb4f2e1671 Mon Sep 17 00:00:00 2001 From: agisga <11449372+agisga@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:38:01 -0500 Subject: [PATCH 732/762] fbopt plots: fixes txt saving --- .../utils/generate_fbopt_phase_portrait.py | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 5f8908e89..41339bdc9 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -150,15 +150,16 @@ def phase_portrait_combined( plt.ylabel(legend2) plt.title("phase portrait") - # write x and y data to a text file: - txt_name = os.path.join(output_dir, event_files[event_i] + "_backup.txt") - fh = ListFileHandler(txt_name) - fh.write_lists_to_file(x, y) - if not os.path.exists(output_dir): os.makedirs(output_dir) legend22 = legend2.split(os.sep)[-1] + # write x and y data to a text file: + txt_name = os.path.join(output_dir, f"phase_portrait_combined_{legend22}.txt") + fh = ListFileHandler(txt_name) + fh.write_lists_to_file(x, y) + + # save figures fname = os.path.join(output_dir, f"phase_portrait_combined_{legend22}") plt.savefig(fname+".png", dpi=300) plt.savefig(fname+".pdf", format="pdf") @@ -199,6 +200,12 @@ def two_curves_combined( if not os.path.exists(output_dir): os.makedirs(output_dir) + # write x and y data to a text file: + txt_name = os.path.join(output_dir, f"timecourse_{legend11}_{legend22}.txt") + fh = ListFileHandler(txt_name) + fh.write_lists_to_file(x, y) + + # save figures fname = os.path.join(output_dir, f"timecourse_{legend11}_{legend22}") plt.savefig(fname+".png", dpi=300) plt.savefig(fname+".pdf", format="pdf") @@ -221,12 +228,18 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): legend11 = legend1.replace(os.sep, "_") + # save figures if not os.path.exists(output_dir): os.makedirs(output_dir) plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.png"), dpi=300) plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.pdf"), format="pdf") plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.svg"), format="svg") + # write x and y data to a text file: + txt_name = os.path.join(output_dir, f"timecourse_{legend11}.txt") + fh = ListFileHandler(txt_name) + fh.write_lists_to_file(list(range(len(x))), x) + if __name__ == "__main__": parser = argparse.ArgumentParser(description="plot") From f5c06a78543530035e746572240696776045bb3b Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 26 Feb 2024 11:01:14 +0100 Subject: [PATCH 733/762] single run reproduce --- ...pacs_diva_fbopt_alone_es1_autoki_1run.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_1run.yaml diff --git a/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_1run.yaml b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_1run.yaml new file mode 100644 index 000000000..9ec43ac7b --- /dev/null +++ b/examples/benchmark/pacs_diva_fbopt_alone_es1_autoki_1run.yaml @@ -0,0 +1,107 @@ +mode: grid + +output_dir: zoutput/benchmarks/pacs_diva_fbopt_alone_single_run + +sampling_seed: 0 + +startseed: 0 +endseed: 0 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_aug.py + dmem: False + lr: 5e-5 + epos: 500 + epos_min: 200 + es: 5 + bs: 32 + san_check: False + npath: examples/nets/resnet50domainbed.py + npath_dom: examples/nets/resnet50domainbed.py + zx_dim: 16 + zy_dim: 64 + zd_dim: 64 + + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + str_diva_multiplier_type: + distribution: categorical + datatype: str + values: + - gammad_recon + - gammad_recon_per_pixel + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + + mu_clip: + distribution: categorical + datatype: float + values: + - 10 + - 1000 + - 1 + - 100 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: uniform + + k_i_gain_ratio: + min: 0.1 + max: 1 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + model: diva + trainer: fbopt + force_setpoint_change_once: True + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + str_diva_multiplier_type: gammad_recon + mu_init: 1e-6 + k_i_gain_ratio: 0.5 + mu_clip: 10 + coeff_ma_output_state: 0.0 + coeff_ma_setpoint: 0.0 From ba1e19d3f2b7612e5f97c021f555037c672547f1 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 26 Feb 2024 11:12:17 +0100 Subject: [PATCH 734/762] move benchmark submit back --- scripts_fbopt/run_benchmark_slurm.sh => run_benchmark_slurm.sh | 0 .../run_benchmark_standalone.sh => run_benchmark_standalone.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename scripts_fbopt/run_benchmark_slurm.sh => run_benchmark_slurm.sh (100%) rename scripts_fbopt/run_benchmark_standalone.sh => run_benchmark_standalone.sh (100%) diff --git a/scripts_fbopt/run_benchmark_slurm.sh b/run_benchmark_slurm.sh similarity index 100% rename from scripts_fbopt/run_benchmark_slurm.sh rename to run_benchmark_slurm.sh diff --git a/scripts_fbopt/run_benchmark_standalone.sh b/run_benchmark_standalone.sh similarity index 100% rename from scripts_fbopt/run_benchmark_standalone.sh rename to run_benchmark_standalone.sh From e3ef1abae4b1bb39fc5b052aa7eab8316d28ced7 Mon Sep 17 00:00:00 2001 From: smilesun Date: Mon, 26 Feb 2024 11:15:17 +0100 Subject: [PATCH 735/762] change mode for submission script --- sbatch4submit_slurm_cpu_10days.sh | 0 sbatch4submit_slurm_cpu_3days.sh | 0 submit_slurm_via_cpu_10days.sh | 0 submit_slurm_via_cpu_3days.sh | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 sbatch4submit_slurm_cpu_10days.sh mode change 100755 => 100644 sbatch4submit_slurm_cpu_3days.sh mode change 100644 => 100755 submit_slurm_via_cpu_10days.sh mode change 100644 => 100755 submit_slurm_via_cpu_3days.sh diff --git a/sbatch4submit_slurm_cpu_10days.sh b/sbatch4submit_slurm_cpu_10days.sh old mode 100755 new mode 100644 diff --git a/sbatch4submit_slurm_cpu_3days.sh b/sbatch4submit_slurm_cpu_3days.sh old mode 100755 new mode 100644 diff --git a/submit_slurm_via_cpu_10days.sh b/submit_slurm_via_cpu_10days.sh old mode 100644 new mode 100755 diff --git a/submit_slurm_via_cpu_3days.sh b/submit_slurm_via_cpu_3days.sh old mode 100644 new mode 100755 From 98689ff9083b73f1618cf0eebbff704f3e7c9d18 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 27 Feb 2024 12:24:20 +0100 Subject: [PATCH 736/762] add output dir --- script_generate_all_figures_diva.sh | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 3a90af391..bf51dea23 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -1,6 +1,9 @@ #!/bin/bash -STR_LOSS_ELL = "loss_task/ell" +STR_LOSS_ELL="loss_task/ell" +OUT_DIR="./figures_diva" +# Number of points to plot: +phase_portrait_plot_len=50 # README: @@ -26,30 +29,27 @@ else skip_n=$2 fi -# Number of points to plot: -phase_portrait_plot_len=50 - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir="./figures_diva" --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait # Plot R and the corresponding set point curves (both in the same figure) -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss (gamma_d)" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss (gamma_d)" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL (beta_d)" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL (beta_d)" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir="./figures_diva" +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir=$OUT_DIR # Other plots (one curve per figure) @@ -57,5 +57,5 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p # Loop over the array for val in "${values[@]}" do - python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="$val" --legend1="$val" --output_dir="./figures_diva" + python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="$val" --legend1="$val" --output_dir=$OUT_DIR done From eea73e3827b3a315e01e15f4e2e05f5137eb094d Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 27 Feb 2024 12:50:13 +0100 Subject: [PATCH 737/762] added matplotlib from nutan --- .../utils/generate_fbopt_phase_portrait.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 41339bdc9..6a1cf0104 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -1,15 +1,22 @@ """ This file is used for generating phase portrait from tensorboard event files. """ - import argparse import glob import os - -import matplotlib.pyplot as plt import numpy as np from tensorboard.backend.event_processing.event_accumulator import EventAccumulator +import matplotlib +import matplotlib.pyplot as plt +from matplotlib.backends.backend_pdf import PdfPages +matplotlib.rcParams['pdf.fonttype'] = 42 +matplotlib.rcParams['text.usetex'] = True +plt.rcParams['text.latex.preamble'] = r'\usepackage{amsmath}' +font = {'size': 20} +matplotlib.rc('font', **font) + + class ListFileHandler: def __init__(self, file_path): @@ -216,7 +223,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): """ FIXME: colors parameter is not used """ - plt.figure() + fig = plt.figure() for event_i in range(len(event_files)): x, _ = get_xy_from_event_file(event_files[event_i], plot1=plot1) plt.plot(x) @@ -234,6 +241,9 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.png"), dpi=300) plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.pdf"), format="pdf") plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.svg"), format="svg") + pdf_page = PdfPages(os.path.join(output_dir, f"timecourse_{legend11}_pdfpage.pdf")) + pdf_page.savefig(fig, bbox_inches="tight") + pdf_page.close() # write x and y data to a text file: txt_name = os.path.join(output_dir, f"timecourse_{legend11}.txt") From 33c027a9072fcf12d8bdae763c53743faa7dfb64 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 27 Feb 2024 13:12:07 +0100 Subject: [PATCH 738/762] logscale --- .../utils/generate_fbopt_phase_portrait.py | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 6a1cf0104..b6b408c2b 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -182,16 +182,18 @@ def two_curves_combined( legend2=None, output_dir=".", title=None, -): + logscale=False): """ FIXME: colors parameter is not used """ - plt.figure() + fig = plt.figure() for event_i in range(len(event_files)): x, y = get_xy_from_event_file(event_files[event_i], plot1=plot1, plot2=plot2) plt.plot(x, color="blue") plt.plot(y, color="red") - plt.xlabel("epoch") + if logscale: + plt.yscale("log") + plt.xlabel("Epoch") # plt.ylabel("loss") if title is not None: plt.title(title) @@ -213,10 +215,16 @@ def two_curves_combined( fh.write_lists_to_file(x, y) # save figures + fname_logscale = "_logscale" if logscale else "" fname = os.path.join(output_dir, f"timecourse_{legend11}_{legend22}") - plt.savefig(fname+".png", dpi=300) - plt.savefig(fname+".pdf", format="pdf") - plt.savefig(fname+".svg", format="svg") + plt.savefig(fname+fname_logscale+".png", dpi=300) + plt.savefig(fname+fname_logscale+".pdf", format="pdf") + plt.savefig(fname+fname_logscale+".svg", format="svg") + pdf_page = PdfPages(fname+fname_logscale+"_pdfpage.pdf") + pdf_page.savefig(fig, bbox_inches="tight") + pdf_page.close() + + def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): @@ -314,6 +322,18 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): output_dir=args.output_dir, title=args.title, ) + two_curves_combined( + event_files, + colors, + plot1=args.plot1, + plot2=args.plot2, + legend1=args.legend1, + legend2=args.legend2, + output_dir=args.output_dir, + title=args.title, + logscale=True + ) + else: # one curve per plot plot_single_curve( From d11da9be86a3e991cb15f943944066a93ca9758b Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 27 Feb 2024 13:47:08 +0100 Subject: [PATCH 739/762] complex math display not possible --- script_generate_all_figures_diva.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index bf51dea23..349074fa5 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -5,6 +5,8 @@ OUT_DIR="./figures_diva" # Number of points to plot: phase_portrait_plot_len=50 +LOSS_GAMMA_D="$\mathbb{E}_{q_{\phi_d}(z_d|x)}[\log q_{\omega_d}(d|z_d)]$" + # README: # The following scripts will check event files from the 'runs' folder of the working directory. @@ -18,7 +20,6 @@ else runs_dir=$1 fi -# Phase portraits # a command line argument can be passed to this script, in order to skip the first few large jumps on the phase plots; if no argument is provided then all points will be plotted: if [ -z "$2" ]; then @@ -29,7 +30,11 @@ else skip_n=$2 fi -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss (gamma_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait + + + +# Phase portraits +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss $\gamma_d$" --legend1="$\ell$" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait @@ -40,8 +45,10 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait + + # Plot R and the corresponding set point curves (both in the same figure) -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss (gamma_d)" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss ($\gamma_d$)" --legend2="setpoint" --output_dir=$OUT_DIR python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir=$OUT_DIR From 3f1f04f799fd3f2747ba3769a776d776c3dc5046 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 27 Feb 2024 16:53:46 +0100 Subject: [PATCH 740/762] change output name --- domainlab/utils/generate_fbopt_phase_portrait.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index b6b408c2b..4031da9db 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -182,7 +182,8 @@ def two_curves_combined( legend2=None, output_dir=".", title=None, - logscale=False): + logscale=False, + prefix="output_r_"): """ FIXME: colors parameter is not used """ @@ -210,13 +211,13 @@ def two_curves_combined( os.makedirs(output_dir) # write x and y data to a text file: - txt_name = os.path.join(output_dir, f"timecourse_{legend11}_{legend22}.txt") + txt_name = os.path.join(output_dir, prefix+f"{legend11}_{legend22}.txt") fh = ListFileHandler(txt_name) fh.write_lists_to_file(x, y) # save figures fname_logscale = "_logscale" if logscale else "" - fname = os.path.join(output_dir, f"timecourse_{legend11}_{legend22}") + fname = os.path.join(output_dir, prefix+f"{legend11}_{legend22}") plt.savefig(fname+fname_logscale+".png", dpi=300) plt.savefig(fname+fname_logscale+".pdf", format="pdf") plt.savefig(fname+fname_logscale+".svg", format="svg") From 9907274dc74637a226ac237fb7af0308dbe46024 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 27 Feb 2024 17:01:05 +0100 Subject: [PATCH 741/762] remove latex in filename --- domainlab/utils/generate_fbopt_phase_portrait.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 4031da9db..304cc1b0e 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -5,6 +5,7 @@ import glob import os import numpy as np +import re from tensorboard.backend.event_processing.event_accumulator import EventAccumulator import matplotlib @@ -16,7 +17,9 @@ font = {'size': 20} matplotlib.rc('font', **font) - +def latex_to_nonlatex(latex_string): + nonlatex_string = re.sub(r'[{$}]', '', latex_string) + return nonlatex_string class ListFileHandler: def __init__(self, file_path): @@ -161,13 +164,15 @@ def phase_portrait_combined( os.makedirs(output_dir) legend22 = legend2.split(os.sep)[-1] + fname_legend = latex_to_nonlatex(legend22) + # write x and y data to a text file: - txt_name = os.path.join(output_dir, f"phase_portrait_combined_{legend22}.txt") + txt_name = os.path.join(output_dir, f"phase_portrait_{fname_legend}.txt") fh = ListFileHandler(txt_name) fh.write_lists_to_file(x, y) # save figures - fname = os.path.join(output_dir, f"phase_portrait_combined_{legend22}") + fname = os.path.join(output_dir, f"phase_portrait_{fname_legend}") plt.savefig(fname+".png", dpi=300) plt.savefig(fname+".pdf", format="pdf") plt.savefig(fname+".svg", format="svg") From 0ac873d720b4b0ad7bc8e25482fce122e0074d90 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 27 Feb 2024 17:04:46 +0100 Subject: [PATCH 742/762] . --- domainlab/utils/generate_fbopt_phase_portrait.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 304cc1b0e..5a5536e84 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -215,14 +215,16 @@ def two_curves_combined( if not os.path.exists(output_dir): os.makedirs(output_dir) + fname_legend = latex_to_nonlatex(legend11) + fname_legend += latex_to_nonlatex(legend22) # write x and y data to a text file: - txt_name = os.path.join(output_dir, prefix+f"{legend11}_{legend22}.txt") + txt_name = os.path.join(output_dir, prefix+f"fname_legend.txt") fh = ListFileHandler(txt_name) fh.write_lists_to_file(x, y) # save figures fname_logscale = "_logscale" if logscale else "" - fname = os.path.join(output_dir, prefix+f"{legend11}_{legend22}") + fname = os.path.join(output_dir, prefix+f"fname_legend") plt.savefig(fname+fname_logscale+".png", dpi=300) plt.savefig(fname+fname_logscale+".pdf", format="pdf") plt.savefig(fname+fname_logscale+".svg", format="svg") From 3edc1696996e3c5e9210b41cbed0ed23b6300658 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 27 Feb 2024 17:05:22 +0100 Subject: [PATCH 743/762] todo --- script_generate_all_figures_diva.new | 68 ++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 script_generate_all_figures_diva.new diff --git a/script_generate_all_figures_diva.new b/script_generate_all_figures_diva.new new file mode 100755 index 000000000..cbe9a71cf --- /dev/null +++ b/script_generate_all_figures_diva.new @@ -0,0 +1,68 @@ +#!/bin/bash + +STR_LOSS_ELL="loss_task/ell" +OUT_DIR="./figures_diva" +# Number of points to plot: +phase_portrait_plot_len=50 + +LOSS_GAMMA_D="$\mathbb{E}_{q_{\phi_d}(z_d|x)}[\log q_{\omega_d}(d|z_d)]$" + + +# README: +# The following scripts will check event files from the 'runs' folder of the working directory. +# To generate example tensorboard 'runs' folder, one could execute e.g. `sh run_fbopt_mnist_diva_autoki.sh` such that there will be 'runs' folder. + +if [ -z "$1" ]; then + # Check if an argument is provided + runs_dir="runs/*" +else + # Use the provided argument + runs_dir=$1 +fi + + +# a command line argument can be passed to this script, in order to skip the first few large jumps on the phase plots; if no argument is provided then all points will be plotted: +if [ -z "$2" ]; then + # Check if an argument is provided + skip_n=0 +else + # Use the provided argument + skip_n=$2 +fi + + + + +# Phase portraits +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="$R_\gamma_d(\cdot)$" --legend1="$\ell(\cdot)$" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="$R_{\mu_{recon}}$" --legend1="$\ell(\cdot)$" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait + + + + +# Plot R and the corresponding set point curves (both in the same figure) +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="$R_\gamma_d$" --legend2="setpoint" --output_dir=$OUT_DIR + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir=$OUT_DIR + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL $(-R_{beta_d}$)" --legend2="setpoint" --output_dir=$OUT_DIR + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir=$OUT_DIR + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir=$OUT_DIR + + + # Other plots (one curve per figure) + values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_x' 'controller_gain/gamma_d' 'controller_gain/mu_recon' 'dyn_mu/beta_d' 'delta/beta_d' 'dyn_mu/beta_y' 'delta/beta_y' 'dyn_mu/beta_x' 'delta/beta_x' 'dyn_mu/gamma_d' 'delta/gamma_d' 'dyn_mu/mu_recon' 'delta/mu_recon' 'loss_task/penalized' 'loss_task/ell' 'acc/te' 'acc/val' 'acc/sel' 'acc/setpoint') + # Loop over the array + for val in "${values[@]}" + do + python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="$val" --legend1="$val" --output_dir=$OUT_DIR + done From 75eaaa324d129777308ba4e939c72d44851b0cc8 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 10:34:30 +0100 Subject: [PATCH 744/762] . --- domainlab/utils/generate_fbopt_phase_portrait.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 5a5536e84..dc22dcb39 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -250,14 +250,15 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): # plt.title("timecourse") legend11 = legend1.replace(os.sep, "_") + fname_legend = latex_to_nonlatex(legend11) # save figures if not os.path.exists(output_dir): os.makedirs(output_dir) - plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.png"), dpi=300) - plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.pdf"), format="pdf") - plt.savefig(os.path.join(output_dir, f"timecourse_{legend11}.svg"), format="svg") - pdf_page = PdfPages(os.path.join(output_dir, f"timecourse_{legend11}_pdfpage.pdf")) + plt.savefig(os.path.join(output_dir, f"timecourse_{fname_legend}.png"), dpi=300) + plt.savefig(os.path.join(output_dir, f"timecourse_{fname_legend}.pdf"), format="pdf") + plt.savefig(os.path.join(output_dir, f"timecourse_{fname_legend}.svg"), format="svg") + pdf_page = PdfPages(os.path.join(output_dir, f"timecourse_{fname_legend}_pdfpage.pdf")) pdf_page.savefig(fig, bbox_inches="tight") pdf_page.close() From c8f5f5f1a28c1bd0d0a0f523b1bfcd848f550556 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 11:49:06 +0100 Subject: [PATCH 745/762] skip draw --- .../utils/generate_fbopt_phase_portrait.py | 24 +++++-- script_generate_all_figures_diva.new | 68 ------------------- script_generate_all_figures_diva.sh | 16 ++--- 3 files changed, 25 insertions(+), 83 deletions(-) delete mode 100755 script_generate_all_figures_diva.new diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index dc22dcb39..6d8c695d9 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -17,6 +17,12 @@ font = {'size': 20} matplotlib.rc('font', **font) + +def sav2pdfpage(fig, fname): + pdf_page = PdfPages(fname) + pdf_page.savefig(fig, bbox_inches="tight") + pdf_page.close() + def latex_to_nonlatex(latex_string): nonlatex_string = re.sub(r'[{$}]', '', latex_string) return nonlatex_string @@ -106,14 +112,14 @@ def phase_portrait_combined( legend1=None, legend2=None, plot_len=None, - skip_first_n=0, + skip_n_steps=1, output_dir=".", ): """ combined phase portait for multiple (at least one) Tensorboard event files in the same plot """ - plt.figure() + fig = plt.figure() for event_i in range(len(event_files)): x, y = get_xy_from_event_file(event_files[event_i], plot1=plot1, plot2=plot2) @@ -122,11 +128,14 @@ def phase_portrait_combined( if plot_len is None: plot_len = len(x) # truncate x and y to the desired length: - x = x[skip_first_n:(plot_len+skip_first_n)] - y = y[skip_first_n:(plot_len+skip_first_n)] + x = x[:plot_len] + y = y[:plot_len] + # skip every n steps + x = x[0::skip_n_steps] + y = y[0::skip_n_steps] head_w_glob = min((max(x) - min(x)) / 100.0, (max(y) - min(y)) / 100.0) - for i in range(plot_len - 1): + for i in range(len(x) - 1): xy_dist = np.sqrt((x[i + 1] - x[i]) ** 2 + (y[i + 1] - y[i]) ** 2) head_l = xy_dist / 30.0 head_w = min(head_l, head_w_glob) @@ -176,6 +185,7 @@ def phase_portrait_combined( plt.savefig(fname+".png", dpi=300) plt.savefig(fname+".pdf", format="pdf") plt.savefig(fname+".svg", format="svg") + sav2pdfpage(fig, fname+"_pdfpage.pdf") def two_curves_combined( @@ -275,7 +285,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): parser.add_argument("-legend1", "--legend1", default=None, type=str) parser.add_argument("-legend2", "--legend2", default=None, type=str) parser.add_argument("-plot_len", "--plot_len", default=None, type=int) - parser.add_argument("-skip_first_n", "--skip_first_n", default=None, type=int) + parser.add_argument("-skip_n_steps", "--skip_n_steps", default=None, type=int) parser.add_argument("-title", "--title", default=None, type=str) parser.add_argument("--output_dir", default=".", type=str) parser.add_argument("--runs_dir", default="runs", type=str) @@ -315,7 +325,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): legend1=args.legend1, legend2=args.legend2, plot_len=args.plot_len, - skip_first_n=args.skip_first_n, + skip_n_steps=args.skip_n_steps, output_dir=args.output_dir, ) else: diff --git a/script_generate_all_figures_diva.new b/script_generate_all_figures_diva.new deleted file mode 100755 index cbe9a71cf..000000000 --- a/script_generate_all_figures_diva.new +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -STR_LOSS_ELL="loss_task/ell" -OUT_DIR="./figures_diva" -# Number of points to plot: -phase_portrait_plot_len=50 - -LOSS_GAMMA_D="$\mathbb{E}_{q_{\phi_d}(z_d|x)}[\log q_{\omega_d}(d|z_d)]$" - - -# README: -# The following scripts will check event files from the 'runs' folder of the working directory. -# To generate example tensorboard 'runs' folder, one could execute e.g. `sh run_fbopt_mnist_diva_autoki.sh` such that there will be 'runs' folder. - -if [ -z "$1" ]; then - # Check if an argument is provided - runs_dir="runs/*" -else - # Use the provided argument - runs_dir=$1 -fi - - -# a command line argument can be passed to this script, in order to skip the first few large jumps on the phase plots; if no argument is provided then all points will be plotted: -if [ -z "$2" ]; then - # Check if an argument is provided - skip_n=0 -else - # Use the provided argument - skip_n=$2 -fi - - - - -# Phase portraits -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="$R_\gamma_d(\cdot)$" --legend1="$\ell(\cdot)$" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="$R_{\mu_{recon}}$" --legend1="$\ell(\cdot)$" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait - - - - -# Plot R and the corresponding set point curves (both in the same figure) -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="$R_\gamma_d$" --legend2="setpoint" --output_dir=$OUT_DIR - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir=$OUT_DIR - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL $(-R_{beta_d}$)" --legend2="setpoint" --output_dir=$OUT_DIR - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir=$OUT_DIR - -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir=$OUT_DIR - - - # Other plots (one curve per figure) - values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_x' 'controller_gain/gamma_d' 'controller_gain/mu_recon' 'dyn_mu/beta_d' 'delta/beta_d' 'dyn_mu/beta_y' 'delta/beta_y' 'dyn_mu/beta_x' 'delta/beta_x' 'dyn_mu/gamma_d' 'delta/gamma_d' 'dyn_mu/mu_recon' 'delta/mu_recon' 'loss_task/penalized' 'loss_task/ell' 'acc/te' 'acc/val' 'acc/sel' 'acc/setpoint') - # Loop over the array - for val in "${values[@]}" - do - python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="$val" --legend1="$val" --output_dir=$OUT_DIR - done diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 349074fa5..5a21d6532 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x -v STR_LOSS_ELL="loss_task/ell" OUT_DIR="./figures_diva" @@ -34,25 +34,25 @@ fi # Phase portraits -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="loss $\gamma_d$" --legend1="$\ell$" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="\$R_{\gamma_d}(\cdot)\$" --legend1="$\ell(\cdot)$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="$\ell(\cdot)$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_first_n $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait # Plot R and the corresponding set point curves (both in the same figure) -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="loss ($\gamma_d$)" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="$R_\gamma_d$" --legend2="setpoint" --output_dir=$OUT_DIR python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL (beta_d)" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL (-$R_{beta_d}$)" --legend2="setpoint" --output_dir=$OUT_DIR python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir=$OUT_DIR From 4e4f4900c6bf01dfcc15779ae9a3cfd50ba23f14 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 12:12:02 +0100 Subject: [PATCH 746/762] arrow width --- domainlab/utils/generate_fbopt_phase_portrait.py | 1 + script_generate_all_figures_diva.sh | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 6d8c695d9..67d927ec7 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -139,6 +139,7 @@ def phase_portrait_combined( xy_dist = np.sqrt((x[i + 1] - x[i]) ** 2 + (y[i + 1] - y[i]) ** 2) head_l = xy_dist / 30.0 head_w = min(head_l, head_w_glob) + head_w = max(head_w, head_w_glob*100/plot_len) plt.arrow( x[i], y[i], diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 5a21d6532..db1d4795c 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -34,9 +34,9 @@ fi # Phase portraits -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="\$R_{\gamma_d}(\cdot)\$" --legend1="$\ell(\cdot)$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="\$R_{\gamma_d}(\cdot)\$" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="$\ell(\cdot)$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait @@ -48,15 +48,15 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p # Plot R and the corresponding set point curves (both in the same figure) -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="$R_\gamma_d$" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="\$R_{\gamma_d}\$" --legend2="setpoint" --output_dir=$OUT_DIR python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="KL (-$R_{beta_d}$)" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="-\$R_{\beta_d}\$" --legend2="setpoint" --output_dir=$OUT_DIR python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="KL (beta_y)" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="-\$R_{\beta_y}\$" --legend2="setpoint" --output_dir=$OUT_DIR # Other plots (one curve per figure) From cd800eb2dafcbec6031b1f29b930524559e80357 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 13:08:32 +0100 Subject: [PATCH 747/762] plot len --- .../utils/generate_fbopt_phase_portrait.py | 44 ++++++++++++++----- script_generate_all_figures_diva.sh | 10 ++--- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 67d927ec7..58c2fd10e 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -199,15 +199,26 @@ def two_curves_combined( output_dir=".", title=None, logscale=False, - prefix="output_r_"): + neg=False, + prefix="output_r_", + plot_len=None): """ FIXME: colors parameter is not used """ fig = plt.figure() for event_i in range(len(event_files)): + if plot_len is None: + plot_len = len(x) + # truncate x and y to the desired length: + x = x[:plot_len] + y = y[:plot_len] x, y = get_xy_from_event_file(event_files[event_i], plot1=plot1, plot2=plot2) - plt.plot(x, color="blue") - plt.plot(y, color="red") + if neg: + plt.plot(-np.array(x), color="blue") + plt.plot(-np.array(y), color="red") + else: + plt.plot(x, color="blue") + plt.plot(y, color="red") if logscale: plt.yscale("log") plt.xlabel("Epoch") @@ -229,13 +240,13 @@ def two_curves_combined( fname_legend = latex_to_nonlatex(legend11) fname_legend += latex_to_nonlatex(legend22) # write x and y data to a text file: - txt_name = os.path.join(output_dir, prefix+f"fname_legend.txt") + txt_name = os.path.join(output_dir, prefix+f"{fname_legend}.txt") fh = ListFileHandler(txt_name) fh.write_lists_to_file(x, y) # save figures fname_logscale = "_logscale" if logscale else "" - fname = os.path.join(output_dir, prefix+f"fname_legend") + fname = os.path.join(output_dir, prefix+f"{fname_legend}") plt.savefig(fname+fname_logscale+".png", dpi=300) plt.savefig(fname+fname_logscale+".pdf", format="pdf") plt.savefig(fname+fname_logscale+".svg", format="svg") @@ -246,13 +257,17 @@ def two_curves_combined( -def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): +def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir=".", plot_len=None): """ FIXME: colors parameter is not used """ fig = plt.figure() for event_i in range(len(event_files)): x, _ = get_xy_from_event_file(event_files[event_i], plot1=plot1) + if plot_len is None: + plot_len = len(x) + # truncate x and y to the desired length: + x = x[:plot_len] plt.plot(x) plt.xlabel("time") if legend1 is None: @@ -266,15 +281,15 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): # save figures if not os.path.exists(output_dir): os.makedirs(output_dir) - plt.savefig(os.path.join(output_dir, f"timecourse_{fname_legend}.png"), dpi=300) - plt.savefig(os.path.join(output_dir, f"timecourse_{fname_legend}.pdf"), format="pdf") - plt.savefig(os.path.join(output_dir, f"timecourse_{fname_legend}.svg"), format="svg") - pdf_page = PdfPages(os.path.join(output_dir, f"timecourse_{fname_legend}_pdfpage.pdf")) + plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.png"), dpi=300) + plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.pdf"), format="pdf") + plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.svg"), format="svg") + pdf_page = PdfPages(os.path.join(output_dir, f"single_timecourse_{fname_legend}_pdfpage.pdf")) pdf_page.savefig(fig, bbox_inches="tight") pdf_page.close() # write x and y data to a text file: - txt_name = os.path.join(output_dir, f"timecourse_{legend11}.txt") + txt_name = os.path.join(output_dir, f"single_timecourse_{fname_legend}.txt") fh = ListFileHandler(txt_name) fh.write_lists_to_file(list(range(len(x))), x) @@ -290,6 +305,11 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): parser.add_argument("-title", "--title", default=None, type=str) parser.add_argument("--output_dir", default=".", type=str) parser.add_argument("--runs_dir", default="runs", type=str) + parser.add_argument( + "--neg", + action="store_true", + help="if true, plot negative of a list", + ) parser.add_argument( "--phase_portrait", action="store_true", @@ -341,6 +361,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): legend2=args.legend2, output_dir=args.output_dir, title=args.title, + neg=args.neg ) two_curves_combined( event_files, @@ -351,6 +372,7 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir="."): legend2=args.legend2, output_dir=args.output_dir, title=args.title, + neg=args.neg, logscale=True ) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index db1d4795c..e3a7ed339 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -40,7 +40,7 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait +# python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait @@ -52,14 +52,14 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="-\$R_{\beta_d}\$" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="-\$R_{\beta_d}\$" --legend2="setpoint" --output_dir=$OUT_DIR --neg -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir=$OUT_DIR +# python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="-\$R_{\beta_y}\$" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="-\$R_{\beta_y}\$" --legend2="setpoint" --output_dir=$OUT_DIR --neg - # Other plots (one curve per figure) + # One curve per figure values=('controller_gain/beta_d' 'controller_gain/beta_y' 'controller_gain/beta_x' 'controller_gain/gamma_d' 'controller_gain/mu_recon' 'dyn_mu/beta_d' 'delta/beta_d' 'dyn_mu/beta_y' 'delta/beta_y' 'dyn_mu/beta_x' 'delta/beta_x' 'dyn_mu/gamma_d' 'delta/gamma_d' 'dyn_mu/mu_recon' 'delta/mu_recon' 'loss_task/penalized' 'loss_task/ell' 'acc/te' 'acc/val' 'acc/sel' 'acc/setpoint') # Loop over the array for val in "${values[@]}" From 1712cac7ba6aa32185466a0649fa704500b7cf2e Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 13:54:41 +0100 Subject: [PATCH 748/762] phase portrait arrow size automatic --- domainlab/utils/generate_fbopt_phase_portrait.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 58c2fd10e..6d7052886 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -134,12 +134,13 @@ def phase_portrait_combined( x = x[0::skip_n_steps] y = y[0::skip_n_steps] - head_w_glob = min((max(x) - min(x)) / 100.0, (max(y) - min(y)) / 100.0) + head_w_glob = min((max(x) - min(x)) / plot_len, (max(y) - min(y)) / plot_len) + head_w_glob *= skip_n_steps for i in range(len(x) - 1): xy_dist = np.sqrt((x[i + 1] - x[i]) ** 2 + (y[i + 1] - y[i]) ** 2) - head_l = xy_dist / 30.0 - head_w = min(head_l, head_w_glob) - head_w = max(head_w, head_w_glob*100/plot_len) + head_l = xy_dist / plot_len * skip_n_steps + # let width be one tenth of length + head_w = min(head_l/10.0, head_w_glob) plt.arrow( x[i], y[i], @@ -168,7 +169,7 @@ def phase_portrait_combined( legend2 = plot2 plt.xlabel(legend1) plt.ylabel(legend2) - plt.title("phase portrait") + plt.title("output portrait") if not os.path.exists(output_dir): os.makedirs(output_dir) @@ -207,12 +208,13 @@ def two_curves_combined( """ fig = plt.figure() for event_i in range(len(event_files)): + x, y = get_xy_from_event_file(event_files[event_i], plot1=plot1, plot2=plot2) if plot_len is None: plot_len = len(x) # truncate x and y to the desired length: x = x[:plot_len] y = y[:plot_len] - x, y = get_xy_from_event_file(event_files[event_i], plot1=plot1, plot2=plot2) + if neg: plt.plot(-np.array(x), color="blue") plt.plot(-np.array(y), color="red") From d3b0a126a2574c8055ebd1f092df98a682487997 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 15:27:30 +0100 Subject: [PATCH 749/762] color bar for phase portrait --- domainlab/utils/generate_fbopt_phase_portrait.py | 14 ++++++++++---- script_generate_all_figures_diva.sh | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 6d7052886..54387c66e 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -157,11 +157,17 @@ def phase_portrait_combined( # more visible. # length_includes_head=False makes the arrow stick too far out # beyond of the point, which let; so, True is used. - colors = ["red", "green", "blue", "yellow", "purple"] - plt.plot(x[0], y[0], "ko") - list_color = [colors[i % len(colors)] for i, h in enumerate(x)] - plt.scatter(x, y, s=1, c=np.array(list_color)) + # use finite color + # colors = ["red", "green", "blue", "yellow", "purple"] + # list_color = [colors[i % len(colors)] for i, h in enumerate(x)] + # use numerical color + colors = np.arange(0, plot_len, skip_n_steps) + plt.plot(x[0], y[0], "ko") + # plt.scatter(x, y, s=1, c=np.array(list_color)) + # size + plt.scatter(x, y, s=10, c=colors, cmap='viridis') + plt.colorbar() if legend1 is None: legend1 = plot1 diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index e3a7ed339..f0da11499 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -3,7 +3,7 @@ STR_LOSS_ELL="loss_task/ell" OUT_DIR="./figures_diva" # Number of points to plot: -phase_portrait_plot_len=50 +phase_portrait_plot_len=120 LOSS_GAMMA_D="$\mathbb{E}_{q_{\phi_d}(z_d|x)}[\log q_{\omega_d}(d|z_d)]$" From 560379092fece170949418657f33044a0e16727d Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 15:40:18 +0100 Subject: [PATCH 750/762] bounding gbox tight --- .../utils/generate_fbopt_phase_portrait.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 54387c66e..acf5bc2db 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -190,9 +190,9 @@ def phase_portrait_combined( # save figures fname = os.path.join(output_dir, f"phase_portrait_{fname_legend}") - plt.savefig(fname+".png", dpi=300) - plt.savefig(fname+".pdf", format="pdf") - plt.savefig(fname+".svg", format="svg") + plt.savefig(fname+".png", dpi=300, bbox_inches="tight") + plt.savefig(fname+".pdf", format="pdf", bbox_inches="tight") + plt.savefig(fname+".svg", format="svg", bbox_inches="tight") sav2pdfpage(fig, fname+"_pdfpage.pdf") @@ -255,9 +255,9 @@ def two_curves_combined( # save figures fname_logscale = "_logscale" if logscale else "" fname = os.path.join(output_dir, prefix+f"{fname_legend}") - plt.savefig(fname+fname_logscale+".png", dpi=300) - plt.savefig(fname+fname_logscale+".pdf", format="pdf") - plt.savefig(fname+fname_logscale+".svg", format="svg") + plt.savefig(fname+fname_logscale+".png", dpi=300, bbox_inches="tight") + plt.savefig(fname+fname_logscale+".pdf", format="pdf", bbox_inches="tight") + plt.savefig(fname+fname_logscale+".svg", format="svg", bbox_inches="tight") pdf_page = PdfPages(fname+fname_logscale+"_pdfpage.pdf") pdf_page.savefig(fig, bbox_inches="tight") pdf_page.close() @@ -289,9 +289,9 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir=".", # save figures if not os.path.exists(output_dir): os.makedirs(output_dir) - plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.png"), dpi=300) - plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.pdf"), format="pdf") - plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.svg"), format="svg") + plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.png"), dpi=300, bbox_inches="tight") + plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.pdf"), format="pdf", bbox_inches="tight") + plt.savefig(os.path.join(output_dir, f"single_timecourse_{fname_legend}.svg"), format="svg", bbox_inches="tight") pdf_page = PdfPages(os.path.join(output_dir, f"single_timecourse_{fname_legend}_pdfpage.pdf")) pdf_page.savefig(fig, bbox_inches="tight") pdf_page.close() From 9e1eb99f9fe075c02880941eb3ff190b77b44127 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 15:54:24 +0100 Subject: [PATCH 751/762] remove \ in filename --- domainlab/utils/generate_fbopt_phase_portrait.py | 1 + 1 file changed, 1 insertion(+) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index acf5bc2db..39c3d5c14 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -25,6 +25,7 @@ def sav2pdfpage(fig, fname): def latex_to_nonlatex(latex_string): nonlatex_string = re.sub(r'[{$}]', '', latex_string) + nonlatex_string = nonlatex_string.replace("\\", "") return nonlatex_string class ListFileHandler: From 5364878934d2ecd6f13d40cf1b49f6e53c530f09 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 15:57:56 +0100 Subject: [PATCH 752/762] more latex --- script_generate_all_figures_diva.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index f0da11499..be87f14c0 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -36,7 +36,7 @@ fi # Phase portraits python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_gamma_d" --plot1="loss_task/ell" --legend2="\$R_{\gamma_d}(\cdot)\$" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="reconstruction loss" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="\$R_{\mu_{recon}}(\cdot)\$" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait From 7385e815e39c0b94dfee7db221807795b82da893 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 15:59:39 +0100 Subject: [PATCH 753/762] . --- script_generate_all_figures_diva.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index be87f14c0..9a554a025 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -38,7 +38,7 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="\$R_{\mu_{recon}}(\cdot)\$" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="KL (beta_d)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="\$R_{\beta_d}(\cdot)\$" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait # python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait From 0ed3a213b37a5cf404ef48d483560f5f5565547b Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 16:43:47 +0100 Subject: [PATCH 754/762] latex in plot --- script_generate_all_figures_diva.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index 9a554a025..b145d2323 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -38,11 +38,11 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_mu_recon" --plot1="loss_task/ell" --legend2="\$R_{\mu_{recon}}(\cdot)\$" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="\$R_{\beta_d}(\cdot)\$" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_d" --plot1="loss_task/ell" --legend2="\$R_{\beta_d}(\cdot)\$" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait # python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_x" --plot1="loss_task/ell" --legend2="KL (beta_x)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="KL (beta_y)" --legend1="ell" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot2="lossrd/dyn_beta_y" --plot1="loss_task/ell" --legend2="\$R_{beta_y}(\cdot)\$" --legend1="\$\ell(\cdot)\$" --plot_len $phase_portrait_plot_len --skip_n_steps $skip_n --output_dir=$OUT_DIR --phase_portrait @@ -50,13 +50,13 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p # Plot R and the corresponding set point curves (both in the same figure) python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_gamma_d" --plot2="lossrs/setpoint_gamma_d" --legend1="\$R_{\gamma_d}\$" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="reconstruction loss" --legend2="setpoint" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_mu_recon" --plot2="lossrs/setpoint_mu_recon" --legend1="\$R_{\mu_{recon}}(\cdot)\$" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="-\$R_{\beta_d}\$" --legend2="setpoint" --output_dir=$OUT_DIR --neg +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_d" --plot2="lossrs/setpoint_beta_d" --legend1="\$R_{\beta_d}(\cdot)\$" --legend2="setpoint" --output_dir=$OUT_DIR --neg # python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_x" --plot2="lossrs/setpoint_beta_x" --legend1="KL (beta_x)" --legend2="setpoint" --output_dir=$OUT_DIR -python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="-\$R_{\beta_y}\$" --legend2="setpoint" --output_dir=$OUT_DIR --neg +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="lossrd/dyn_beta_y" --plot2="lossrs/setpoint_beta_y" --legend1="\$R_{\beta_y}(\cdot)\$" --legend2="setpoint" --output_dir=$OUT_DIR --neg # One curve per figure From 3b1bb09baa009097bc1dc1a67fcb8b5c51a05bc5 Mon Sep 17 00:00:00 2001 From: smilesun Date: Wed, 28 Feb 2024 16:49:30 +0100 Subject: [PATCH 755/762] phase portrait neg --- domainlab/utils/generate_fbopt_phase_portrait.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 39c3d5c14..3592f3aad 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -135,6 +135,9 @@ def phase_portrait_combined( x = x[0::skip_n_steps] y = y[0::skip_n_steps] + x = [-ele if ele <0 else ele for ele in x ] + y = [-ele if ele <0 else ele for ele in y] + head_w_glob = min((max(x) - min(x)) / plot_len, (max(y) - min(y)) / plot_len) head_w_glob *= skip_n_steps for i in range(len(x) - 1): From b70dbd0e1417b028724f440a69a1c701ccc1c8d2 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 29 Feb 2024 10:52:07 +0100 Subject: [PATCH 756/762] log scale to phase portrait plot after carla's suggestion --- domainlab/utils/generate_fbopt_phase_portrait.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 3592f3aad..4c064b1b3 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -171,6 +171,8 @@ def phase_portrait_combined( # plt.scatter(x, y, s=1, c=np.array(list_color)) # size plt.scatter(x, y, s=10, c=colors, cmap='viridis') + plt.yscale("log") + plt.xscale("log") plt.colorbar() if legend1 is None: From 382005ef83cd9395522e5aaf58d4962900148a73 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 29 Feb 2024 13:29:32 +0100 Subject: [PATCH 757/762] log single curve --- domainlab/utils/generate_fbopt_phase_portrait.py | 3 ++- script_generate_all_figures_diva.sh | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/domainlab/utils/generate_fbopt_phase_portrait.py b/domainlab/utils/generate_fbopt_phase_portrait.py index 4c064b1b3..ef4b28806 100644 --- a/domainlab/utils/generate_fbopt_phase_portrait.py +++ b/domainlab/utils/generate_fbopt_phase_portrait.py @@ -283,7 +283,8 @@ def plot_single_curve(event_files, colors, plot1, legend1=None, output_dir=".", # truncate x and y to the desired length: x = x[:plot_len] plt.plot(x) - plt.xlabel("time") + plt.yscale("log") + plt.xlabel("Epoch") if legend1 is None: legend1 = plot1 plt.ylabel(legend1) diff --git a/script_generate_all_figures_diva.sh b/script_generate_all_figures_diva.sh index b145d2323..e7f9617d2 100755 --- a/script_generate_all_figures_diva.sh +++ b/script_generate_all_figures_diva.sh @@ -66,3 +66,11 @@ python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --p do python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="$val" --legend1="$val" --output_dir=$OUT_DIR done + + +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="dyn_mu/mu_recon" --legend1="\$\mu_{recon}\$" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="dyn_mu/gamma_d" --legend1="\$\gamma_d\$" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="dyn_mu/beta_y" --legend1="\$\beta_y\$" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="loss_task/ell" --legend1="\$\ell(\cdot)\$" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="loss_task/penalized" --legend1="\$\ell(\cdot)+\mu^TR(\cdot)\$" --output_dir=$OUT_DIR +python domainlab/utils/generate_fbopt_phase_portrait.py --runs_dir $runs_dir --plot1="controller_gain/beta_y" --legend1="controller gain for \$\beta_y\$" --output_dir=$OUT_DIR From f3e9d0faf725914942b69134ba01e00074acc14b Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 1 Mar 2024 10:18:48 +0100 Subject: [PATCH 758/762] comment how setpoint model selction works --- domainlab/algos/msels/c_msel_setpoint_delay.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index 87c9b3c84..d8948bf3b 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -29,15 +29,24 @@ def oracle_last_setpoint_sel_te_acc(self): def update(self, clear_counter=False): """ if the best model should be updated + currently, clear_counter is set via + flag = super().tr_epoch(epoch, self.flag_setpoint_updated) """ logger = Logger.get_logger() logger.info( f"setpoint selected current acc {self._oracle_last_setpoint_sel_te_acc}" ) if clear_counter: + # for the current version of code, clear_counter = flag_setpoint_updated log_message = ( f"setpoint msel te acc updated from " + # self._oracle_last_setpoint_sel_te_acc start from 0.0, and always saves + # the test acc when last setpoint decrease occurs f"{self._oracle_last_setpoint_sel_te_acc} to " + # self.sel_model_te_acc defined as a property + # in a_msel, which returns self.msel.sel_model_te_acc + # is the validation acc based model selection, which + # does not take setpoint into account f"{self.sel_model_te_acc}" ) logger.info(log_message) From 1ae0ef758f9a45d447c603302e414df41b68ea55 Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 8 Mar 2024 10:23:15 +0100 Subject: [PATCH 759/762] . --- domainlab/algos/msels/c_msel_setpoint_delay.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/domainlab/algos/msels/c_msel_setpoint_delay.py b/domainlab/algos/msels/c_msel_setpoint_delay.py index d8948bf3b..8387dbb26 100644 --- a/domainlab/algos/msels/c_msel_setpoint_delay.py +++ b/domainlab/algos/msels/c_msel_setpoint_delay.py @@ -1,16 +1,14 @@ """ -Multiobjective Model Selection +logs the best up-to-event selected model at each event when setpoint shrinks """ -import copy - from domainlab.algos.msels.a_model_sel import AMSel from domainlab.utils.logger import Logger class MSelSetpointDelay(AMSel): """ - 1. Model selection using validation performance - 2. Only update if setpoint has been decreased + This class decorate another model selection object, it logs the current + selected performance from the decoratee each time the setpoint shrinks """ def __init__(self, msel): @@ -51,5 +49,6 @@ def update(self, clear_counter=False): ) logger.info(log_message) self._oracle_last_setpoint_sel_te_acc = self.sel_model_te_acc + # let decoratee decide if model should be selected or not flag = self.msel.update(clear_counter) return flag From 56e06cb06fdd6fa1331dddfbd0e23977a7ae2b1a Mon Sep 17 00:00:00 2001 From: smilesun Date: Fri, 8 Mar 2024 10:23:52 +0100 Subject: [PATCH 760/762] . --- domainlab/algos/msels/c_msel_tr_loss.py | 2 +- domainlab/algos/msels/c_msel_val_top_k.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/domainlab/algos/msels/c_msel_tr_loss.py b/domainlab/algos/msels/c_msel_tr_loss.py index 7ed3f1168..58ca03e21 100644 --- a/domainlab/algos/msels/c_msel_tr_loss.py +++ b/domainlab/algos/msels/c_msel_tr_loss.py @@ -1,5 +1,5 @@ """ -Model Selection should be decoupled from +AMSel.accept ---> Trainer """ import math diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index 4836a6245..f557c7dc1 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -57,5 +57,5 @@ def update(self, clear_counter=False): f"{self._sel_model_te_acc} to {metric_te_current} to ensure consistency" ) self._sel_model_te_acc = metric_te_current - return True + return True # if metric_val_current > acc_min: return flag_super From 6f37464328d1ff884efb5580299fc7be23336642 Mon Sep 17 00:00:00 2001 From: smilesun Date: Thu, 14 Mar 2024 09:14:20 +0100 Subject: [PATCH 761/762] comment --- domainlab/algos/msels/c_msel_val_top_k.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domainlab/algos/msels/c_msel_val_top_k.py b/domainlab/algos/msels/c_msel_val_top_k.py index f557c7dc1..4e4a92bd1 100644 --- a/domainlab/algos/msels/c_msel_val_top_k.py +++ b/domainlab/algos/msels/c_msel_val_top_k.py @@ -58,4 +58,4 @@ def update(self, clear_counter=False): ) self._sel_model_te_acc = metric_te_current return True # if metric_val_current > acc_min: - return flag_super + return flag_super # flag_super is flag from super()=MSelValPerf From 7bdf2effcf92688a76836678d01d65800345b034 Mon Sep 17 00:00:00 2001 From: smilesun Date: Tue, 7 May 2024 16:02:57 +0200 Subject: [PATCH 762/762] dial --- examples/benchmark/pacs_dial_mhof.yaml | 94 ++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 examples/benchmark/pacs_dial_mhof.yaml diff --git a/examples/benchmark/pacs_dial_mhof.yaml b/examples/benchmark/pacs_dial_mhof.yaml new file mode 100644 index 000000000..32179c041 --- /dev/null +++ b/examples/benchmark/pacs_dial_mhof.yaml @@ -0,0 +1,94 @@ +mode: grid + +output_dir: zoutput/benchmarks/dial + +sampling_seed: 0 + +startseed: 0 +endseed: 0 + +test_domains: + - sketch + +domainlab_args: + tpath: examples/tasks/task_pacs_aug.py + dmem: False + lr: 5e-5 + epos: 500 + epos_min: 200 + es: 5 + bs: 32 + san_check: False + npath: examples/nets/resnet50domainbed.py + +Shared params: + ini_setpoint_ratio: + min: 0.990 + max: 0.999 + num: 2 + distribution: uniform + + coeff_ma_output_state: + distribution: categorical + datatype: float + values: + - 0.1 + - 0.5 + + mu_clip: + distribution: categorical + datatype: float + values: + - 10 + - 1000 + - 1 + - 100 + + k_i_gain: + min: 0.0001 + max: 0.01 + num: 2 + distribution: uniform + + k_i_gain_ratio: + min: 0.1 + max: 1 + num: 3 + distribution: uniform + + mu_init: + min: 0.000001 + max: 0.00001 + step: 0.000001 + num: 3 + distribution: loguniform + + gamma_y: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + gamma_d: + min: 1.0 + max: 1e6 + step: 100 + num: 3 + distribution: loguniform + + + +# Test fbopt with different hyperparameter configurations, no noeed to tune mu_clip since this is the job of KI gain when mu_init is small + +diva_fbopt_full: + model: erm + trainer: fbopt_dial + force_setpoint_change_once: True + gamma_y: 1.0 + ini_setpoint_ratio: 0.99 + mu_init: 1e-6 + k_i_gain_ratio: 0.5 + mu_clip: 10 + coeff_ma_output_state: 0.0 + coeff_ma_setpoint: 0.0