This site uses cookies to analyze traffic and improve service.
By using this site, you agree to this use. See details.
Deep Learning From Scratch  Theory and Implementation
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
It is now time to say goodbye to our cuddly TensorSlow library and start to get professional by switching to the actual TensorFlow.
As we've learned already, TensorFlow conceptually works exactly the same as our implementation. So why not just stick to our own implementation? There are a couple of reasons:

TensorFlow is the product of years of effort in providing efficient implementations for all the algorithms relevant to our purposes. Fortunately, there are experts at Google whose everyday job is to optimize these implementations. We do not need to know all of these details. We only have to know what the algorithms do conceptually (which we do now) and how to call them.

TensorFlow allows us to train our neural networks on the GPU (graphical processing unit), resulting in an enormous speedup through massive parallelization.

Google is now building Tensor processing units, which are integrated circuits specifically built to run and train TensorFlow graphs, resulting in yet more enormous speedup.

TensorFlow comes preequipped with a lot of neural network architectures that would be cumbersome to build on our own.

TensorFlow comes with a highlevel API called Keras that allows us to build neural network architectures way easier than by defining the computational graph by hand, as we did up until now. We will learn more about Keras in a later lesson.
So let's get started. Installing TensorFlow is very easy.
pip install tensorflow
If we want GPU acceleration, we have to install the package tensorflowgpu
:
pip install tensorflowgpu
In our code, we import it as follows:
import tensorflow as tf
Since the syntax we are used to from the previous sections mimics the TensorFlow syntax, we already know how to use TensorFlow. We only have to make the following changes:
 Add
tf.
to the front of all our function calls and classes  Call
session.run(tf.global_variables_initializer())
after building the graph
The rest is exactly the same. Let's recreate the multilayer perceptron from the previous section using TensorFlow: