keras 切换后端 TensorFlow,cntk,theano
参考
https://keras.io/#configuring-your-keras-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的更多相关文章
- 常用深度学习框架(keras,pytorch.cntk,theano)conda 安装--未整理
版本查询 cpu tensorflow conda env list source activate tensorflow python import tensorflow as tf 和 tf.__ ...
- 深度学习框架比较TensorFlow、Theano、Caffe、SciKit-learn、Keras
TheanoTheano在深度学习框架中是祖师级的存在.Theano基于Python语言开发的,是一个擅长处理多维数组的库,这一点和numpy很像.当与其他深度学习库结合起来,它十分适合数据探索.它为 ...
- 关于深度学习框架 TensorFlow、Theano 和 Keras
[TensorFlow] ——( https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/) 1.TensorFlow是啥 ...
- cpu、gpu 安装框架pytorch,cntk,theano及测试
一,cpu 下安装 tensorflow conda env list source activate tensorflow 直接安装相应版本 python import tensorflow as ...
- Deploying Keras model on Tensorflow Serving--
keras训练了个二分类的模型.需求是把keras模型跑到 tensorflow serving上 (TensorFlow Serving 系统用于在生产环境中运行模型) keras模型转 tenso ...
- Comparing deep learning frameworks: Tensorflow, CNTK, MXNet, & Caffe
https://imaginghub.com/blog/10-a-comparison-of-four-deep-learning-frameworks-tensorflow-cntk-mxnet-a ...
- 转:【AI每日播报】从TensorFlow到Theano:横向对比七大深度学习框架
http://geek.csdn.net/news/detail/139235 说到近期的深度学习框架,TensorFlow火的不得了,虽说有专家在朋友圈大声呼吁,不能让TensorFlow形成垄断地 ...
- 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 ...
- Keras:基于Theano和TensorFlow的深度学习库
catalogue . 引言 . 一些基本概念 . Sequential模型 . 泛型模型 . 常用层 . 卷积层 . 池化层 . 递归层Recurrent . 嵌入层 Embedding 1. 引言 ...
随机推荐
- Delphi ADOQuery的速度优化
今天终于把纠缠了几天的问题改完了,说到底只是一个很小的问题,就是ADOQuery的一个小属性. 把控件DBGridEh的一列的checkbox设为true,将其绑定DataSource和ADOQuer ...
- mysql常用命令、非交互式mysql命令看29条
CentOS下mysql数据库常用命令总结1.更改root密码 mysqladmin -uroot password 'yourpassword' 2.远程登陆mysql服务器 mysql -uroo ...
- SQL 创建表
SQL 创建表是通过SQL CREATE TABLE 语句来实现,该语句是DDL SQL语句.CREATE TABLE语句用于创建用于存储数据的表.在创建表时,可以为列定义主键.惟一键和外键等完整性约 ...
- java 画图 Graphics 文字自动换行
/** * 文字超出限定长度自动换行 * * @param g 画布 * @param font 字体样式 * @param text 文字 * @param widthLength 最大长度 (多少 ...
- Spring Maven工程引入css,js
1.CSS <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet" type="t ...
- esigner中name和comment互換
1 PowerDesigner中批量根据对象的name生成comment的脚本 执行方法:Open PDM -- Tools -- Execute Commands -- Run Script Opt ...
- python lanbda匿名函数(20)
在python开发中常规的函数在调用之前都需要先声明,而python还有一种匿名函数,有速写函数的功能并且匿名函数不需要声明也没有函数名字,完全不需要担心函数名冲突,具体的妙用还需要从实战练习中多多积 ...
- Linux基础重点习题讲解
第一章 一个EXT4的文件分区,当时使用touch test.file命令创建一个新文件时报错,报错的信息是提示磁盘已满,但是采用df-h命令查看磁盘大小时,只使用了60%的磁盘空间,为什么会出现这 ...
- 乐字节Java变量与数据类型之一:Java编程规范,关键字与标识符
大家好,我是乐字节的小乐,这次要给大家带来的是Java变量与数据类型.本文是第一集:Java编程规范,关键字与标识符. 一.编程规范 任何地方的名字都需要见名知意: 代码适当缩进 书写过程成对编程 对 ...
- pthread_mutexattr_t设置的相关函数及其说明
基本概述 该函数用于C函数的多线程编程中,互斥锁的初始化. 头文件:#include <pthread.h> 函数原型: int pthread_mutex_init(pthread_mu ...