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. 引言 ...
随机推荐
- SSH工具登录远程指定节点时输入用户名密码方式【我】
通过堡垒机部署项目, 一种方式:先把补丁传到接入机,然后用CRT等命令行工具登录指定接入机,然后用SCP命令把 补丁传到 生产服务器,比如 scp -P90010 /app/backup/packet ...
- 算法习题---4-5IP网络(Uva1590)
一:题目 给出m(1到10000之间)个IP地址,求他们最小的网络号和子网掩码 (一)样例输入 3 表示要获取的IP地址个数 194.85.160.177 IP地址 194.85.160.183 19 ...
- jsp中cookie的一个报错
写项目时在一个jsp页面中使用了cookie,用逗号分隔的数据,服务器老报错,搞了一个小时,终于清楚了,jsp的cookie中不能使用逗号. cookie规则:这个规则用于jsp.asp中(下面这两句 ...
- 安装android sdk,后出现导出错误,提示命令行找不到解决方案
The steps. Rename android sdk tool folder : [Your Android SDK root]/tools -> toolsXXXX Download S ...
- Python 动态规划算法
背包问题 假设你是一个小偷,背一个可装4磅东西的背包.可盗窃的商品有如下3件: 音响,4磅,价值3000美元 笔记本电脑,3磅,价值2000美元 吉他,1磅,价值1500美元 为了让盗窃的商品价值最高 ...
- C# checked和unchecked 关键字详解
checked 和 unchecked关键字用来限定检查或者不检查数学运算溢出的:如果使用了checked发生数学运算溢出时会抛出OverflowException:如果使用了unchecked则不会 ...
- selenium + python 环境配置 (二)之启动IE
安装好python.selenium工具后,下一步就是启动浏览器 1.启动IE浏览器 即Selenium 调用IEDriverServer打开IE浏览器 ,因此需下载对应的IEDriverServer ...
- php开启多线程下载
php开启多线程下载 <pre><?php/** * 多进程批量下载文件(使用php curl_multi_exec实现) * Date: 2017-07-16 * Author: ...
- 学习笔记:oracle学习一:oracle11g体系结构之物理存储结构
目录 1.物理存储结构 1.1 数据文件 1.2 控制文件 1.3 日志文件 1.3.1 重做日志文件 1.3.2 归档日志文件 1.4 服务器参数文件 1.4.1 查看服务器参数 1.4.2 修改服 ...
- 工作总结 CTO(张王岩) File构造器
import java.io.File; /** * 构建File对象 * @author Allen17805272076 * */ public class FileDemo2 { public ...