TensorFlow
|
TensorFlow is an open source offering from Google Brain Team.
Specifically, TensorFlow is a system that processes a dataFLOW graph, where the data that gets passed in and out of each node ("op") in the graph is a TENSOR (typed multi-dim array). Stated another way, it is a dataflow processor where ALL data is in the form of 'tensors' - in other words, tensors flow in and out of ops/nodes that form a (dataflow) graph.
Tensors are simply n-dimensional collections of numbers: a 0-tensor (0D tensor) is simply a scalar, a 1-tensor is a vector (row or column), a 2-tensor is a matrix, a 3-tensor is a cuboid (stack of matrices), etc.
Schematically, every op (node) in a tensorflow graph looks like this:
From Google's doc: "TensorFlow uses a dataflow graph to represent your computation in terms of the dependencies between individual operations. This leads to a low-level programming model in which you first define the dataflow graph, then create a TensorFlow session to run parts of the graph across a set of local and remote devices."
Because CNNs involve pipelined neuron processing, where each neuron (a node in TF) processes arrays of inputs and weights (tensors in TF).
TF makes it possible to express neural networks as graphs (flexible), as opposed to a collection of chained function calls (rigid). The flexibility also allows the nodes to be processed in a variety of ways - in a CPU, GPU, 'TPU', cloud, laptop, mobile device, other hardware...
You can download TF from GitHub via your native Python environment (eg. using pip install), and use it in that environment.
Or you can use Docker! Very simply, Docker is a lightweight alternative to running a VM such as VirtualBox or VMWare. Docker allows for easy downloading and installing of software inside it, using git-style pull requests. For our purposes, we'll need to install Python first, then pull in tensorflow.
Install Docker Toolbox first:
Next, launch a Docker shell (Docker Quickstart Terminal):
Next, verify that Docker is running properly [note - this screenshot is off a different PC compared to above!]:
Now we can run Hello World :)
Time to install Python, followed by tensorflow:
Excellent! Now we can start playing with TensorFlow by visiting localhost:8888 (or http://192.168.99.100:8888) on our browser, and running "literate computing-style" Jupyter notebooks there.
You can even run Jupyter notebooks on the cloud (note - you can't edit using this interface). Eg. here is a pre-loaded example (GitHub can run this, too).
Here is an example where we add two "tensors" (arrays of identical length/size) to obtain a resulting "tensor".
Here we chain additions:
numpy is a popular, capable module that we use with TF.
This is how to multiply two matrices [like we'd do in a CNN!].
This short and sweet example shows we can iteratively solve for m and c for a y=mx+c line equation, given pairs of (x,y) data :)
You can use the above as a starting point for more regression experiments - multiple-linear, non-linear..
As you can imagine, we barely scratched the surface! Here are starting points for more exploring:
Also, Magenta (see this page, this one) is an experiment to get NNs to GENERATE art (including music)..
Needless to say, 'TF' (now in v2) is enormously popular.