Building products with
ML & TensorFlow
@svonava, svonava@gmail.com, svonava.com
How is ML used today (MIT Tech Review*, 2016)
Already achieved
Objectives
*375 C-suite/VP/enterprise devs across USA, EU & India
How is ML used today (MIT Tech Review, 2016)
Primary driver for ML?
How is ML used today (MIT Tech Review, 2016)
% of 2017 budget dedicated to ML
Strategy & tactics
But first a bit of history!
“a machine which senses, recognizes, remembers, and responds like the human mind”
The New Yorker
But first a bit of history!
“a machine which senses, recognizes, remembers, and responds like the human mind”
The New Yorker, 1958
The 60ties
Rosenblatt
The 60ties
The 80ties
The 80ties
Feature engineering!
Back propagation!
Deep[er] learning
Deep learning (mNeuron)
Deep learning (mNeuron)
Convolution!
Remember late 2010 & mobile first?
Strategy & tactics
Strategy: Talent
Hire
Grow
Spread!
ML guidelines, internal training, open-sourcing
Strategy: Infrastructure
Pipelines (pre/post processing)
Efficient model training (ASIC)
Model serving
or deploy to mobile
Interactive analysis
Data acquisition
Storage
Pre-trained model APIs
Strategy: Infrastructure
Strategy: Frameworks
Static comp. graph�Tensorflow
Tooling, deployment, domain-specific abstractions ...
Dynamic comp. graph�PyTorch
Variable length data is padded by zeros etc.�→ Batching & efficiency
Forward comp. like numpy�→ Easier adoption
i = tf.constant(0)�c = lambda i: tf.less(i, 10)�b = lambda i: tf.add(i, 1)�r = tf.while_loop(c, b, [i])
for _ in range(T):� h = torch.matmul(W, h) + b
Strategy: Risk
What can go wrong?
Strategy: Risk
Strategy: Risk
→ Invest in human oversight, fallback solutions & PR/expectation management.
Strategy: Ethics
Disruption of worker & employer negotiation, hiding behind ‘neutral’ technology.
Simple
ML
→ No standard ethics code and no way to transparently enforce… but check AI Now.
Strategy: Ethics
60% of all jobs have 30% of tasks readily automatable (McKinsey).
Strategy & tactics
Personalization
Automation
Anticipation
Forecasting
Data processing
Anomaly detection
external
internal
Personalization
Automation
Anticipation
Forecasting
Data processing
Anomaly detection
external
internal
UX for window-shopper vs fire-and-forget.
Receipt input for expenses.
Reactive → Proactive (Search vs. Google Now)
Web traffic forecast for Ad selling.
Sentiment analysis on users to prioritize dev.
Fraud prevention.
Degrees of freedom:
Complexity of the model:
→ More data & simpler models.
→ The less independent the examples, the more of them you need.
→ Easy test: How much can you sample/downscale the examples → gives “useful bits”.
Before AI, go HI
Before AI, go HI
Before AI, go HI
body_def = {� 'title': 'Student cell phone ownership',� 'description': 'Ownership of cell.',� 'owners': owner_emails,� 'wantedResponseCount': 100,� 'audience': {� 'country': 'US',� },� 'questions': [� {� 'question': 'Do you own a cell phone?',� 'type': 'singleAnswer',� 'answers': ['Yes', 'No'],� }� ]�}�surveys_service.surveys().insert(body=body_def).execute()
Before AI, go HI
→ Near-real time (x minutes) with:
Alegion, StintMint, SquadRun (also possible with Amazon)
Getting labeled data for free?
Check out human-based computation games (wikipedia).
Scaling & latency beyond HI - pre-trained models!
Case study: Natural Language Processing (Wootric)
TensorFlow: Tensor-glove (Google Cloud) - low entry bar
Input: Couple 100s labeled points (3 classes) in 3D.
TensorFlow: Tensor-glove (Google Cloud)
Steps:
TensorFlow: Tensor-glove (Google Cloud)
Steps:
TensorFlow: Tensor-glove (Google Cloud)
# define the model�import tensorflow as tf�weights = tf.Variable(tf.zeros([3, 3]), dtype=tf.float32) # The model learns this�biases = tf.Variable(tf.zeros([3]), dtype=tf.float32) # and this.�glove_data = tf.placeholder(tf.float32) # Sensor data goes here e.g. [[5 .3 47]..]. �rps_data = tf.matmul(glove_data, weights) + biases # Encodes y=Wx+b.��# define the loss�rps_labels = tf.placeholder(tf.float32) # Labels for glove_data e.g. [[1 0 0]..].
loss = tf.losses.softmax_cross_entropy(onehot_labels=rps_labels, logits=rps_data)
Softmax - squish rps_data to [0, 1] with sum = 1 (probabilities)
Cross entropy - diff of the probabilities and the one-hot representation
TensorFlow: Tensor-glove (Google Cloud)
# define an optimizer�optimizer = tf.train.GradientDescentOptimizer(learning_rate=1).minimize(loss)�# create a Session�sess = tf.Session()�# init the variables�initializer = tf.global_variables_initializer()�sess.run(initializer)�# train the model�for i in range(10000):� # train the model� sess.run(optimizer, {glove_data: g_data, rps_labels: g_label})� # print current loss� if i % 1000 == 0:� l = sess.run(loss, {glove_data: g_data, rps_labels: g_label})
TensorFlow: Tensor-glove (Google Cloud)
What’s next?
Thank you!
Follow @svonava for more generative goodness coming soon!