Python3下UnicodeDecodeError:‘ASCII’ codec cant decode..(128)

今天准备用Keras跑一下LeNet的程序,结果总是编码出错

源代码是2.7写的,编码格式是utf-8。然后尝试网上各种方法不适用,最后还是解决了

源代码:

    data = gzip.open(r'C:\Users\Administrator\Desktop\Digit Recognizer\mnist.pkl.gz')  

    train_set,valid_set,test_set = cPickle.load(data)  

修改后:

  

    with gzip.open(r'C:\Users\Administrator\Desktop\Digit Recognizer\mnist.pkl.gz') as f:
    train_set, valid_set, test_set = pickle.load(f, encoding='latin1')

即可解决。

posted @ 2017-09-19 12:09  路在脚下丶  阅读(850)  评论(0编辑  收藏  举报