Getting Started With TensorFlow
Ever wondered why it is called TensorFlow?
As the name suggests, TensorFlow defines how tensors will flow through the system. But what are these tensors that we are discussing?
When we represent data for machine learning, it generally needs to be done numerically. Tensor is a data repository, especially when referring to neural network data representation.
In simple words, it is an artificial intelligence library, which builds models using data flow graphs.
It is widely used for
- Understanding
- Classification
- Discovering
- Perception
- Creation
- Prediction
TensorFlow works with Python as it’s base language. But that doesn’t make it a limitation, as it also runs on C++, Java, R and many more programming languages.
Let’s move to installation, We’ll be installing TensorFlow for Windows 10 CPU. If you want to install TensorFlow for Windows 10 GPU, Mac OSX CPU, Ubuntu etc. then you can do it manually from here.
Installing TensorFlow
- Firstly, Download Conda. We’ll be Installing MiniConda which is a minimal version of Anaconda.
Make sure you choose the latest version available to download.
- Now, let’s install MiniConda.
- Select both of the given options and click on ‘install’.
- Once Miniconda is installed, Let’s prepare our .yml script for Conda.
- After clicking here, save the file as text document. (to the directory of your machine where you can find and access it easily. Suggested to save it in user directory.)
- Now, open the Command Prompt of your windows and change to the directory which has the .yml script that you saved earlier and rename yml.txt file to .yml file.
ren tensorflow.yml.text tensorflow.yml
- Now, let’s install Jupyter through Conda.
conda install jupyter
- It will take some time to install [if prompt type ‘y’]
- After Jupyter is installed, we are going to run the installation scrip that we downloaded earlier, to create an environment.
dir *.yml
conda env create -v -f tensorflow.yml
- This will take some time.
- Now, our environment is ready and we can start using TensorFlow.
- To activate TensorFlow, run the following command.
conda activate tensorflow
Similarly, to deactivate TensorFlow, run ‘conda deactivate’.
- It moves you to the TensorFlow environment.
Output: (tensorflow) C:\Users\Jeff>
- Now, Let’s go into Python environment of TensorFlow
python
- Let’s check if our TensorFlow is still working.
import tensorflow as tf
This will take a moment.
print(tf.__version__)
- If you’re getting an output like this:
2.0.0
Your TensorFlow is working.
- Now, lets install the Kernel for Jupyter. (This is an important step. Make sure you don’t skip it)
python -m ipykernel install --user --name tensorflow --display-name "Python 3.7 (tensorflow)"
[if you are getting error in this step, then let us know in the comment section.]
- This registers our environment into Jupyter Kernel, so that we can use TensorFlow in Jupyter. If you skip this step, your Jupyter will not know that you created a kernel like this.
- Now lets open Jupyter Notebook to check if our Kernel is installed.
jupyter notebook
This will open the Jupyter Notebook. Now, click on ‘New’ on the top-right corner.
- As you can see, Jupyter now has the Kernel we just created.
- Click on ‘Python 3.7 (tensorflow)’ and it’s ready to get started.
To import it we run the below command:
import tensorflow as tf
Resourses provided by TensorFlow
- TensorFlow-Hub: You’ll be able to access various pre-trained models and datasets built by professional.
- ML Tools: Tools like CoLab, TensorBoard, ML Perf, XLA and many more are easily accessible and provided by TensorFlow.
- Libraries and Extensions: Magenta, Nucleus, Sonnet, Unicode and many more libraries are available.
- Inbuilt Functions: Such as tf.audio, tf.io, tf.keras, tf.test, tf.train, etc. makes it easy to build a machine learning model.
TensorFlow is a rich system that provides all the bits and pieces for Machine learning.
Leave a Reply