Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Model Building with TensorFlow

Model Building with TensorFlow

A talk that introduces usage of TensorFlow library via building a simple model for image recognition. This presentation was for the IWD extended event at the Women TechMakers Nairobi group.

Avatar for Rukayat

Rukayat

April 21, 2018
Tweet

More Decks by Rukayat

Other Decks in Programming

Transcript

  1. Whoami… • Software Engineer at Andela, InVisionApp. • Postgraduate Student

    at Georgia Institute of Technology specialising in Machine Learning. • Problem Solver. • Polyglot.
  2. Learning Objectives • Introducing TensorFlow • What makes TensorFlow better?

    • Applications of TensorFlow • Hands-on session with TensorFlow
  3. TensorFlow is… • an open source library developed by Google

    for numerical computation • a library that allows creation of large scale neural networks with multiple layers • mainly used for classification, perception, understanding, discovery and prediction problems.
  4. Why TensorFlow? • It uses data flow graphs, making it

    more efficient to compute all required operations at once. other libraries do single operations at a time. • It automatically calculates gradients needed to optimise graph variable for improved model performance.
  5. Why TensorFlow? (cont’d) • Runs faster by leveraging CPUs, GPUs

    and more recently special chips called TPUs - TensorFlow Processing Units
  6. Uses cases… • Classification Problems e.g image recognition • Voice/Sound

    Recognition e.g voice search, • Text Based Applications e.g sentimental analysis, threat detection • Time Series Analysis - trading predictions, recommenders systems Source: https://www.exastax.com/deep-learning/top-five-use-cases-of-tensorflow/
  7. Notebook Link: https://github.com/Hvass-Labs/TensorFlow- Tutorials/blob/master/01_Simple_Linear_Model.ipynb Hands-on session: Model Building Disclaimer: I

    do not claim ownership for the tutorial used in this presentation. The tutorial is originally written by Magnus Pedersen. I have chosen not to re-invent the wheel since a basic tutorial exists to teach TensorFlow
  8. A typical TF graph • Placeholder variables for graph inputs

    • Model variables: to be optimised for better model performance • Model: mathematical function calculating outputs based on inputs. • Cost measure: guides optimisation of variables • Optimisation method: changes the model variables
  9. Placeholder Variables • Input images - x, float • true

    labels - y_true, float • true class value - y_true_cls, int
  10. Model model = (x * weights ) + biases •

    Model Function • Normalized output of model using “softmax” function • Select index with highest class using “argmax” function
  11. Cost Measure • Measure how well model performs with “cross-entropy”.

    • Calculate value with function “softmax_cross_entropy_with_logits” • Values range from 0 to positive values • 0 ==> perfect match • positive number ==> no perfect classification • Optimise model by changing weights and biases to minimise cross-entropy
  12. Cost Measure (cont’d) • 0 ==> perfect match • positive

    number ==> imperfect classification with varying degree of inaccuracies • Optimise model by changing weights and biases to minimise cross-entropy
  13. Optimisation • Optimise with Gradient Descent to obtain minimal cross-entropy.

    • Use “GradientDescentOptimizer” function from TensorFlow library.
  14. Running TensorFlow • Create a session • Initialise all variables

    • Perform optimisation • Measure Performance session = tf.session()