File "mtrand.pyx", line 1289, in mtrand.RandomState.uniform (numpy/random/mtrand/mtrand.c:19267)
OverflowError: Range exceeds valid bounds
是的!之前我们在~/.keras/keras.json里改的theano它还是不长记性!
从异常跑出的栈里看是numpy的random函数有越界,
解决:
文件前面初始化设置:
from keras import backend
backend.set_image_dim_ordering('th')
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)
用tensorflow+gpu的时候,在代码里添加这个,注意input此时变成了(samples,row,col,channels)的格式
from keras import backend
import tensorflow
sess=tensorflow.Session()
backend.set_session(sess)
网友评论