官术网_书友最值得收藏!

Keras installation and configuration

At this point, the environment is ready for Keras installation. If all the dependencies and the backend engine have been correctly installed, we can proceed. Actually, the work that remains to be done is very simple and immediate.

There are two ways to install Keras as follows:

The first step involves the use of the Python Package Index (PyPI).

This is a repository of software for the Python programming language. PyPI helps you find and install software developed and shared by the Python community. This is the recommended option.

After installing the PyPI package, simply type the following command:

$ sudo pip install keras

If you are using a virtualenv, you may want to avoid using sudo:

$ pip install keras

Alternatively, we can install Keras from the GitHub source. To do this, we first need to clone Keras using git:

$ git clone https://github.com/keras-team/keras.git

Then, add cd to the keras folder and run the install command:

cd keras
sudo python setup.py install

We have the Keras environment available to implement our deep learning models. Let us look at some more information about the configuration. As we have already mentioned, Keras uses TensorFlow as the default backend. If we want to use the other two options, Theano and CNTK, we must modify the Keras configuration file. This is a file with the .json extension, and is named keras.json.

The file's position depends on the operating system that is in use in our PC:

$ HOME/.keras/keras.json

We can use the following command for Unix-like OSes:

%USERPROFILE%/.Keras/keras.json

And, for Windows OS, the contents of the configuration file are of the following type:

{
"image_data_format": "channels_last",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"
}

The parameters have the following meaning:

  • image_data_format: String, either channels_last or channels_first. It specifies which data format convention Keras will follow.
  • epsilon: Float, a numeric fuzzing constant used to avoid dividing by zero in some operations.
  • floatx: String, float16, float32, or float64. Default float precision.
  • backend: String, tensorflow, theano, or cntk.

Switching from one backend to another is very fast. Simply change the field backend to theano, tensorflow, or cntk, and Keras will use the new configuration the next time you run any Keras code.

主站蜘蛛池模板: 凭祥市| 巧家县| 都兰县| 根河市| 理塘县| 汽车| 来宾市| 报价| 诸暨市| 湖南省| 昂仁县| 抚远县| 丰都县| 乌兰察布市| 隆昌县| 行唐县| 涟水县| 灵璧县| 成都市| 和平县| 永善县| 自贡市| 怀集县| 雅安市| 双峰县| 兴仁县| 巩留县| 元江| 嘉峪关市| 平利县| 布拖县| 金乡县| 南澳县| 池州市| 都兰县| 花垣县| 靖宇县| 塔河县| 玛多县| 安国市| 丽水市|