Generative AI with Python and TensorFlow 2 - By Joseph Babcock , Raghav Bali Kubeflow: an end-to-end machine learning lab As was described at the beginning of this chapter, there are many components of an end-to-end lab for machine learning research and development (Table 2.1), such as: A way to manage and version library dependencies, such as TensorFlow, and package them for a reproducible computing environment Interactive research environments where we can visualize data and experiment with different settings
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
A systematic way to specify the steps of a pipeline – data processing, model tuning, evaluation, and deployment Provisioning of resources to run the modeling process in a distributed manner Robust mechanisms for snapshotting historical versions of the research process As we described earlier in this chapter, TensorFlow was designed to utilize distributed resources for training. To leverage this capability, we will use the Kubeflow projects. Built on top of Kubernetes, Kubeflow has several components that are useful in the end-to-end process of managing machine learning applications. Using Kubeflow Katib to optimize model hyperparameters Katib is a framework for running multiple instances of the same job with differing inputs, such as in neural architecture search (for determining the right number and size of layers in a neural network) and hyperparameter search (finding the right learning rate, for example, for an algorithm). Like the other Customize templates we have seen, the TensorFlow job specifies a generic TensorFlow job, with placeholders for the parameters: apiVersion: "kubeflow.org/v1alpha3" kind: Experiment metadata: namespace: kubeflow name: tfjob-example spec: parallelTrialCount: 3 maxTrialCount: 12 maxFailedTrialCount: 3 objective: type: maximize goal: 0.99 objectiveMetricName: accuracy_1 algorithm: algorithmName: random metricsCollectorSpec: source: fileSystemPath: path: /train kind: Directory collector: kind: TensorFlowEvent parameters: - name: --learning_rate parameterType: double feasibleSpace: min: "0.01" max: "0.05" - name: --batch_size parameterType: int feasibleSpace: min: "100" max: "200" trialTemplate: goTemplate: rawTemplate: |- apiVersion: "kubeflow.org/v1" kind: TFJob metadata: name: {{.Trial}} namespace: {{.NameSpace}} spec: tfReplicaSpecs: Worker: replicas: 1 restartPolicy: OnFailure template: spec: containers: - name: tensorflow image: gcr.io/kubeflow-ci/tf-mnist-with- summaries:1.0 imagePullPolicy: Always command: - "python" - "/var/tf_mnist/mnist_with_summaries.py" - "--log_dir=/train/metrics" {{- with .HyperParameters}} {{- range .}} - "{{.Name}}={{.Value}}" {{- end}} {{- end}} which we can run using the familiar kubectl syntax: kubectl apply -f https://raw.githubusercontent.com/kubeflow/katib/master/examples/v1alpha3/tfjob-example.yaml This content is from the book “Generative AI with Python and TensorFlow 2” by Joseph Babcock , Raghav Bali (April 2021). Start reading a free chapter or access the entire Packt digital library free for 7 days by signing up now. To learn more, click on the button below. |