Ejemplo n.º 1
0
                         output_units=1,
                         metrics=['accuracy'],
                         epochs=20))

# Add an evaluator
training_pipeline.add_evaluator(
    TFMAEvaluator(slices=[['has_diabetes']],
                  metrics={
                      transformed_label_name('has_diabetes'):
                      ['binary_crossentropy', 'binary_accuracy']
                  }))

# Add the deployer
training_pipeline.add_deployment(
    GCAIPDeployer(
        project_id=GCP_PROJECT,
        model_name=MODEL_NAME,
    ))

# Run the pipeline
training_pipeline.run()

# Another way to do is is to create a DeploymentPipeline.
# Uncomment to create the model via this pipeline
# from zenml.core.pipelines.deploy_pipeline import DeploymentPipeline
# model_uri = training_pipeline.get_model_uri()
# deploy_pipeline = DeploymentPipeline(model_uri=model_uri)
# deploy_pipeline.add_deployment(
#     GCAIPDeployer(
#         model_name=MODEL_NAME + '_v2',
#         project_id=GCP_PROJECT
Ejemplo n.º 2
0
training_pipeline.add_evaluator(
    TFMAEvaluator(
        slices=[['has_diabetes']],
        metrics={'has_diabetes': ['binary_crossentropy', 'binary_accuracy']}))

# Add cortex deployer
api_config = {
    "name": CORTEX_MODEL_NAME,
    "kind": "RealtimeAPI",
    "predictor": {
        "type": "tensorflow",
        # Set signature key of the model as we are using Tensorflow Trainer
        "models": {
            "signature_key": "serving_default"
        }
    }
}
training_pipeline.add_deployment(
    CortexDeployer(
        env=CORTEX_ENV,
        api_config=api_config,
        predictor=TensorFlowPredictor,
    ))

# Define the artifact store
artifact_store = ArtifactStore(
    os.path.join(GCP_BUCKET, 'cortex/artifact_store'))

# Run the pipeline
training_pipeline.run(artifact_store=artifact_store)