septembra 19, 2019 —
Posted by Kevin Haas, Zhitao Li, and Robert Crowe on behalf of the TFX team
TensorFlow Extended (TFX) is a platform for creating production-ready ML pipelines. TFX was created by Google and provides the backbone of Google’s ML services and applications, and we’ve been open sourcing TFX for everyone who needs to create production ML pipelines.
TFX can be extended and customized in several ways, incl…
class Executor(base_executor.BaseExecutor):
"""Start a trainer job on Google Cloud AI Platform."""
def Do(self, input_dict,
output_dict,
exec_properties):
"""Starts a trainer job on Google Cloud AI Platform.
from tfx.extensions.google_cloud_ai_platform.trainer
import executor as ai_platform_trainer_executor
...
trainer = Trainer(
...,
custom_executor_spec = executor_spec.ExecutorClassSpec(
ai_platform_trainer_executor.Executor)
)
from tfx.types import artifact_utils
train_input_examples_uri = artifact_utils.get_split_uri(
input_dict['my_input_data'], 'train')
eval_input_examples_uri = artifact_utils.get_split_uri(
input_dict['my_input_data'], 'eval')
train_output_examples_uri = artifact_utils.get_split_uri(
output_dict['my_output_data'], 'train')
eval_output_examples_uri = artifact_utils.get_split_uri(
output_dict[‘my_output_data'], 'eval')
class MyComponentSpec(tfx.types.ComponentSpec):
PARAMETERS = {
<...>
}
INPUTS = {
'my_input_data':
ChannelParameter(type=standard_artifacts.Examples),
}
OUTPUTS = {
'my_output_data':
ChannelParameter(type=standard_artifacts.Examples),
}
output_data = tfx.types.Channel(
type=standard_artifacts.Examples,
artifacts=[
standard_artifacts.Examples(split=split)
for split in artifact.DEFAULT_EXAMPLE_SPLITS
])
spec = LabelingComponentSpec(
input_data=input_data,
my_output_data=output_data)
_ai_platform_training_args = {
'pythonModule': None, # Will be populated by TFX
'args': None, # Will be populated by TFX
'region': _gcp_region,
'jobDir': os.path.join(_output_bucket, 'tmp'),
'project': ‘your GCP project id’
}
...
trainer = Trainer(
...,
custom_config={'ai_platform_training_args':
_ai_platform_training_args})
}
# Configure Google Cloud AI Platform job
training_inputs = exec_properties.get('custom_config',
{}).pop('ai_platform_training_args')
executor_class_path = '%s.%s' %
(tfx_trainer_executor.Executor.__module__,
tfx_trainer_executor.Executor.__name__)
# Start Google Cloud AI Platform job
return runner.start_cmle_training(input_dict, output_dict,
exec_properties, executor_class_path, training_inputs)
septembra 19, 2019
—
Posted by Kevin Haas, Zhitao Li, and Robert Crowe on behalf of the TFX team
TensorFlow Extended (TFX) is a platform for creating production-ready ML pipelines. TFX was created by Google and provides the backbone of Google’s ML services and applications, and we’ve been open sourcing TFX for everyone who needs to create production ML pipelines.
TFX can be extended and customized in several ways, incl…