当前位置: 首页>>代码示例>>Python>>正文


Python config.load方法代码示例

本文整理汇总了Python中rasa_nlu.config.load方法的典型用法代码示例。如果您正苦于以下问题:Python config.load方法的具体用法?Python config.load怎么用?Python config.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rasa_nlu.config的用法示例。


在下文中一共展示了config.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: train_model

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def train_model():
    # trains a model and times it
    t = time()
    # training_data = load_data('demo_train.md')
    training_data = load_data("data/company_train_lookup.json")
    td_load_time = time() - t
    trainer = Trainer(config.load("config.yaml"))
    t = time()
    trainer.train(training_data)
    train_time = time() - t
    clear_model_dir()
    t = time()
    model_directory = trainer.persist(
        "./tmp/models"
    )  # Returns the directory the model is stored in
    persist_time = time() - t
    return td_load_time, train_time, persist_time 
开发者ID:RasaHQ,项目名称:rasa_lookup_demo,代码行数:19,代码来源:time_train_test.py

示例2: print_stats

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def print_stats(
    count,
    num_words_list,
    num_words,
    lookup_construct_time,
    td_load_time,
    train_time,
    persist_time,
    eval_time,
    total_time,
):

    print("{0:.2f} % done".format((count + 1) / len(num_words_list) * 100))
    print("with {} words in lookup table:".format(num_words))
    print("    took {} sec. to construct lookup table".format(lookup_construct_time))
    print("    took {} sec. to load training data".format(td_load_time))
    print("    took {} sec. to train model".format(train_time))
    print("    took {} sec. to perist model".format(persist_time))
    print("    took {} sec. to evaluate on test set".format(eval_time))
    print("    took {} sec. total".format(total_time)) 
开发者ID:RasaHQ,项目名称:rasa_lookup_demo,代码行数:22,代码来源:time_train_test.py

示例3: train_models

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def train_models(component_builder, data):
    # Retrain different multitenancy models
    def train(cfg_name, project_name):
        from rasa_nlu import training_data

        cfg = config.load(cfg_name)
        trainer = Trainer(cfg, component_builder)
        training_data = training_data.load_data(data)

        trainer.train(training_data)
        trainer.persist("test_projects", project_name=project_name)

    train("sample_configs/config_pretrained_embeddings_spacy.yml",
          "test_project_spacy")
    train("sample_configs/config_pretrained_embeddings_mitie.yml",
          "test_project_mitie")
    train("sample_configs/config_pretrained_embeddings_mitie_2.yml",
          "test_project_mitie_2") 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:20,代码来源:test_multitenancy.py

示例4: zipped_nlu_model

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def zipped_nlu_model():
    spacy_config_path = "sample_configs/config_pretrained_embeddings_spacy.yml"

    cfg = config.load(spacy_config_path)
    trainer = Trainer(cfg)
    td = training_data.load_data(DEFAULT_DATA_PATH)

    trainer.train(td)
    trainer.persist("test_models",
                    project_name="test_model_pretrained_embeddings")

    model_dir_list = os.listdir(TEST_MODEL_PATH)

    # directory name of latest model
    model_dir = sorted(model_dir_list)[-1]

    # path of that directory
    model_path = os.path.join(TEST_MODEL_PATH, model_dir)

    zip_path = zip_folder(model_path)

    return zip_path 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:24,代码来源:conftest.py

示例5: train_models

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def train_models(component_builder, data):
    # Retrain different multitenancy models
    def train(cfg_name, project_name):
        from rasa_nlu.train import create_persistor
        from rasa_nlu import training_data

        cfg = config.load(cfg_name)
        trainer = Trainer(cfg, component_builder)
        training_data = training_data.load_data(data)

        trainer.train(training_data)
        trainer.persist("test_projects", project_name=project_name)

    train("sample_configs/config_spacy.yml", "test_project_spacy_sklearn")
    train("sample_configs/config_mitie.yml", "test_project_mitie")
    train("sample_configs/config_mitie_sklearn.yml", "test_project_mitie_sklearn") 
开发者ID:crownpku,项目名称:Rasa_NLU_Chi,代码行数:18,代码来源:test_multitenancy.py

示例6: test_run_cv_evaluation

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def test_run_cv_evaluation():
    td = training_data.load_data('data/examples/rasa/demo-rasa.json')
    nlu_config = config.load("sample_configs/config_spacy.yml")

    n_folds = 2
    results, entity_results = run_cv_evaluation(td, n_folds, nlu_config)

    assert len(results.train["Accuracy"]) == n_folds
    assert len(results.train["Precision"]) == n_folds
    assert len(results.train["F1-score"]) == n_folds
    assert len(results.test["Accuracy"]) == n_folds
    assert len(results.test["Precision"]) == n_folds
    assert len(results.test["F1-score"]) == n_folds
    assert len(entity_results.train['ner_crf']["Accuracy"]) == n_folds
    assert len(entity_results.train['ner_crf']["Precision"]) == n_folds
    assert len(entity_results.train['ner_crf']["F1-score"]) == n_folds
    assert len(entity_results.test['ner_crf']["Accuracy"]) == n_folds
    assert len(entity_results.test['ner_crf']["Precision"]) == n_folds
    assert len(entity_results.test['ner_crf']["F1-score"]) == n_folds 
开发者ID:crownpku,项目名称:Rasa_NLU_Chi,代码行数:21,代码来源:test_evaluation.py

示例7: train_nlu

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def train_nlu():
    from rasa_nlu.training_data import load_data
    from rasa_nlu import config
    from rasa_nlu.model import Trainer

    training_data = load_data('data/nlu.md')
    trainer = Trainer(config.load("config.yml"))
    trainer.train(training_data)
    model_directory = trainer.persist('models/nlu/',
                                      fixed_model_name="current")

    return model_directory 
开发者ID:RasaHQ,项目名称:rasa_core,代码行数:14,代码来源:bot.py

示例8: _load_default_config

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def _load_default_config(path):
        if path:
            return config.load(path).as_dict()
        else:
            return {} 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:7,代码来源:server.py

示例9: test_run_cv_evaluation

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def test_run_cv_evaluation():
    td = training_data.load_data('data/examples/rasa/demo-rasa.json')
    nlu_config = config.load(
        "sample_configs/config_pretrained_embeddings_spacy.yml")

    n_folds = 2
    results, entity_results = cross_validate(td, n_folds, nlu_config)

    assert len(results.train["Accuracy"]) == n_folds
    assert len(results.train["Precision"]) == n_folds
    assert len(results.train["F1-score"]) == n_folds
    assert len(results.test["Accuracy"]) == n_folds
    assert len(results.test["Precision"]) == n_folds
    assert len(results.test["F1-score"]) == n_folds
    assert len(entity_results.train[
        'CRFEntityExtractor']["Accuracy"]) == n_folds
    assert len(entity_results.train[
        'CRFEntityExtractor']["Precision"]) == n_folds
    assert len(entity_results.train[
        'CRFEntityExtractor']["F1-score"]) == n_folds
    assert len(entity_results.test[
        'CRFEntityExtractor']["Accuracy"]) == n_folds
    assert len(entity_results.test[
        'CRFEntityExtractor']["Precision"]) == n_folds
    assert len(entity_results.test[
        'CRFEntityExtractor']["F1-score"]) == n_folds 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:28,代码来源:test_evaluation.py

示例10: test_blank_config

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def test_blank_config():
    file_config = {}
    f = write_file_config(file_config)
    final_config = config.load(f.name)
    assert final_config.as_dict() == defaults 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:7,代码来源:test_config.py

示例11: test_invalid_config_json

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def test_invalid_config_json():
    file_config = """pipeline: [spacy_sklearn"""  # invalid yaml
    with tempfile.NamedTemporaryFile("w+",
                                     suffix="_tmp_config_file.json") as f:
        f.write(file_config)
        f.flush()
        with pytest.raises(config.InvalidConfigError):
            config.load(f.name) 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:10,代码来源:test_config.py

示例12: test_invalid_pipeline_template

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def test_invalid_pipeline_template():
    args = {"pipeline": "my_made_up_name"}
    f = write_file_config(args)
    with pytest.raises(config.InvalidConfigError) as execinfo:
        config.load(f.name)
    assert "unknown pipeline template" in str(execinfo.value) 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:8,代码来源:test_config.py

示例13: test_set_attr_on_component

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def test_set_attr_on_component(default_config):
    cfg = config.load("sample_configs/config_pretrained_embeddings_spacy.yml")
    cfg.set_component_attr(6, C=324)

    assert cfg.for_component(1) == {"name": "SpacyTokenizer"}
    assert cfg.for_component(6) == {"name": "SklearnIntentClassifier",
                                    "C": 324} 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:9,代码来源:test_config.py

示例14: test_override_defaults_supervised_embeddings_pipeline

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def test_override_defaults_supervised_embeddings_pipeline():
    cfg = config.load("data/test/config_embedding_test.yml")
    builder = ComponentBuilder()

    component1_cfg = cfg.for_component(0)

    component1 = builder.create_component(component1_cfg, cfg)
    assert component1.max_ngram == 3

    component2_cfg = cfg.for_component(1)
    component2 = builder.create_component(component2_cfg, cfg)
    assert component2.epochs == 10 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:14,代码来源:test_config.py

示例15: default_config

# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import load [as 别名]
def default_config():
    return config.load(CONFIG_DEFAULTS_PATH) 
开发者ID:weizhenzhao,项目名称:rasa_nlu,代码行数:4,代码来源:conftest.py


注:本文中的rasa_nlu.config.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。