- 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
- Traditional RNN vs Dynamic Models
- Model whose structure cannot be easily defined by graph
- Straightforward with Eager using Native Python control flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) | |
Happy Mastering DL!!!
No comments:
Post a Comment