def __init__(self, embeddings, nbow, vocabulary_min=50, vocabulary_max=500,
vocabulary_optimizer=TailVocabularyOptimizer(),
verbosity=logging.INFO, main_loop_log_interval=60):
"""
Initializes a new instance of WMD class.
:param embeddings: The embeddings model, see WMD.embeddings.
:param nbow: The nBOW model, see WMD.nbow.
:param vocabulary_min: The minimum bag size, see \
:py:attr:`~wmd.WMD.vocabulary_min`.
:param vocabulary_max: The maximum bag size, see \
:py:attr:`~wmd.WMD.vocabulary_max`.
:param vocabulary_optimizer: The bag size reducer, see \
:py:attr:`~wmd.WMD.vocabulary_optimizer`.
:param verbosity: The log verbosity level.
:param main_loop_log_interval: Time frequency of logging updates, see \
:py:attr:`~wmd.WMD.main_loop_log_interval`.
:type embeddings: object with :meth:`~object.__getitem__`
:type nbow: object with :meth:`~object.__iter__` and \
:meth:`~object.__getitem__`
:type vocabulary_min: int
:type vocabulary_max: int
:type vocabulary_optimizer: callable
:type verbosity: int
:type main_loop_log_interval: int
:raises TypeError: if some of the arguments are invalid.
:raises ValueError: if some of the arguments are invalid.
"""
self._relax_cache = None
self._exact_cache = None
self._centroid_cache = None
self.embeddings = embeddings
self.nbow = nbow
self.vocabulary_min = vocabulary_min
self.vocabulary_max = vocabulary_max
self.vocabulary_optimizer = vocabulary_optimizer
self._log = logging.getLogger("WMD")
self._log.level = logging.Logger("", verbosity).level
self.main_loop_log_interval = main_loop_log_interval
评论列表
文章目录