报错:

AttributeError: module ‘keras.preprocessing.sequence’ has no attribute ‘pad_sequences’
【AI学习笔记】AttributeError: module ‘keras.preprocessing.sequence‘ has no attribute ‘pad_sequences‘
看了许多博客,说是版本问题,我的版本都是2.11.0
【AI学习笔记】AttributeError: module ‘keras.preprocessing.sequence‘ has no attribute ‘pad_sequences‘

解决方法

有的人说:

from keras.preprocessing import sequence
改为
from keras_preprocessing import sequence
结果换了一个报错(然后找相关博客没找到解决方法,可能是我太菜了)
【AI学习笔记】AttributeError: module ‘keras.preprocessing.sequence‘ has no attribute ‘pad_sequences‘
有的人说:
【AI学习笔记】AttributeError: module ‘keras.preprocessing.sequence‘ has no attribute ‘pad_sequences‘

from keras.preprocessing.sequence import pad_sequences
改为
from keras_preprocessing.sequence import pad_sequences
或者
from keras.utils import pad_sequences

看到第一个改法,我寻思着这不和前面那个方法一样吗~
结果:果然不出我所料,一样的错误
【AI学习笔记】AttributeError: module ‘keras.preprocessing.sequence‘ has no attribute ‘pad_sequences‘
然后我又试了第二个改法,结果如下:
【AI学习笔记】AttributeError: module ‘keras.preprocessing.sequence‘ has no attribute ‘pad_sequences‘
欸~,成了哈哈哈,

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。