参考

https://keras.io/#configuring-your-keras-backend

https://keras.io/backend/

Switching from one backend to another

If you have run Keras at least once, you will find the Keras configuration file at:

$HOME/.keras/keras.json

If it isn't there, you can create it.

linux

~/.keras/目录下 keras.json文件 如果不存在可以手动创建

windows

在系统盘中用户(users)当前用户名下的.keras文件夹中,有个keras.json文件。

打开后更改"backend": "xxxxxx"

xxxxx表示需要更换的后端,如"theano", "tensorflow", or "cntk",

NOTE for Windows Users: Please replace $HOME with %USERPROFILE%.

The default configuration file looks like this:

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

Simply change the field backend to "theano", "tensorflow", or "cntk", and Keras will use the new configuration next time you run any Keras code.

You can also define the environment variable KERAS_BACKEND and this will override what is defined in your config file :

KERAS_BACKEND=tensorflow python -c "from keras import backend"
Using TensorFlow backend.

In Keras it is possible to load more backends than "tensorflow", "theano", and "cntk". Keras can use external backends as well, and this can be performed by changing the keras.json configuration file, and the "backend" setting. Suppose you have a Python module called my_module that you wanted to use as your external backend. The keras.json configuration file would be changed as follows:

{
"image_data_format": "channels_last",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "my_package.my_module"
}

An external backend must be validated in order to be used, a valid backend must have the following functions: placeholder, variable and function.

If an external backend is not valid due to missing a required entry, an error will be logged notifying which entry/entries are missing.


keras.json details

The keras.json configuration file contains the following settings:

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

You can change these settings by editing $HOME/.keras/keras.json.

  • image_data_format: String, either "channels_last" or "channels_first". It specifies which data format convention Keras will follow. (keras.backend.image_data_format() returns it.)

  • For 2D data (e.g. image), "channels_last" assumes (rows, cols, channels) while "channels_first" assumes (channels, rows, cols).
  • For 3D data, "channels_last" assumes (conv_dim1, conv_dim2, conv_dim3, channels) while "channels_first" assumes (channels, conv_dim1, conv_dim2, conv_dim3).
  • 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".

keras 切换后端 TensorFlow,cntk,theano的更多相关文章

  1. 常用深度学习框架(keras,pytorch.cntk,theano)conda 安装--未整理

    版本查询 cpu tensorflow conda env list source activate tensorflow python import tensorflow as tf 和 tf.__ ...

  2. 深度学习框架比较TensorFlow、Theano、Caffe、SciKit-learn、Keras

    TheanoTheano在深度学习框架中是祖师级的存在.Theano基于Python语言开发的,是一个擅长处理多维数组的库,这一点和numpy很像.当与其他深度学习库结合起来,它十分适合数据探索.它为 ...

  3. 关于深度学习框架 TensorFlow、Theano 和 Keras

    [TensorFlow] ——( https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/) 1.TensorFlow是啥 ...

  4. cpu、gpu 安装框架pytorch,cntk,theano及测试

    一,cpu 下安装 tensorflow conda env list source activate tensorflow 直接安装相应版本 python import tensorflow as ...

  5. Deploying Keras model on Tensorflow Serving--

    keras训练了个二分类的模型.需求是把keras模型跑到 tensorflow serving上 (TensorFlow Serving 系统用于在生产环境中运行模型) keras模型转 tenso ...

  6. Comparing deep learning frameworks: Tensorflow, CNTK, MXNet, & Caffe

    https://imaginghub.com/blog/10-a-comparison-of-four-deep-learning-frameworks-tensorflow-cntk-mxnet-a ...

  7. 转:【AI每日播报】从TensorFlow到Theano:横向对比七大深度学习框架

    http://geek.csdn.net/news/detail/139235 说到近期的深度学习框架,TensorFlow火的不得了,虽说有专家在朋友圈大声呼吁,不能让TensorFlow形成垄断地 ...

  8. Problem after converting keras model into Tensorflow pb - 将keras模型转换为Tensorflow pb后的问题

    I'm using keras 2.1.* with tensorflow 1.13.* backend. I save my model during training with .h5 forma ...

  9. Keras:基于Theano和TensorFlow的深度学习库

    catalogue . 引言 . 一些基本概念 . Sequential模型 . 泛型模型 . 常用层 . 卷积层 . 池化层 . 递归层Recurrent . 嵌入层 Embedding 1. 引言 ...

随机推荐

  1. DBUtil内部实现过程解读

    python数据库连接工具DBUtils DBUtils是一个允许在多线程python应用和数据库之间安全及高效连接的python模块套件. 模块 DBUtils套件包含两个模块子集,一个适用于兼容D ...

  2. VBScript把json字符串解析成json对象的2个方法

    这篇文章主要介绍了VBScript把json字符串解析成json对象的2个方法,本文通过MSScriptControl.ScriptControl和jscript实现,需要的朋友可以参考下 asp/v ...

  3. Expression: __acrt_first_block == header

    File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp Line: 996 Expression: __acrt_first_block == ...

  4. load ifc

    void setRootNode( osg::Group* root ) { m_main_view->setSceneData( root ); if( m_hud_camera ) { ro ...

  5. 5G && 物联网

    可打电话的 2G.能够上网的 3G.满足移动互联网用户需求的 4G 相比,逐步可以商用的 5G 在多重性能上更胜一筹,如 高数据率: 低延迟: 更节能: 有效地降低通信成本: 具备更高的系统容量: 更 ...

  6. python面试必备-基础篇

    一.python中and, or, and-or语法 1.and   有假先出假 在Python 中,and 和 or 执行布尔逻辑演算,如你所期待的一样,但是它们并不返回布尔值:而是,返回它们实际进 ...

  7. PHP实现简单留言板

    最近学习了下PHP基础,这里做一个简单的留言板,算是对PHP和MySQL的使用做一个整体的练习吧,不遇到问题总感觉学不到东西. 截图如下: 总结: 1>数据库的简单操作,数据库的增删改查: 2. ...

  8. php关于文件上传的两个配置项说明

    ; Maximum allowed size for uploaded files.; http://php.net/upload-max-filesizeupload_max_filesize = ...

  9. linux下的进程通信之信号量semaphore

    概念: IPC 信号量和内核信号量非常相似,是内核信号量的用户态版本. 优点:每个IPC信号量可以保护一个或者多个信号量值的集合,而不像内核信号量一样只有一个值,这意味着同一个IPC资源可以保护多个独 ...

  10. SQLPrompt 6.3.0.354 完美破解 安装于 SQL Server 2012/2014

    SQL SERVER 2012格式化 SQL SERVER 2014格式化 SQLPrompt_6.4.0.641 破解版 百度云下载 迅雷下载 百度网盘下载 SQL Prompt 是一款拥有SQL智 ...