matchzoo package¶
Subpackages¶
- matchzoo.auto package
- matchzoo.contrib package
- matchzoo.data_generator package
- matchzoo.data_pack package
- matchzoo.datasets package
- matchzoo.engine package
- Submodules
- matchzoo.engine.base_metric module
- matchzoo.engine.base_model module
- matchzoo.engine.base_preprocessor module
- matchzoo.engine.base_task module
- matchzoo.engine.callbacks module
- matchzoo.engine.hyper_spaces module
- matchzoo.engine.param module
- matchzoo.engine.param_table module
- Module contents
- matchzoo.layers package
- matchzoo.losses package
- matchzoo.metrics package
- Submodules
- matchzoo.metrics.average_precision module
- matchzoo.metrics.discounted_cumulative_gain module
- matchzoo.metrics.mean_average_precision module
- matchzoo.metrics.mean_reciprocal_rank module
- matchzoo.metrics.normalized_discounted_cumulative_gain module
- matchzoo.metrics.precision module
- Module contents
- matchzoo.models package
- Submodules
- matchzoo.models.anmm module
- matchzoo.models.arci module
- matchzoo.models.arcii module
- matchzoo.models.cdssm module
- matchzoo.models.conv_knrm module
- matchzoo.models.dense_baseline module
- matchzoo.models.drmm module
- matchzoo.models.drmmtks module
- matchzoo.models.dssm module
- matchzoo.models.duet module
- matchzoo.models.knrm module
- matchzoo.models.match_pyramid module
- matchzoo.models.mvlstm module
- matchzoo.models.naive module
- matchzoo.models.parameter_readme_generator module
- Module contents
- matchzoo.preprocessors package
- matchzoo.processor_units package
- matchzoo.tasks package
- matchzoo.utils package
Submodules¶
matchzoo.embedding module¶
Matchzoo toolkit for token embedding.
-
class
matchzoo.embedding.
Embedding
(data)¶ 基类:
object
Embedding class.
- Examples::
>>> import matchzoo as mz >>> data_pack = mz.datasets.toy.load_data() >>> pp = mz.preprocessors.NaivePreprocessor() >>> vocab_unit = mz.build_vocab_unit(pp.fit_transform(data_pack), ... verbose=0) >>> term_index = vocab_unit.state['term_index'] >>> embed_path = mz.datasets.embeddings.EMBED_RANK
- To load from a file:
>>> embedding = mz.embedding.load_from_file(embed_path) >>> matrix = embedding.build_matrix(term_index) >>> matrix.shape[0] == len(term_index) + 1 True
- To build your own:
>>> data = pd.DataFrame(data=[[0, 1], [2, 3]], index=['A', 'B']) >>> embedding = mz.embedding.Embedding(data) >>> matrix = embedding.build_matrix({'A': 2, 'B': 1}) >>> matrix.shape == (3, 2) True
-
build_matrix
(term_index, initializer=<function Embedding.<lambda>>)¶ Build a matrix using term_index.
参数: - term_index (
dict
) -- A dict or TermIndex to build with. - initializer -- A callable that returns a default value for missing terms in data. (default: a random uniform distribution in range) (-0.2, 0.2)).
返回类型: ndarray
返回: A matrix.
- term_index (
-
input_dim
¶ return Embedding input dimension.
返回类型: int
-
output_dim
¶ return Embedding output dimension.
返回类型: int
-
matchzoo.embedding.
load_from_file
(file_path, mode='word2vec')¶ Load embedding from file_path.
参数: - file_path (
str
) -- Path to file. - mode (
str
) -- Embedding file format mode, one of 'word2vec' or 'glove'. (default: 'word2vec')
返回类型: 返回: An
matchzoo.embedding.Embedding
instance.- file_path (
matchzoo.logger module¶
MatchZoo Logging module.
matchzoo.version module¶
Matchzoo version file.