Keras-后端配置 (Keras - Backend Configuration)
This chapter explains Keras backend implementations TensorFlow and Theano in detail. Let us go through each implementation one by one.
本章详细说明Keras后端实现TensorFlow和Theano。 让我们逐一介绍每个实现。
TensorFlow (TensorFlow)
TensorFlow is an open source machine learning library used for numerical computational tasks developed by Google. Keras is a high level API built on top of TensorFlow or Theano. We know already how to install TensorFlow using pip.
TensorFlow是一个开源的机器学习库,用于Google开发的数值计算任务。 Keras是建立在TensorFlow或Theano之上的高级API。 我们已经知道如何使用pip安装TensorFlow。
If it is not installed, you can install using the below command −
如果尚未安装,则可以使用以下命令进行安装-
pip install TensorFlow
Once we execute keras, we could see the configuration file is located at your home directory inside and go to .keras/keras.json.
执行keras后,我们可以看到配置文件位于您的主目录中,并转到.keras / keras.json。
keras.json (keras.json)
{
"image_data_format": "channels_last",
"epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"
}
Here,
这里,
image_data_format represent the data format.
image_data_format表示数据格式。
epsilon represents numeric constant. It is used to avoid DivideByZero error.
epsilon表示数值常数。 用于避免DivideByZero错误。
floatx represent the default data type float32. You can also change it to float16 or float64 using set_floatx() method.
float x表示默认数据类型float32 。 您也可以使用set_floatx()方法将其更改为float16或float64 。
image_data_format represent the data format.
image_data_format表示数据格式。
Suppose, if the file is not created then move to the location and create using the below steps −
假设,如果未创建文件,则移动到该位置并使用以下步骤创建-
> cd home
> mkdir .keras
> vi keras.json
Remember, you should specify .keras as its folder name and add the above configuration inside keras.json file. We can perform some pre-defined operations to know backend functions.
请记住,您应该指定.keras作为其文件夹名称,并将上述配置添加到keras.json文件中。 我们可以执行一些预定义的操作来了解后端功能。
茶野 (Theano)
Theano is an open source deep learning library that allows you to evaluate multi-dimensional arrays effectively. We can easily install using the below command −
Theano是一个开源深度学习库,可让您有效地评估多维数组。 我们可以使用以下命令轻松安装-
pip install theano
By default, keras uses TensorFlow backend. If you want to change backend configuration from TensorFlow to Theano, just change the backend = theano in keras.json file. It is described below −
默认情况下,keras使用TensorFlow后端。 如果要将后端配置从TensorFlow更改为Theano,只需在keras.json文件中更改backend = theano。 它在下面描述-
keras.json (keras.json)
{
"image_data_format": "channels_last",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}
Now save your file, restart your terminal and start keras, your backend will be changed.
现在保存文件,重新启动终端并启动keras,您的后端将被更改。
>>> import keras as k
using theano backend.
翻译自: https://www.tutorialspoint.com/keras/keras_backend_configuration.htm
本文深入探讨了Keras的后端实现,包括TensorFlow和Theano。TensorFlow是由Google开发的开源机器学习库,而Keras是基于TensorFlow或Theano的高级API。文章介绍了如何安装TensorFlow,配置keras.json文件以选择后端,并提供了更改数据格式和数据类型的指导。

911

被折叠的 条评论
为什么被折叠?



