美文网首页
keras backend 报错OverflowError

keras backend 报错OverflowError

作者: 荷包蛋酱 | 来源:发表于2017-03-10 21:08 被阅读0次
    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)
    

    相关文章

      网友评论

          本文标题:keras backend 报错OverflowError

          本文链接:https://www.haomeiwen.com/subject/sgmogttx.html