# Introduction to TensorFlow

Machine Learning (ML) is the construction of algorithms and statistical models that can extract information hidden within a dataset. It has the ability to learn a model of a system and predict that systems behavior. A rigorous definition of a neural network may not be much good to us right now. At this point, it may just help to know the first known neural network was based on the human brain.

TensorFlow is an open-source neural network framework that makes it easy to build and deploy ML models across many different devices. You may be able to guess TensorFlow’s core data structure is the tensor. You may also say TensorFlow is a language for describing computations as stateful dataflow graphs. These graphs are constructed using tensors for the directed edges and operations for the nodes.

In order to install TensorFlow, you’ll need to have Python installed first. You can reference the following if you need some help getting TensorFlow installed:

https://www.tensorflow.org/install/pip#virtual-environment-install

I would strongly recommend installing TensorFlow in a virtual environment. You may notice part of setting up such a virtual environment is its activation. On Windows, for example, you’ll use a command like:

`.\venv\Scripts\activate`

Once that’s installed, if you’re comfortable with python you should be familiar with the concept of importing packages. One way of checking you have TensorFlow installed correctly is to try to install it while in interactive mode.

For example:

```
(venv) … $ python
…
>>> import tensorflow as tf
```

Well, don’t stop there. Let’s try to print the version:

```
>>> print(‘tensorflow version’,tf.__version__)
tensorflow version 2.2.0
```

Now add:

```
>>> print(tf.add(1,1))
tf.Tensor(2, shape=(), dtype=int32)
```

You good??? No vicious errors?? I’m impressed. You appear to be somewhat comfortable with TensorFlow, so I think we’re ready to talk about Keras, which is a high-level neural network built on top of TensorFlow. Among other things, it provides what we call the Layer and Model constructs.

**References**

- A LIGHTNING-FAST INTRODUCTION TO DEEP LEARNING AND TENSORFLOW 2.0. https://builtin.com/machine-learning/introduction-deep-learning-tensorflow-20. Last accessed: 6/11/2020.
- TFRT: A new TensorFlow runtime. https://blog.tensorflow.org/2020/04/tfrt-new-tensorflow-runtime.html. Last accessed: 6/11/2020.
- The Google’s 7 steps of Machine Learning in practice: a TensorFlow example for structured data. https://towardsdatascience.com/the-googles-7-steps-of-machine-learning-in-practice-a-tensorflow-example-for-structured-data-96ccbb707d77. Last accessed: 6/11/2020.
- Broughton, M., Verdon, G., McCourt, T., Martinez, A. J., Yoo, J. H., Isakov, S. V., … & Leib, M. (2020). Tensorflow quantum: A software framework for quantum machine learning.
*arXiv preprint arXiv:2003.02989*. Last accessed: 6/11/2020. - Announcing TensorFlow Quantum: An Open Source Library for Quantum Machine Learning. https://ai.googleblog.com/2020/03/announcing-tensorflow-quantum-open.html. Last accessed: 6/17/2020.