【AI学习笔记】AttributeError: module ‘keras.preprocessing.sequence‘ has no attribute ‘pad_sequences‘

Error:

AttributeError: module 'keras.preprocessing.sequence' has no attribute 'pad_sequences'
![Insert picture description here](https://img-blog.csdnimg.cn/961d1b0c357b473293cb82358074e6e7.png
After reading many blogs, it is said that it is a version problem, and my version is 2.11.0
insert image description here

Solution

Some people said:
Change
from keras.preprocessing import sequence
to
from keras_preprocessing import sequence,
and the result is an error report (then I couldn’t find a solution to the relevant blog, maybe I’m too bad)
insert image description here
Some people said:
insert image description here
Change
from keras.preprocessing .sequence import pad_sequences
changed to
from keras_preprocessing.sequence import pad_sequences
or
from keras.utils import pad_sequences

Seeing the first modification, I wondered if it was the same as the previous method~
The result: As I expected, the same error
insert image description here
Then I tried the second modification, the result is as follows:
insert image description here
Hey~, success Hahaha,

Guess you like

Origin blog.csdn.net/weixin_45954198/article/details/128146170