TensorFlow Extended Part 2 - Model Build - Analysis - and - Serving
TensorFlow Extended Part 2 - Model Build - Analysis - and - Serving
Generalist Generalist
Generalist
Specialist
Specialist
Specialist
Lesson Roadmap
● Overview of TFX: What problems it can help you solve ● TensorFlow Model Analysis Overview (40 mins)
(30 mins) a. What is it & why should you care?
a. What is TFX & Why Should You Care? b. TFMA API Overview
b. What can you leverage? TFX Ecosystem c. TFMA Usage
d. TFMA notebook demo
c. Which problems can TFX help you solve?
d. TFX Components
10 min Break
10 min Break
● TensorFlow Estimator Overview (35 mins)
a. What is TensorFlow & Why Should You Care?
● Tensorflow Serving (45 mins)
b. What is TF Estimator?
a. What is it & why should you care?
c. How to train a model using TF Estimator? b. TF Serving Intro
d. Dataset Overview c. TF Serving w/ Docker notebook demo
e. TF Estimator notebook demo i. CPU / GPU / TPU
d. TF Model Server REST API
10 min Break
TensorFlow Extended
Overview
TensorFlow Extended (TFX)
TFX is…
Tuner
Pipeline Storage
Training Data Build Model Save Model Load Model Serve Model Serving Data
3 4 6 7 8 11
Evaluate Model
All sessions in a day Current session
Large size Small size
High throughput Low latency
2 5 10
Input Data for
Prepare Data 1 Training
Serving Data 9 Prepare Data
TFX Pipeline
TF Data Validation TF Transform TF Estimator TF Model Analysis TF Serving
source
Architecture Overview
TFX pipelines can be orchestrated using Apache Airflow and Kubeflow Pipelines.
For this workshop, we will be running in interactive mode.
source
What is a TFX Component?
● TFX pipelines are a series of components
● Components are organized into DAGs
● Executor is where insert your work will be
● Driver feeds data to Executor
● Publisher writes to ml.metadata
source
What is a TFX Component?
As data flows through pipelines…
source
TFX Pipeline
TF Data Validation TF Transform TF Estimator TF Model Analysis TF Serving
source
TensorFlow
Model Build
Dataset
Bucket Features Dense Float Features Vocab Features Categorical Features
pickup_hour trip_distance
pickup_month passenger_count
pickup_day_of_week tip_amount
dropoff_month
dropoff_hour
dropoff_day_of_week
source
Tensorflow FeatureColumns Part 2
source
Tensorflow FeatureColumns Part 3
source
What is TF Estimator & Why Should You Care?
TF Estimator is a high level OOP API which makes it easier to train models
(see overview)
source
preprocessing_fn(...)
source
_build_estimator(...)
source
TF Model Build Knowledge Check
a) tf.feature_column.numeric_column()
b) tf.feature_column.categorical_column_with_vocabulary_list()
c) tf.feature_column.categorical_column_with_identity()
d) tf.feature_column.indicator_column()
e) All of the above
TensorFlow
Model Analysis
What is TF Model Analysis & Why Should You Care?
TF Model Analysis is a library for evaluating TF models.
Benefits include…
Results
Evaluator TFX Pipeline Component
Notes:
source
ModelValidator TFX Pipeline Component
Notes:
source
Pusher TFX Pipeline Component
Notes:
source
TensorFlow Model Analysis API
Feature Engineering @ Scale Transformations
a) True
b) False
TensorFlow
Serving
What is TF Serving & Why Should You Care?
Requirements of a Model Serving System...
1. Low latency
a. Isolation of load & serve threads
2. Efficient
a. Dynamic request batching
3. Scale Horizontally
4. Reliable & Robust
5. Support loading/hosting multiple model versions dynamically
a. Serve one model, while sending canary requests to new model
b. Built in A/B testing
6. Deployment roll forward / backward
7. Serves over 1,500 models @Google, 100 predictions/sec
POST http://host:port/<URI>:<VERB>
URI - /v1/models/${MODEL_NAME}[/versions/${MODEL_VERSION}]
VERBS - classify | regress | predict
Classify Format:
POST http://host:port/v1/models/${MODEL_NAME}[/versions/${MODEL_VERSION}]:classify
Classify Example:
POST http://host:port/v1/models/iris/versions/1:classify
Predict Format:
POST http://host:port/v1/models/${MODEL_NAME}[/versions/${MODEL_VERSION}]:predict
Predict Example:
POST http://host:port/v1/models/mnist/versions/1:predict
End-2-End example
Next Steps:
● Work through TFMA & TFServing Notebooks