python类load_config()的实例源码

poet.py 文件源码 项目:reddit-iambic-pentameter 作者: pmichel31415 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, config_file):
        """Constructor"""
        # Load options
        util.load_config(self, config_file)
        # Set up the collection of verses
        self.verses = load_verses(self.general.output_file)
        self.n_verses = len(self.verses)
        # Store the verses by rhyme
        self.rhymes = defaultdict(lambda: set())
        for i, verse in enumerate(self.verses):
            self.rhymes[poetry.verse_rhyme(verse)].add(i)
        # Total number of rhymes
        self.n_rhymes = len(self.rhymes)
        for k, v in self.rhymes.items():
            self.rhymes[k] = list(v)
        # Probability of picking a rhyme
        # This probability is proportional to the number of verses for each rhyme.
        # In particular, for rhymes with only one verse, the probability is set to 0
        self.p_rhymes = {r: (len(v) - 1) for r, v in self.rhymes.items()}
        self.names_rhymes, self.p_rhymes = zip(*self.p_rhymes.items())
        self.p_rhymes = np.asarray(self.p_rhymes, dtype=float)
        self.p_rhymes /= self.p_rhymes.sum()
        # Title generator
        self.tg = title.get_title_generator(self.title)
score.py 文件源码 项目:DL4MT 作者: thompsonb 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def main(models, source_file, nbest_file, saveto, b=80,
         normalize=False, verbose=False, alignweights=False):

    # load model model_options
    options = []
    for model in models:
        options.append(load_config(model))

        fill_options(options[-1])

    rescore_model(source_file, nbest_file, saveto, models, options, b, normalize, verbose, alignweights)
rescore.py 文件源码 项目:DL4MT 作者: thompsonb 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def main(models, source_file, nbest_file, saveto, b=80,
         normalize=False, verbose=False, alignweights=False):

    # load model model_options
    options = []
    for model in models:
        options.append(load_config(model))

        fill_options(options[-1])

    rescore_model(source_file, nbest_file, saveto, models, options, b, normalize, verbose, alignweights)
rip.py 文件源码 项目:reddit-iambic-pentameter 作者: pmichel31415 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, config_file):
        """Init from yaml"""
        self.config_file = config_file
        # Load from yaml config file
        util.load_config(self, config_file)
        # Initialize other relevant variables
        self.n_pentameters = 0
        self.n_length_removed = 0
        self.n_pentameters_epoch = 0
        self.last_tweet = 0
        self.last_quatrain_tweet = 0
        self.start = time.time()
        # Initialize reddit
        self.init_reddit()
score.py 文件源码 项目:nematus 作者: EdinburghNLP 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def main(source_file, target_file, output_file, scorer_settings):
    # load model model_options
    options = []
    for model in scorer_settings.models:
        options.append(load_config(model))
        fill_options(options[-1])
    rescore_model(source_file, target_file, output_file, scorer_settings, options)
translate.py 文件源码 项目:nematus 作者: EdinburghNLP 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _load_model_options(self):
        """
        Loads config options for each model.
        """
        options = []
        for model in self._models:
            m = load_config(model)
            if not 'concatenate_lm_decoder' in m:
                m['concatenate_lm_decoder'] = False
            options.append(m)
            # backward compatibility
            fill_options(options[-1])

        self._options = options
rescore.py 文件源码 项目:nematus 作者: EdinburghNLP 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def main(source_file, nbest_file, output_file, rescorer_settings):
    # load model model_options
    options = []
    for model in rescorer_settings.models:
        options.append(load_config(model))
        fill_options(options[-1])
    rescore_model(source_file, nbest_file, output_file, rescorer_settings, options)
train.py 文件源码 项目:Style-Transfer-In-Tensorflow 作者: JiangQH 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def main(args):
    paser = argparse.ArgumentParser()
    paser.add_argument('-c', '--conf', help='path to the config file')
    args = paser.parse_args()
    Config = load_config(args.conf)
    solve(Config)


问题


面经


文章

微信
公众号

扫码关注公众号