wv = Word2Vec.load_word2vec_format("GoogleNews-vectors-negative300.bin.gz", binary=True)
wv.init_sims(replace=True)
私に知らせてください問題 ?
wv = Word2Vec.load_word2vec_format("GoogleNews-vectors-negative300.bin.gz", binary=True)
wv.init_sims(replace=True)
私に知らせてください問題 ?
どのようにgensimをインストールしましたか、どのバージョンがインストールされていますか?
gensim 1.0のAPIの変更点load_word2vec_format()
をKeyedVectors
というヘルパークラスに変更しました(現在のプレリリース版)。
この時点(2017年2月)は、経験豊かなユーザーで、リリースノート[CHANGELOG.md][1]
に厳密に従わない限り、プレリリース版を使用したくない可能性があります。
意図的にこのAPIの変更にgensimのそれ以降のバージョンを使用している場合は、代わりに使用します。
KeyedVectors.load_word2vec_format("GoogleNews-vectors-negative300.bin.gz", binary=True)
gensim.models.KeyedVectors.load_word2vec_format("GoogleNews-vectors-negative300.bin.gz", binary=True)
を
例えばsmart_open(gensimのすべての依存関係をアップグレードしよう)、まだ次のようなエラーがある場合
pip install --upgrade gensim
INIT self.model = gensim.models.KeyedVectors.load_word2vec_format(w2v_path、バイナリ= TRUE)
におけるファイル "/home/liangn/PythonProjects/DeepRecommendation/Algorithm/Word2Vec.py"、ライン18、フィンとしてutils.smart_open(fnameに)とload_word2vec_formatでファイル "/home/liangn/PythonProjects/venvLiang/lib/python2.7/site-packages/gensim/models/keyedvectors.py"、行191、:
ファイル "/home/liangn/PythonProjects/venvLiang/lib/python2.7/site-packages/smart_open/smart_open_lib.py"、smart_openの138行目、 return file_smart_open(parsed_uri.uri_path、mode)
file_smart_open リターンcompression_wrapper(オープン(fnameは、モード)、fnameは、中のファイル "/home/liangn/PythonProjects/venvLiang/lib/python2.7/site-packages/smart_open/smart_open_lib.py"、ライン642、モード)compression_wrapper リターンmake_closing(のGzipFile)(file_obj、モード)で
ファイル "/home/liangn/PythonProjects/venvLiang/lib/python2.7/site-packages/smart_open/smart_open_lib.py"、ライン630、
ファイル "/usr/lib64/python2.7/gzip.py"、ライン94、のinitで もしfileobj = self.myfileobj = 組み込み .open(ファイル名、モードや 'RB')
はTypeError:Unicodeに強制変換:必要文字列またはバッファ、ファイルは私がgensimに新しいですし、1.0.0rc2を使用して
を見つけました。 輸入KeyedVectors KeyedVectors.load_word2vec_format( "Googleニュースベクトル-negative300.bin.gz"、真=バイナリ)が、それでも私はエラーを取得しています:私はKeyedVectorを使用してみました。私はPython 2.7を使用しています。いくつかのパッケージがうまくいくので、Anacondaにアップグレードする必要があります –
gensimはどのようにインストールしましたか?私は 'pip install gensim'があなたをそのプレリリース版にするとは思わない。 'KeyedVector'を使用しようとすると実際に何のエラーが出ていますか? (同じエラーではない可能性があり、解決のためには正確なメッセージが重要です。) – gojomo