diff --git a/tf/chunkparser.py b/tf/chunkparser.py index 981aed1e..53d552e7 100644 --- a/tf/chunkparser.py +++ b/tf/chunkparser.py @@ -131,6 +131,7 @@ def __init__(self, buffer_size=1, batch_size=256, value_focus_min=1, + value_focus_max=1, value_focus_slope=0, workers=None): """ @@ -168,6 +169,7 @@ def __init__(self, self.sample = sample # set the min and slope for value focus, defaults accept all positions self.value_focus_min = value_focus_min + self.value_focus_max = value_focus_max self.value_focus_slope = value_focus_slope # set the mini-batch size self.batch_size = batch_size @@ -443,7 +445,7 @@ def sample_record(self, chunkdata): # if orig_q is NaN, accept, else accept based on value focus if not np.isnan(orig_q): diff_q = abs(best_q - orig_q) - thresh_p = self.value_focus_min + self.value_focus_slope * diff_q + thresh_p = min(self.value_focus_max, self.value_focus_min + self.value_focus_slope * diff_q) if thresh_p < 1.0 and random.random() > thresh_p: continue diff --git a/tf/train.py b/tf/train.py index a3b7fcdb..8686f0c9 100644 --- a/tf/train.py +++ b/tf/train.py @@ -412,6 +412,7 @@ def main(cmd): ChunkParser.BATCH_SIZE = split_batch_size value_focus_min = cfg['training'].get('value_focus_min', 1) + value_focus_max = cfg['training'].get('value_focus_max', 1) value_focus_slope = cfg['training'].get('value_focus_slope', 0) root_dir = os.path.join(cfg['training']['path'], cfg['name']) @@ -422,7 +423,7 @@ def main(cmd): extractor = select_extractor(tfprocess.INPUT_MODE) if experimental_parser and (value_focus_min != 1 - or value_focus_slope != 0): + or value_focus_max != 1 or value_focus_slope != 0): raise ValueError( 'Experimental parser does not support non-default value \ focus parameters.') @@ -447,6 +448,7 @@ def read(x): sample=SKIP, batch_size=ChunkParser.BATCH_SIZE, value_focus_min=value_focus_min, + value_focus_max=value_focus_max, value_focus_slope=value_focus_slope, workers=train_workers) train_dataset = tf.data.Dataset.from_generator(