Saturday, October 7, 2017

Anconda Basics (Tensorflow keras installation in Windows)

Data science is one of the biggest buzz word in tech arena. "Tensorflow" is getting lots of interest and lots of people talking about it. This is simple stepping stone for your data science world exploration. 

First download the Anaconda 
https://www.anaconda.com/download/

select what ever the platform you like to get your hands dirty. 

open Anaconda prompt  as Administrator.


By default there is only one environment is created. "root". Anaconda allows us to create multiple environments with different python or R versions. That is one of the reasons Anaconda is being popular. 

put following command to create a new environment 

conda create -n testing python=3.5



This will install bunch of packages and python as we specified. When I am writing this Tensorflor has some problems with python 3.6 so better to install 3.5. after installation you will get some help about how to activate and deactivate environments. 


There are two ways of installing packages in Anaconda. first method is using command prompt and other one is Anaconda Navigator. 

Open Anaconda Navigator as administrator.


hit refresh button to see whether our newly created environment is created or not. 


select our newly created environment and click Environments in left hand side panel. 




Then you can see all the installed packages in that environment. select "All" from the drop down and search whatever the package that you want to install. 

Installing Tensorflow 

search Tensorflow in the search box. In this particular case Tensorflow have that green check box. That means that, Tensorflow is already installed in the environment. 













 search Tensorflow package and click Tensorflow. This will be indicated by little down side arrow.


click apply button at the bottom of the window. this will install all the required things for Tensorflow.

Testing Tensorflow

In Anaconda there are many editor options. "Spider" is one of the main editors in Anaconda. press install and then you can launch "Spider" by Anaconda.


type following command to test Tensorflow


import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

if you get the print statement. You are successfully install Tensorflow.  


Install Keras

Since we did Tensorflow installation in Anaconda Navigator, lets install Keras using command prompt. 

first run the Anaconda prompt as administrator and activate the environment. Otherwise it will installed in root environment. 


activate testing
 conda install mingw libpython


 conda install theano

 conda install --channel https://conda.anaconda.org/conda-forge keras

if you didn't get any errors you are good to go. 
open the spider editor and issue following command.


import tensorflow as tf
from keras import backend
print(backend._BACKEND)
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))


or you can use command prompt to test keras. 


python -c "from keras import backend; print(backend._BACKEND)"


Done ;) enjoy 

No comments:

Post a Comment