1. Error
在使用Keras.layers.convolutional.Convolution2D的时候
Convolution2D(32, 5, 5, border_mode='valid', input_shape=(1, 28, 28), activation='relu')
报如下错误:
OverflowError: Range exceeds valid bounds
这是因为Keras配置图片通道顺序错误导致的。上面代码使用图片通道顺序是[channels][height][width]
2. 修改图片通道顺序
检查 ~/.keras/keras.json文件
if "image_dim_ordering": is "th" and "backend": "theano", your input_shape must be (channels, height, width) if "image_dim_ordering": is "tf" and "backend": "tensorflow", your input_shape must be (height, width, channels)
所以,要保证你使用的通道顺序和配置的通道顺序一致
或者通过这样修改
from keras import backend backend.set_image_dim_ordering('th')
补充:Keras设置后端数据维度顺序
Keras是比较高级的深度学习框架,其对几个比较常见的主流深度学习框架的封装而来,也就是按照Keras的说法就是其后端是以Ten