TensorFlow API is built by google and mainly deals with neural network but support other APIs as well such as scikit lear to one liner ML models.
It is library which hold all high level ML algorithm for ex.
TF Logging - It has four logging options,DEBUG,INFO ,WARNING, ERROR. tf.logging.set_verbosity(tf.logging.ERROR)
Tensors : One number, vector, matrix etc are are form of tensor. Increase in dimension results are stored in tensors. How would you store 10 matrix. You will think array of matrix, and that variable is called tensor.
Tensor flow formally gives two packages, one to deal with Graph and another to run computation on graph (sessions).
Computational Graph - Graph is same old neural network graph each node in graph has some purpose(variable,computation,placeholder), input and output. It’s a data strucutre well defined in TF.
Advantage of using graph- portability (Export and share), Easy to understand, parallelism,
Following are the component of Computational Graph. Variable, Placeholders, contants, operation, graph, session.
Compared to numpy array they don’t allocate memory in starting. For ex. a = tf.zeros(int(le12),int(le12)) will just form a shape not the actual allocation of memory. It will only allocate memory when it is executed.
How the Graph component looks in Code.
Here is very nice explanation from one of the blog. https://medium.com/@d3lm/understand-tensorflow-by-mimicking-its-api-from-scratch-faa55787170d
Important Function used in Andrews NG Course.
- tf.nn.conv2d(X,W, strides = [1,s,s,1], padding = ‘SAME’) – convolution layer
- tf.nn.max_pool(A, ksize = [1,f,f,1], strides = [1,s,s,1], padding = ‘SAME’) - max pool layer
- tf.nn.relu(Z) - element wise relu
- tf.contrib.layers.flatten(P) – flattens the multidimensional into desire dimension
- tf.contrib.layers.fully_connected(F, num_outputs) – Create fully connected layer from F to num_outputs
- tf.nn.softmax_cross_entropy_with_logits(logits = Z, labels = Y) –Calculate cost.
- tf.reduce_mean – Calculate mean of all example cost.
- Valid vs same pad, same brings add extra padding in case if needed, valid doesn’t consider edge to apply filter. (https://stackoverflow.com/questions/37674306/what-is-the-difference-between-same-and-valid-padding-in-tf-nn-max-pool-of-t)