def __init__(self): # node names self.g_names = [] # optimizer self.g_optim = ConfEntryChoices({"yes": OptimConf(), "no": None}, "no") # lrate factor (by default 1.0) self.g_lrf = SVConf().direct_update(val=1., which_idx="eidx", mode="none", min_val=0.) # margin (by default 0.0) self.g_margin = SVConf().direct_update(val=0.)
def __init__(self): # reading and writing formats # self.R = ReaderGetterConf() from .run import MyDataReaderConf self.R = MyDataReaderConf() # reader + optional extra functionalities self.W = WriterGetterConf() # -- # data paths: train/dev can be multiple! self.train: List[str] = [] self.train_props: List[Dict] = [] # extra properties for R self.dev: List[str] = [] self.test = "" self.cache_data = True # turn off if large data self.cache_shuffle = True # shuffle cache if using cache self.dict_dir = "./" self.dict_frame_file = "" # read frame file for building types # ----- # for multi-source training (len(train)>1); note: currently three should be enough self.ms_stop_idx = 0 # with which to consider the end of an epoch self.ms_train_budget0 = SVConf().direct_update(val=1., which_idx="eidx", mode="none", min_val=0.) self.ms_train_budget1 = SVConf().direct_update(val=1., which_idx="eidx", mode="none", min_val=0.) self.ms_train_budget2 = SVConf().direct_update(val=1., which_idx="eidx", mode="none", min_val=0.) # ----- # save name for trainer not here!! self.model_load_name = "zmodel.best.m" # load name self.model_load_strict = True # strict loading? self.output = "zout.json" self.eval_conf = ConfEntryChoices( { 'frame': FrameEvalConf(), 'fn': MyFNEvalConf(), 'pb': MyPBEvalConf() }, 'frame') # pretrain self.pretrain_wv_file = "" self.pretrain_scale = 1.0 # (not used anymore) self.pretrain_init_nohit = 1.0 self.pretrain_hits_outf = "" # output a by-product of filtered embeddings # extra for testing self.test_extra_pretrain_wv_files = [] # thresholds for word self.word_rthres = 200000 # rank <= this self.word_fthres = 1 # freq >= this
def __init__(self): # save and load model self.model_save_prefix = "zmodel" self.model_save_suffix_curr = ".curr" self.model_save_suffix_best = ".best" self.train_preload_model = "" # preload model name before training? self.model_load_name = "zmodel.best.m" # (test time) load name # train self.accu_batch = 1 # how many fb count as one update self.min_uidx = 0 # min updated (before early stop) self.max_uidx = 1000 * 100 # max update # valid self.valid_ufreq = 1000 # do valid every this udix self.valid_first = False # valid once at the very start self.valid_start_uidx = 0 # do valid >=this # record best & save cidx self.record_best_start_cidx = 0 # starting from where to record best self.save_special_start_cidx = Constants.INT_PRAC_MAX # save special ones starting from what cidx self.save_special_cfreq = Constants.INT_PRAC_MAX # save (specific name model) every cidx # lrate schedule self.lrate = SVConf().direct_update(val=0.001, which_idx="uidx", mode="none", m=0.75, min_val=0.000001) self.lrate_warmup_uidx = 0 # linear increasing lrate as warmup for how many uidx self.lrate_decrease_alpha = 0. # as the one in Transformer, sth like -0.5 (after warmup, uidx**alpha)
def __init__(self): super().__init__() self.temperature = SVConf().direct_update(val=1., which_idx="eidx", mode="none", min_val=0.) self.cf_merge_mode = "Multinomial" # Multinomial/Geometric self.pred_argmax = True # select the argmax one! self.pred_mix_probs = False # weight probs rather than logprobs
def __init__(self): self.cl_starting_cidx = Constants.INT_PRAC_MAX # starting cl-mode when >= this! self.cl_update_each = False # whether update after each fb # -- self.cl_lo0 = SVConf().direct_update(val=1., which_idx="cidx", mode="linear", b=0., k=0., max_val=1., idx_scale=50) self.cl_lo1 = SVConf().direct_update(val=1., which_idx="cidx", mode="linear", b=0., k=0., max_val=1., idx_scale=50) self.cl_lo2 = SVConf().direct_update(val=1., which_idx="cidx", mode="linear", b=0., k=0., max_val=1., idx_scale=50) self.cl_lo3 = SVConf().direct_update(val=1., which_idx="cidx", mode="linear", b=0., k=0., max_val=1., idx_scale=50) self.cl_hi0 = SVConf().direct_update(val=1., which_idx="cidx", mode="linear", b=0., k=1., max_val=1., idx_scale=50) self.cl_hi1 = SVConf().direct_update(val=1., which_idx="cidx", mode="linear", b=0., k=1., max_val=1., idx_scale=50) self.cl_hi2 = SVConf().direct_update(val=1., which_idx="cidx", mode="linear", b=0., k=1., max_val=1., idx_scale=50) self.cl_hi3 = SVConf().direct_update(val=1., which_idx="cidx", mode="linear", b=0., k=1., max_val=1., idx_scale=50) self.cl_rank_idx = [] # by default, 0,1,2,...
def __init__(self): super().__init__() # -- self.temperature = SVConf().direct_update(val=1., which_idx="eidx", mode="none", min_val=0.) self.detach_weights = True # detach weights? self.max_cf = 0.999 # act like label-smoothing self.cf_trg_rel = False # if so, target at relative (exp(s-max(s))); otherwise, absolute gold prob as trg self.loss_cf = 0.5
def __init__(self): super().__init__() # -- self.loss_weights = [] self.pred_weights = [] # note: not used anymore!! self.pred_sel_idx = -1 # simply select one (by default the last) # schedule for weighting!! self.use_lw_num = 0 # make it brief! self.lw0 = SVConf().direct_update(val=1., which_idx="cidx", mode="none", b=0., k=0.02, max_val=1.) self.lw1 = SVConf().direct_update(val=1., which_idx="cidx", mode="none", b=0., k=0.02, max_val=1.) self.lw2 = SVConf().direct_update(val=1., which_idx="cidx", mode="none", b=0., k=0.02, max_val=1.) self.lw3 = SVConf().direct_update(val=1., which_idx="cidx", mode="none", b=0., k=0.02, max_val=1.) self.lw4 = SVConf().direct_update(val=1., which_idx="cidx", mode="none", b=0., k=0.02, max_val=1.)
def __init__(self): super().__init__() # overall conf (for non-component nodes) # optimizer self.main_optim = OptimConf() # lrate factor self.main_lrf = SVConf().direct_update(val=1., which_idx="eidx", mode="none", min_val=0., max_val=1.) # different groups (useful for different lrates) for ii in range(10): # this should be enough! setattr(self, f"mpg{ii}", NodeGroupConf()) # model-param-group # dropouts (general default settings) self.df_hdrop = 0.1 # hdrop self.df_gdrop = 0.33 # gdrop (always fixed for recurrent connections) self.df_idrop = 0.33 # idrop for rnn self.df_fix_drop = False # fix drop for one run for each dropout # ema self.ema_conf = EMAConf()
def __init__(self): # == # top/group-level info (used at outside, put here for convenience) self.group_name = "" self.group_files = [ ] # List: # -> "input_file" or Dict: sub_name -> "input_file" self.group_tasks = [] # tasks to perform! note: allow sub-name! self.group_info = {} # extra info? self.group_joint = False # join all these into one dataset? # train (train) self.group_sample_rate = SVConf().direct_update( val=1., which_idx="cidx", mode="none") # outside_sample by rate self.group_sample_alpha = 0. # inside_sample by len(inst)**alpha # eval (test/dev) self.group_eval_weight = 1. # weight for final eval # == # (static) io self.R = ReaderGetterConf() self.W = WriterGetterConf() # - paths (further we have default ones for "*_gold", "*_output" if not provided in extras) self.input_dir = "./" # if needed self.input_file = "" self.gold_file = "" # by default the same as input_file self.output_dir = "./" # if needed self.output_file = "" self.output_prefix = "_zout" # default output prefix, full will be "{this}.{wset}.json" # - special self.preprocessors = [] # need to slightly modify the data? # self.approx_prev_next = False # approx. setting of prev & next when loading, note: deprecated self.presample = 1.0 # (>1=N,<1=Rate) random sample how much at the very beginning, as pre-processing for convenience! self.presample_shuffle = False # whether shuffle in presample? self.presample_reverse = False # from back to start (for convenience) # == # runtime self.convert_conf = ZIConverterConf() self.batch_conf = ZIBatcherConf()