参考博客https://stackoverflow.com/questions/48561909/attributeerror-module-keras-preprocessing-has-no-attribute-text?answertab=oldest

keras AttributeError: module 'keras.preprocessing' has no attribute 'sequence' 错误解决办法

keras AttributeError: module 'keras.preprocessing' has no attribute 'sequence' 错误解决办法

 

原来我的理解是keras.preprocessing 没有导入或者公开text子模块,因此采用import text方法而不是.text方法。本人就是比葫芦画瓢,嘎嘎。

写法:

import keras

x_pad = kr.preprocessing.sequence.pad_sequences(data_id, max_length)
出现错误:AttributeError: module 'keras.preprocessing' has no attribute 'sequence' 

改为:

from keras.preprocessing import sequence
x_pad = sequence.pad_sequences(data_id, max_length)

解决~,运行没问题

 

相关文章:

  • 2021-04-01
  • 2021-07-10
  • 2022-03-11
  • 2021-07-09
  • 2021-09-04
  • 2021-08-22
  • 2021-04-23
  • 2021-11-02
猜你喜欢
  • 2021-05-19
  • 2022-12-23
  • 2021-10-10
  • 2021-04-29
  • 2021-09-19
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案