Keras-后端配置

编程知识 更新时间:2023-04-19 14:27:33

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()方法将其更改为float16float64

  • 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/keras/keras_backend_configuration.htm

更多推荐

Keras-后端配置

本文发布于:2023-04-15 07:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/446ca3353c2d832e40d66cfcd2b88ee9.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后端   Keras

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 77787文章数
  • 14阅读数
  • 0评论数