當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。