TensorFlow Theory
TensorFlow
An open source machine learning library
TensorFlow Graphs
Graphs are sets of connected nodes.
Node is an operation with possible input that can supply some output.
There are two main types of tensor objects in a Graph:
-
Variables: Hold the values of weights and biases. Always need to be initialize.
-
Placeholders: Initially empty and are used to feed in the actual training examples.
Here is the simple graph of wx+b=z:
Here is the code of simple neural network created using tensorflow:
n_features = 10
n_dense_neurons = 3
x = tf.placeholder(tf.float32,(None,n_features))
b = tf.Variable(tf.zeros([n_dense_neurons]))
W = tf.Variable(tf.random_normal([n_features,n_dense_neurons]))
xW = tf.matmul(x,W)
z = tf.add(xW,b)
a = tf.sigmoid(z)
init = tf.global_variables_initializer()
with tf.Session() as sess:
`sess.run(init)`
`layer_out = sess.run(a,feed_dict={x : np.random.random([1,n_features])})`
print(layer_out)
Tensor — A multi-dimensional matrix
Dense Tensor — A tensor whose values will typically be in a continuous range
Feature columns — Given a set of input data, we need to map categorical features or string features to numerical values of some sort (real values or multi-dimensional tensors). This first level is called the feature columns.
Feature crosses — A combination of two features, which is useful when the relationship between two features is important.
Popular Architectures - Linear Classifier, DNN Classifier, RNN Classifier