"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

December 14, 2018

Day # - 163 - Faster ML Development with TensorFlow

Key Summary
  • ML Models represented as Data Structure or Program
  • Data Structure - Graph (Deferred Execution - Define and Run)
  • Model - Program - Python Code (Eager Execution - Define by Run)
  • Tensorflow is both Data Structure and Model
  • Has both CPU and GPU Support
  • Model is Data Structure - Easy to Serialize and De-Serialize it and Deploy on Devices (Mobile, TPU, XLA)
  • Because model is data structure it is not tied down to language
  • Distributed Training to train on large amount of data
  • Model Structures - Convolution, AvgPool, MaxPool, Concat, Dropout, FullyConnected, Softmax
Model Structures - Static Vs Dynamic
  • Traditional RNN vs Dynamic Models
  • Model whose structure cannot be easily defined by graph
  • Straightforward with Eager using Native Python control flow

#Example 1 - Symolic
import tensorflow as tf
x = tf.constant(10.0)
w = tf.constant(4.0)
b = tf.constant(2.0)
y = tf.multiply(x,w)
print(y)
z = tf.add(y,b)
#you need to create session to perform actual computation
sess = tf.Session()
print(sess.run(z))
#Model as Data Structure
#During Session Computes and returns result
#Example 2 - Eager
#Restart your Spyder kernel to try this setting
import tensorflow as tf
import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()
x = tf.constant(10.0)
w = tf.constant(4.0)
b = tf.constant(2.0)
y = tf.multiply(x,w)
print(y)
z = tf.add(y,b)
print(z)
#Example 3 - Debugging
import tensorflow as tf
from tensorflow.python import debug as tfdebug
x = tf.constant(10.0)
w = tf.constant(4.0)
b = tf.constant(2.0)
y = tf.multiply(x,w)
print(y)
z = tf.add(y,b)
#you need to create session to perform actual computation
sess = tf.Session()
sess = tfdebug.LocalCLIDebugWrapperSession(sess)
sess.run(tf.global_variables_initializer())
sess.run(y)
view raw tf.py hosted with ❤ by GitHub

Happy Mastering DL!!!

No comments: