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


Python papermill.execute_notebook方法代码示例

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


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

示例1: test_text_classification_unified_information

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_text_classification_unified_information(notebooks, tmp):
    notebook_path = notebooks["tc_unified_information"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        kernel_name=KERNEL_NAME,
        parameters=dict(
            DATA_FOLDER=tmp,
            BERT_CACHE_DIR=tmp,
            BATCH_SIZE=32,
            BATCH_SIZE_PRED=512,
            NUM_EPOCHS=1,
            TEST=True,
            QUICK_RUN=True,
        ),
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict
    assert pytest.approx(result["accuracy"], 0.93, abs=ABS_TOL)
    assert pytest.approx(result["precision"], 0.93, abs=ABS_TOL)
    assert pytest.approx(result["recall"], 0.93, abs=ABS_TOL)
    assert pytest.approx(result["f1"], 0.93, abs=ABS_TOL) 
开发者ID:interpretml,项目名称:interpret-text,代码行数:23,代码来源:test_notebook_unified_information_explainer.py

示例2: test_text_classification_introspective_rationale

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_text_classification_introspective_rationale(notebooks, tmp):
    notebook_path = notebooks["tc_introspective_rationale"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        kernel_name=KERNEL_NAME,
        parameters=dict(
            DATA_FOLDER=tmp,
            CUDA=torch.cuda.is_available(),
            QUICK_RUN=False,
            MODEL_SAVE_DIR=tmp
        ),
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict
    print(result)
    assert pytest.approx(result["accuracy"], 0.72, abs=ABS_TOL)
    assert pytest.approx(result["anti_accuracy"], 0.69, abs=ABS_TOL)
    assert pytest.approx(result["sparsity"], 0.17, abs=ABS_TOL) 
开发者ID:interpretml,项目名称:interpret-text,代码行数:20,代码来源:test_notebook_introspective_rationale_explainer.py

示例3: test_notebooks_basic_translations_diff

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_notebooks_basic_translations_diff(
    isolated_filesystem, translated_notebook
):  # pragma: no cover
    """
    Test Notebooks in the tutorial translations folder if they have been
    modified in the current pull request. This test should not consider any
    notebooks locally. It should be used on Github Actions.
    """
    notebook = "/".join(translated_notebook.split("/")[-2:])
    notebook = f"translations/{notebook}"
    list_name = Path(f"examples/tutorials/{notebook}")
    tested_notebooks.append(str(list_name))
    res = pm.execute_notebook(
        notebook,
        "/dev/null",
        parameters={"epochs": 1, "n_test_batches": 5, "n_train_items": 64, "n_test_items": 64},
        timeout=300,
    )
    assert isinstance(res, nbformat.notebooknode.NotebookNode) 
开发者ID:OpenMined,项目名称:PySyft,代码行数:21,代码来源:test_notebooks.py

示例4: test_fl_sms

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_fl_sms(isolated_filesystem):  # pragma: no cover
    sys.path.append("advanced/federated_sms_spam_prediction/")
    import preprocess

    os.chdir("advanced/federated_sms_spam_prediction/")

    notebook = "Federated SMS Spam prediction.ipynb"
    p_name = Path("examples/tutorials/advanced/federated_sms_spam_prediction/")
    tested_notebooks.append(str(p_name / notebook))
    Path("data").mkdir(parents=True, exist_ok=True)
    url = "https://archive.ics.uci.edu/ml/machine-learning-databases/00228/smsspamcollection.zip"
    urllib.request.urlretrieve(url, "data.zip")
    with ZipFile("data.zip", "r") as zipObj:
        # Extract all the contents of the zip file in current directory
        zipObj.extractall()
    preprocess.main()
    res = pm.execute_notebook(notebook, "/dev/null", parameters={"epochs": 1}, timeout=300)
    assert isinstance(res, nbformat.notebooknode.NotebookNode) 
开发者ID:OpenMined,项目名称:PySyft,代码行数:20,代码来源:test_notebooks.py

示例5: assay_one_notebook

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def assay_one_notebook(notebook_name, test_values):
    """Test a single notebook.

    This uses nbformat to append `nteract-scrapbook` commands to the
    specified notebook. The content of the commands and their expected
    values are stored in the `test_values` dictionary. The keys of this
    dictionary are strings to be used as scrapbook keys. They corresponding
    value is a `ScrapSpec` tuple. The `code` member of this tuple is
    the code (as a string) to be run to generate the scrapbook value. The
    `expected` member is a Python object which is checked for equality with
    the scrapbook value

    Makes certain assumptions about directory layout.
    """
    input_notebook = "notebooks/" + notebook_name + ".ipynb"
    processed_notebook = "./test/notebooks/" + notebook_name + ".processed.ipynb"
    output_notebook = "./test/notebooks/" + notebook_name + ".output.ipynb"

    append_scrapbook_commands(input_notebook, processed_notebook, test_values)
    pm.execute_notebook(processed_notebook, output_notebook)
    nb = sb.read_notebook(output_notebook)

    for k, v in test_values.items():
        assert nb.scraps[k].data == v.expected 
开发者ID:fairlearn,项目名称:fairlearn,代码行数:26,代码来源:test_notebooks.py

示例6: test_no_raise

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_no_raise(self):

        nbs = self.list_notebooks()

        here = os.path.dirname(__file__)
        out_dir = "{}/out".format(here)
        if not os.path.exists(out_dir):
            os.mkdir(out_dir)

        for nb_input in nbs:
            basename = os.path.basename(nb_input)

            nb_output = "{}/{}".format(out_dir, basename)

            try:
                pm.execute_notebook(nb_input, nb_output)
            except Exception as e:
                with open(nb_output) as f:
                    print(f.read())

                raise e

        self.assertEqual(1, 1) 
开发者ID:NII-cloud-operation,项目名称:sshkernel,代码行数:25,代码来源:test_sshd_integration.py

示例7: test_unilm_abstractive_summarization

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_unilm_abstractive_summarization(notebooks, tmp):
    notebook_path = notebooks["unilm_abstractive_summarization"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        kernel_name=KERNEL_NAME,
        parameters=dict(
            QUICK_RUN=True,
            NUM_GPUS=torch.cuda.device_count(),
            TOP_N=100,
            WARMUP_STEPS=5,
            MAX_STEPS=50,
            GRADIENT_ACCUMULATION_STEPS=1,
            TEST_PER_GPU_BATCH_SIZE=2,
            BEAM_SIZE=3,
            MODEL_DIR=tmp,
            RESULT_DIR=tmp,
        ),
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict
    assert pytest.approx(result["rouge_1_f_score"], 0.2, abs=ABS_TOL)
    assert pytest.approx(result["rouge_2_f_score"], 0.07, abs=ABS_TOL)
    assert pytest.approx(result["rouge_l_f_score"], 0.16, abs=ABS_TOL) 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:25,代码来源:test_notebooks_unilm_abstractive_summarization.py

示例8: test_entailment_multinli_bert

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_entailment_multinli_bert(notebooks, tmp):
    notebook_path = notebooks["entailment_multinli_transformers"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        parameters={
            "MODEL_NAME": "bert-base-uncased",
            "TO_LOWER": True,
            "TRAIN_DATA_USED_FRACTION": 0.05,
            "DEV_DATA_USED_FRACTION": 0.05,
            "NUM_EPOCHS": 1,
            "CACHE_DIR": tmp
        },
        kernel_name=KERNEL_NAME,
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict
    assert pytest.approx(result["matched_precision"], 0.76, abs=ABS_TOL)
    assert pytest.approx(result["matched_recall"], 0.76, abs=ABS_TOL)
    assert pytest.approx(result["matched_f1"], 0.76, abs=ABS_TOL)
    assert pytest.approx(result["mismatched_precision"], 0.76, abs=ABS_TOL)
    assert pytest.approx(result["mismatched_recall"], 0.76, abs=ABS_TOL)
    assert pytest.approx(result["mismatched_f1"], 0.76, abs=ABS_TOL) 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:24,代码来源:test_notebooks_entailment.py

示例9: test_entailment_xnli_bert_azureml

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_entailment_xnli_bert_azureml(
    notebooks, subscription_id, resource_group, workspace_name, workspace_region, cluster_name
):
    notebook_path = notebooks["entailment_xnli_bert_azureml"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        parameters={
            "DATA_PERCENT_USED": 0.0025,
            "subscription_id": subscription_id,
            "resource_group": resource_group,
            "workspace_name": workspace_name,
            "workspace_region": workspace_region,
            "cluster_name": cluster_name,
        },
        kernel_name=KERNEL_NAME,
    )

    with open("outputs/results.json", "r") as handle:
        result_dict = json.load(handle)
        assert result_dict["weighted avg"]["f1-score"] == pytest.approx(0.2, abs=ABS_TOL)

    if os.path.exists("outputs"):
        shutil.rmtree("outputs") 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:26,代码来源:test_notebooks_entailment.py

示例10: test_minilm_abstractive_summarization

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_minilm_abstractive_summarization(notebooks, tmp):
    notebook_path = notebooks["minilm_abstractive_summarization"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        kernel_name=KERNEL_NAME,
        parameters=dict(
            QUICK_RUN=True,
            NUM_GPUS=torch.cuda.device_count(),
            TOP_N=100,
            WARMUP_STEPS=5,
            MAX_STEPS=50,
            GRADIENT_ACCUMULATION_STEPS=1,
            TEST_PER_GPU_BATCH_SIZE=2,
            BEAM_SIZE=3,
            CLEANUP_RESULTS=True,
        ),
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict
    assert pytest.approx(result["rouge_1_f_score"], 0.2, abs=ABS_TOL)
    assert pytest.approx(result["rouge_2_f_score"], 0.07, abs=ABS_TOL)
    assert pytest.approx(result["rouge_l_f_score"], 0.16, abs=ABS_TOL) 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:24,代码来源:test_notebooks_minilm_abstractive_summarization.py

示例11: test_question_answering_squad_transformers

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_question_answering_squad_transformers(notebooks, tmp):
    notebook_path = notebooks["question_answering_squad_transformers"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        parameters={
            "TRAIN_DATA_USED_PERCENT": 0.15,
            "DEV_DATA_USED_PERCENT": 0.15,
            "NUM_EPOCHS": 1,
            "MAX_SEQ_LENGTH": 384,
            "DOC_STRIDE": 128,
            "PER_GPU_BATCH_SIZE": 4,
            "MODEL_NAME": "distilbert-base-uncased",
            "DO_LOWER_CASE": True,
            "CACHE_DIR": tmp
        },
        kernel_name=KERNEL_NAME,
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict
    assert pytest.approx(result["exact"], 0.55, abs=ABS_TOL)
    assert pytest.approx(result["f1"], 0.70, abs=ABS_TOL) 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:23,代码来源:test_notebooks_question_answering.py

示例12: test_bidaf_deep_dive

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_bidaf_deep_dive(
    notebooks, subscription_id, resource_group, workspace_name, workspace_region
):
    notebook_path = notebooks["bidaf_deep_dive"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        parameters={
            "NUM_EPOCHS": 1,
            "config_path": None,
            "PROJECT_FOLDER": "examples/question_answering/bidaf-question-answering",
            "SQUAD_FOLDER": "examples/question_answering/squad",
            "LOGS_FOLDER": "examples/question_answering/",
            "BIDAF_CONFIG_PATH": "examples/question_answering/",
            "subscription_id": subscription_id,
            "resource_group": resource_group,
            "workspace_name": workspace_name,
            "workspace_region": workspace_region,
        },
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict["validation_EM"]
    assert result == pytest.approx(0.5, abs=ABS_TOL) 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:24,代码来源:test_notebooks_question_answering.py

示例13: test_bidaf_quickstart

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_bidaf_quickstart(
    notebooks, subscription_id, resource_group, workspace_name, workspace_region
):
    notebook_path = notebooks["bidaf_quickstart"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        parameters={
            "config_path": None,
            "subscription_id": subscription_id,
            "resource_group": resource_group,
            "workspace_name": workspace_name,
            "workspace_region": workspace_region,
            "webservice_name": "aci-test-service",
        },
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict["answer"]
    assert result == "Bi-Directional Attention Flow" 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:20,代码来源:test_notebooks_question_answering.py

示例14: test_extractive_summarization_cnndm_transformers

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_extractive_summarization_cnndm_transformers(notebooks, tmp):
    notebook_path = notebooks["extractive_summarization_cnndm_transformer"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        kernel_name=KERNEL_NAME,
        parameters=dict(
            QUICK_RUN=True,
            TOP_N=100,
            CHUNK_SIZE=200,
            USE_PREPROCESSED_DATA=False,
            DATA_PATH=tmp,
            CACHE_DIR=tmp,
            BATCH_SIZE=3000,
            REPORT_EVERY=50,
            MAX_STEPS=100,
            WARMUP_STEPS=5e2,
            MODEL_NAME="distilbert-base-uncased",
        ),
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict
    assert pytest.approx(result["rouge_2_f_score"], 0.1, abs=ABS_TOL) 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:24,代码来源:test_notebooks_extractive_summarization.py

示例15: test_abstractive_summarization_bertsumabs_cnndm

# 需要导入模块: import papermill [as 别名]
# 或者: from papermill import execute_notebook [as 别名]
def test_abstractive_summarization_bertsumabs_cnndm(notebooks, tmp):
    notebook_path = notebooks["abstractive_summarization_bertsumabs_cnndm"]
    pm.execute_notebook(
        notebook_path,
        OUTPUT_NOTEBOOK,
        kernel_name=KERNEL_NAME,
        parameters=dict(
            QUICK_RUN=True,
            TOP_N=1000,
            MAX_POS=512,
            DATA_FOLDER=tmp,
            CACHE_DIR=tmp,
            BATCH_SIZE_PER_GPU=3,
            REPORT_EVERY=50,
            MAX_STEPS=100,
            MODEL_NAME="bert-base-uncased",
        ),
    )
    result = sb.read_notebook(OUTPUT_NOTEBOOK).scraps.data_dict
    assert pytest.approx(result["rouge_2_f_score"], 0.01, abs=ABS_TOL) 
开发者ID:microsoft,项目名称:nlp-recipes,代码行数:22,代码来源:test_notebooks_abstractive_summarization_bertsumabs.py


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