Deep Learning Development Environment Construction
Deep Learning Development Environment Construction
Internal ComCom Wiki RPP Wiki Internal Event Wiki Robotics Tips Wiki Tsukuba Challenge Wiki
present location / / study group / Deep Learning Study Group / Deep Learning development environment construction
[[ study:deeplearning:install ]]
Please note that the following assumptions are made when building the environment.
- Using Roboken's PC
- Runs only in CPU mode
pyenv
This is a tool that allows you to easily switch which Python to use.
The following is how to build an environment on ubuntu. You can also do this on a Mac, but you can find a lot of information about the Mac version by
googling it.
Type the following command to install pyenv and set environment variables.
Now, when you type pyenv on the terminal, pyenv will start.
$pyenv
pyenv 1.0.10
Usage: pyenv <command> [<args>]
Some useful pyenv commands are:
commands List all available pyenv commands
local Set or show the local application-specific Python version
global Set or show the global Python version
shell Set or show the shell-specific Python version
install Install a Python version using python-build
uninstall a specific Python version
rehash Rehash pyenv shims (run this after installing executables)
version Show the current Python version and its origin
versions List all Python versions available to pyenv
which Display the full path to an executable
whence List all Python versions that contain the given executable
See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme
By the way, the following version will display a list of the python versions installed on your PC.
$ pyenv versions
The version marked with an asterisk (*) in the displayed list is the currently selected version.
Anaconda
Anaconda is an excellent tool that not only builds a Python environment but also downloads commonly used modules.
Although it covers most of the tools we might need, such as the matrix calculation library numpy, the scientific calculation (optimization calculation,
etc.) library scipy, the graph drawing library matplotlib, the machine learning library scikit-learn, etc. It is no exaggeration.
Type the following command. Then, the latest Anaconda (Python3 series) version will appear.
https://www.roboken.iit.tsukuba.ac.jp/internal/event-wiki/study/deeplearning/install 1/3
11/8/23, 11:17 AM Deep Learning development environment construction [Internal Event Wiki]
anaconda3-2.0.0
anaconda3-2.0.1
anaconda3-2.1.0
anaconda3-2.2.0
anaconda3-2.3.0
anaconda3-2.4.0
anaconda3-2.4.1
anaconda3-2.5.0
anaconda3-4.0.0
anaconda3-4.1.0
anaconda3-4.1.1
anaconda3-4.2.0
anaconda3-4.3.0
anaconda3-4.3.1
This is output on a Mac, so the version may be different. For now, download the latest version. Answer yes to all yes/no questions.
If this does not work, please contact UMA. I only vaguely remember, so I may have forgotten something.
Maybe the terminal disappears for some reason. Please try starting it again without worrying.
$ python --version
If you type and the Python version and Anaconda version are displayed, it is working without any problems. By the way, if you want to return to the
original Python environment,
$ source deactivate
By the way, if your Python version is 3.5.x, you can proceed to the next installation of opencv, but as of April 2017, opencv3 cannot be installed with
Python3.6.x. As I remember, if you have 3.6.x installed, you must install 3.5 series. in this case,
By typing, you can enter the 3.5 environment that you have created.
Next, install opencv3 to call OpenCV from python. Installing opencv is also easy. Answer yes to all yes/no questions.
Now you can enter freely. Let's check it first. Enter the following command to enter the interactive environment.
$python
>> import cv2
>> import numpy
>> import scipy
>> import matplotlib
If you try importing a well-known module and don't get scolded, there is no problem. If you get scolded, it's a little weird, so please talk to me. (I don't
think I've done anything bad)
The installation should be successful with the above command on your Roboken PC.
The operation was confirmed using the code below. (However, the environment is Ubuntu14)
http://www.roboken.iit.tsukuba.ac.jp/internal/event-wiki/study/deeplearning/sample_code (http://www.roboken.iit.tsukuba.ac.jp/internal/event-
wiki/study/deeplearning/sample_code)
$python
>> import tensorflow
>> import keras
>> from keras import backend
(Output:) using Theano backend
Initially Theano should be selected as the backend. Theano is a deep learning tool created by the University of Montreal, and tensorflow is a tool
created by Google. Keras serves as an interface to make these tools easier to use. Keras is also called a wrapper library. As the name suggests, it
wraps Theano and tensorflow.
https://www.roboken.iit.tsukuba.ac.jp/internal/event-wiki/study/deeplearning/install 2/3
11/8/23, 11:17 AM Deep Learning development environment construction [Internal Event Wiki]
This time I would like to select tensorflow as the backend. This is because Google created it and actually uses it, so its quality is guaranteed.
$ vim $HOME/.keras/keras.json
Use the above command to slightly rewrite the keras configuration file. There should be no problem if you change it as follows.
{
"image_dim_ordering": "tf",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"
}
image_dim_ordering specifies how the data is represented. This is a source of trouble, and many people still suffer from this difference in settings.
When set to “tf”, it is interpreted that the image dataset is treated as (number of data, image height, image width, number of image channels).
Setting "th" means that the image dataset is treated as (number of data, number of image channels, image height, image width).
If you actually set it to "th" but run a program that assumes "tf", keras will throw an error. This takes up a lot of your valuable time. It was stolen.
Everyone please be careful.
By setting the backend to “tensorflow”, you are expressing your intention to use tensorflow.
$python
>> from keras import backend
(Output:) using Tensorflow backend
The settings are now complete. All you have to do now is write a suitable learning program in python and run it.
References
pyenv and Anaconda installation on ubuntu16.04
http://blog.algolab.jp/post/2016/08/21/pyenv-anaconda-ubuntu/ (http://blog.algolab.jp/post/2016/08/21/pyenv-anaconda-ubuntu/)
Unless otherwise stated, content on this Wiki is subject to the following license:
CC Attribution-Share Alike 4.0 International
https://www.roboken.iit.tsukuba.ac.jp/internal/event-wiki/study/deeplearning/install 3/3