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

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.

主站蜘蛛池模板: 泰州市| 和静县| 横山县| 五寨县| 英超| 潼关县| 泾阳县| 海口市| 新巴尔虎右旗| 比如县| 济阳县| 南丰县| 蒙自县| 高平市| 娄底市| 偏关县| 太康县| 彭水| 吕梁市| 金门县| 江津市| 大英县| 防城港市| 淮滨县| 哈尔滨市| 社旗县| 于都县| 华池县| 甘肃省| 福贡县| 临沧市| 南丹县| 衡山县| 将乐县| 建平县| 江都市| 白水县| 涟水县| 桐庐县| 西城区| 弥渡县|