亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

tensorflow.keras.Tokenizer - AttributeError:

tensorflow.keras.Tokenizer - AttributeError:

白豬掌柜的 2023-10-31 16:34:42
我的數據幀或浮點數中都沒有空值。但是,錯誤仍然存在。以下是有關我的數據的一些信息:關于空值(據我所知,numpy.nans 在 pandas 中被編碼為浮點數):?關于數據類型:當我這樣做時:from tensorflow.keras.preprocessing.text import Tokenizertitle_tokeniser = Tokenizer(num_words=10)title_tokeniser.fit_on_texts(train_set.loc[:,'title'] + test_set.loc[:,'title'])這是錯誤:---------------------------------------------------------------------------AttributeError? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call last)<ipython-input-38-26b704f1c0a1> in <module>()? ? ? 1 title_tokeniser = Tokenizer(num_words=10)----> 2 title_tokeniser.fit_on_texts(train_set.loc[:,'title'] + test_set.loc[:,'title'])? ? ? 3?? ? ? 4 # unique tokens found in titles are:? ? ? 5 title_token_index = title_tokeniser.word_index1 frames/usr/local/lib/python3.6/dist-packages/keras_preprocessing/text.py in fit_on_texts(self, texts)? ? 223? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?self.filters,? ? 224? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?self.lower,--> 225? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?self.split)? ? 226? ? ? ? ? ? ?for w in seq:? ? 227? ? ? ? ? ? ? ? ?if w in self.word_counts:/usr/local/lib/python3.6/dist-packages/keras_preprocessing/text.py in text_to_word_sequence(text, filters, lower, split)? ? ?41? ? ?"""? ? ?42? ? ?if lower:---> 43? ? ? ? ?text = text.lower()? ? ?44?? ? ?45? ? ?if sys.version_info < (3,):AttributeError: 'float' object has no attribute 'lower'
查看完整描述

1 回答

?
紅糖糍粑

TA貢獻1815條經驗 獲得超6個贊

嘗試這個


texts = pd.concat([train_set['title'] , test_set['title']],axis=0).astype("str")

   

from tensorflow.keras.preprocessing.text import Tokenize

title_tokeniser = Tokenizer(num_words=10)

title_tokeniser.fit_on_texts(texts)


查看完整回答
反對 回復 2023-10-31
  • 1 回答
  • 0 關注
  • 169 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號