How to Set Up a Python Environment for Deep Learning
Part 1 of 5:
Setting up Anaconda
- Download Anaconda. Anaconda is a scientific environment designed for Python. It is free and easy to use.
- Visit the Anaconda homepage. On the menu, click 'Anaconda' and then select 'Download' from the drop-down list. This will take you to the download page. Select Python 3.5 and choose the 'Graphic Installer'
- The Anaconda Python package should now be downloaded to your workstation
- Make sure you have administrative rights. Before we start this step, you would need to have sufficient administrative rights to install software on your system. Once confirmed, you can proceed.
- Install Anaconda. Double-click the downloaded file. This should launch the installation wizard. Simply follow the step by step instructions per the wizard. It should be a fairly simple and straightforward process. The installation process should take all of 10 minutes a little over 1 GB space on your hard drive.
- Finish the setup. Here will confirm if your Anaconda Python environment is the up to date version. The Anaconda software comes with a complete suite of graphical tools known as Anaconda Navigator. You can launch Anaconda Navigator via the application launcher. To know more about Anaconda Navigator, you can visit the detailed documentation here. For now, we suggest beginning with the command line for the Anaconda environment known as the conda.
Part 2 of 5:
Set up Conda
- Make sure Conda is already installed. Conda is a simple, fast and efficient. Error messages can be easily spotted and you can easily confirm if your working environment is installed and working as intended.
- Open a terminal or a command line window. To confirm if conda is installed correctly, type
conda -V // You should see something similar to this conda 4.2.9
- To confirm if Python is installed correctly, you can type
python -V
- You should the below line or something similar
Python 3.5.2:: Anaconda 4.2.0 (x86_64)
- Open a terminal or a command line window. To confirm if conda is installed correctly, type
- Update it to the latest version. You may have to install some additional packages to confirm the updates.To confirm that your conda environment is the latest version available, type-
conda update conda conda update anaconda
Part 3 of 5:
Verify SciPy Environment is working
- Setup SciPy. It is now time to confirm your SciPy environment. The following script prints the version number of the key SciPy libraries required for optimum Machine Learning development. Some basic libraries include – SciPy, Matplotlib, NumPy, Pandas, Scikit-learn and StatsModels.
- Write a Python Script. You can either choose to type 'python' followed by the commands directly. Or you can use a text editor and paste the script below into your editor. We recommend the second option.
# scipy import scipy print('scipy: %s' % scipy.__version__) # numpy import numpy print('numpy: %s' % numpy.__version__) # matplotlib import matplotlib print('matplotlib: %s' % matplotlib.__version__) # pandas import pandas print('pandas: %s' % pandas.__version__) # statsmodels import statsmodels print('statsmodels: %s' % statsmodels.__version__) # scikit-learn import sklearn print('sklearn: %s' % sklearn.__version__)
- Run the Python script. Save the script with the file name 'versions.py'. Back on the command line, you can change your directory to the path where you saved the script file. You can then type –
python versions.py # The output should look like this scipy: 0.18.1 numpy: 1.11.1 matplotlib: 1.5.3 pandas: 0.18.1 statsmodels: 0.6.1 sklearn: 0.17.1
Part 4 of 5:
Update scikit-learn Library
- Understand what scikit-learn is for. Scikit-learn is the most popular machine library in Python that you can't avoid. Here, we will go the steps to be followed to update the library.
- Update scikit-learn to incorporate the latest available version. A specific library can be updated by way of the conda command line. Below is an example on how to update scikit-learn to the latest version available. Once in the terminal, type -
conda update scikit-learn
- You also have the option of updating a specific library only using –
conda install -c anaconda scikit-learn=0.18.1
- You also have the option of updating a specific library only using –
- Confirm that the installation was successful. To confirm if the installation was successfully completed and scikit-learn was updated, you can re-run the versions.py script –
python versions.py # You should see the following output – scipy: 0.18.1 numpy: 1.11.3 matplotlib: 1.5.3 pandas: 0.18.1 statsmodels: 0.6.1 sklearn: 0.18.1
Part 5 of 5:
Install Deep Learning Libraries
- Understand your stack requirements. Here, we attempt to install Python libraries that are used for deep learning. Particularly, TensorFlow, Theano and Keras. In this article, we recommend using Keras for deep learning initiatives.[1]It is important to note that Keras requires only either Theano or TensorFlow installed in the system.[2] Both are no longer needed. Also, some window machines may face problems installing TensorFlow.
- Install Theano. You can install the Theano deep learning library using –
conda install theano
- If you choose to use the TensorFlow deep learning library, you can use the following command (all except Windows) –
conda install -c conda-forge tensorflow
- You can have the choice of completing the installation using pip and a particular version of tensorflow for your platform. To know more, visit installation instructions for tensorflow.
- If you choose to use the TensorFlow deep learning library, you can use the following command (all except Windows) –
- Install Keras. You can install Keras via the command –
pip install keras
- Add additional tools to your stack. You can add additional tools to your deep learning stack for code tracking, automation, and auto-documentation. You can integrate deep learning SDKs and monitoring tools to make it easier for your team.
- Make sure you've installed the right version. Once completed, it is a good idea to confirm that your environment for deep learning is properly installed and working as intended.
- For this you need to create a script which prints the version numbers for each of the libraries, similar to the exercise for the SciPy environment we completed earlier.
# theano import theano print('theano: %s' % theano.__version__) # tensorflow import tensorflow print('tensorflow: %s' % tensorflow.__version__) # keras import keras print('keras: %s' % keras.__version__)
- You can save the script as a file named 'deep_versions.py' and then run the script using
- python deep_versions.py # You should see the following output - theano: 0.8.2.dev-901275534cbfe3fbbe290ce85d1abf8bb9a5b203 tensorflow: 0.12.1 Using TensorFlow backend. keras: 1.2.1
- For this you need to create a script which prints the version numbers for each of the libraries, similar to the exercise for the SciPy environment we completed earlier.
- Start learning Python. That's it. You can now start building models or get started with developing models using your favorite deep-learning stack. Python & deep learning can be intimidating when you're just getting started, but start with simpler models and then start building more complex ones. You can find tons of useful resources on GitHub.[3]
3.6 ★ | 5 Vote
You should read it
- South American monsters - Spawn anaconda or spawn?
- Scary nape with the largest mouse hunting screen in the world of the giant 'beast' Anaconda
- Shivered, grappling with the giant South American python underwater
- Google officially launches TensorBoard.dev and TensorFlow Enterprise
- How to install TensorFlow in Linux and Raspberry Pi
- Google launched TensorFlow Lite 1.0 for mobile devices and embedded devices
- How big was the biggest snake ever recorded?
- More than 100 Python exercises have solutions (sample code)
May be interested
- Multiple choice quiz about Python - Part 5if you are interested in learning about the python programming language, the following quiz of network administrator will provide useful knowledge for your learning.
- MIT AI model can capture the relationship between objects with the minimum amount of training datadeep learning systems work by selecting statistical patterns in data - that's how they interpret their own worldview. however, this method of statistical learning requires a large amount of input data ...
- How to use Closure in Pythonin this article, tipsmake.com will work with you to learn about closure in python, how to define a closure and why you should use it. let's go find the answer!
- Nvidia launches Deep Learning Super Sampling 2.0, an advanced platform for rendering AI-based graphicsnvidia recently launched the deep learning super sampling 2.0 (dlss) 2.0, ai technology that promises to bring incredible graphics processing power to the new generation gpus, enhancing connectivity. export graphics based on ai.
- The next () function in Pythonthe next () function in python returns the next element in the iterator. you can add a default value to return if iterable is already the last element.
- The oct () function in Pythonthe oct () function is one of python's built-in functions, which is used to convert an integer to the corresponding octal.
- Decorator in Pythondecorator is used a lot in python. so how to create a decorator and why you should use it. let's go find the answer!
- The function id () in Pythonthe built-in function id () in python returns a single integer value that identifies an object.
- What you need to know about Shallow and Deep Copy in Pythonsometimes you'll want to copy an object completely, but other times you'll want to use it as a reference. at this time, you need shallow and deep copy when programming in python.
- 11 tips for learning Python for 'newbie'we believe that the first step in learning any programming language is to ensure that you understand how to learn because this is arguably the most important skill related to computer programming.