为什么Keras不能处理带有通道的图像的Theano和Tensorflow表示之间的区别?例如,如果您使用Theano作为后端,它们的图像是(samples,color_depth,width,height)形式,如果使用TF,则图像采用(samples,width,height,color_depth)格式 . 看起来像Keras可以只使用其中一个,然后重新格式化幕后的形状 .
Keras只使用一种表示法 .
按标准,它使用 channels_last . 如果用户可以将其更改为 channels_first .
channels_last
channels_first
您可以创建一个keras模型,并将其与tensorflow或theano一起使用,而无需更改模型的任何内容 .
文件 keras.json 包含标准定义:
keras.json
{ "floatx": "float32", "image_data_format": "channels_last", "epsilon": 1e-07, "backend": "tensorflow" }
该文件可在 <user>\.keras\keras.json 中找到
<user>\.keras\keras.json
您还可以通过为每个图层定义参数 data_format 来覆盖标准设置 . (见here) .
data_format
它必须是's a good thing to avoid then using tensorflow or theano functions directly. For cases where it',尝试Keras backend函数 .
1 回答
Keras只使用一种表示法 .
按标准,它使用
channels_last
. 如果用户可以将其更改为channels_first
.您可以创建一个keras模型,并将其与tensorflow或theano一起使用,而无需更改模型的任何内容 .
文件
keras.json
包含标准定义:该文件可在
<user>\.keras\keras.json
中找到您还可以通过为每个图层定义参数
data_format
来覆盖标准设置 . (见here) .它必须是's a good thing to avoid then using tensorflow or theano functions directly. For cases where it',尝试Keras backend函数 .