LoginSignup
0
0

Warning : `load_model` does not return WordVectorModel or SupervisedModel any more, but a `FastText` object which is very similar. への対処方法

Posted at

警告の意味

Githubのissuesの内容を参考にすると、単にload_modelの使用が非推奨であることを伝えているだけで、気にする必要はないようである。

警告を消したい

警告をなくしたい場合、以下のように書くことで解決できる。

from fasttext.FastText import _FastText
fasttext_model = _FastText(model_path=fasttext_model_path) #fastext.load_model(path)の代わり

"_"がついているクラスを直接読んでいるためあまり推奨はされないが、fasttext.load_modelの実装は以下に示すようにprintで必ずWarningを出した上で、_FastTextクラスのインスタンスをreturnしているだけである。そのため、Warningを消したい場合、_FastTextクラスのインスタンスを直接作り出すしかないと考えられる。

def load_model(path):
    """Load a model given a filepath and return a model object."""
    eprint("Warning : `load_model` does not return WordVectorModel or SupervisedModel any more, but a `FastText` object which is very similar.")
    return _FastText(model_path=path)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0