matchzoo.models package¶
Submodules¶
matchzoo.models.anmm module¶
An implementation of aNMM Model.
-
class
matchzoo.models.anmm.
ANMM
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
ANMM Model.
Examples
>>> model = ANMM() >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model structure.
aNMM model based on bin weighting and query term attentions
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
matchzoo.models.arci module¶
An implementation of ArcI Model.
-
class
matchzoo.models.arci.
ArcI
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
ArcI Model.
Examples
>>> model = ArcI() >>> model.params['num_blocks'] = 1 >>> model.params['left_filters'] = [32] >>> model.params['right_filters'] = [32] >>> model.params['left_kernel_sizes'] = [3] >>> model.params['right_kernel_sizes'] = [3] >>> model.params['left_pool_sizes'] = [2] >>> model.params['right_pool_sizes'] = [4] >>> model.params['conv_activation_func'] = 'relu' >>> model.params['mlp_num_layers'] = 1 >>> model.params['mlp_num_units'] = 64 >>> model.params['mlp_num_fan_out'] = 32 >>> model.params['mlp_activation_func'] = 'relu' >>> model.params['dropout_rate'] = 0.5 >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model structure.
ArcI use Siamese arthitecture.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
matchzoo.models.arcii module¶
An implementation of ArcII Model.
-
class
matchzoo.models.arcii.
ArcII
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
ArcII Model.
Examples
>>> model = ArcII() >>> model.params['embedding_output_dim'] = 300 >>> model.params['num_blocks'] = 2 >>> model.params['kernel_1d_count'] = 32 >>> model.params['kernel_1d_size'] = 3 >>> model.params['kernel_2d_count'] = [16, 32] >>> model.params['kernel_2d_size'] = [[3, 3], [3, 3]] >>> model.params['pool_2d_size'] = [[2, 2], [2, 2]] >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model structure.
ArcII has the desirable property of letting two sentences meet before their own high-level representations mature.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
matchzoo.models.cdssm module¶
An implementation of CDSSM (CLSM) model.
-
class
matchzoo.models.cdssm.
CDSSM
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
CDSSM Model implementation.
Learning Semantic Representations Using Convolutional Neural Networks for Web Search. (2014a) A Latent Semantic Model with Convolutional-Pooling Structure for Information Retrieval. (2014b)
Examples
>>> model = CDSSM() >>> model.params['optimizer'] = 'adam' >>> model.params['filters'] = 32 >>> model.params['kernel_size'] = 3 >>> model.params['conv_activation_func'] = 'relu' >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model structure.
CDSSM use Siamese architecture.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
classmethod
get_default_preprocessor
()¶ 返回: Default preprocessor.
-
guess_and_fill_missing_params
(verbose=1)¶ Guess and fill missing parameters in
params
.Use this method to automatically fill-in hyper parameters. This involves some guessing so the parameter it fills could be wrong. For example, the default task is Ranking, and if we do not set it to Classification manually for data packs prepared for classification, then the shape of the model output and the data will mismatch.
参数: verbose -- Verbosity.
-
matchzoo.models.conv_knrm module¶
ConvKNRM model.
-
class
matchzoo.models.conv_knrm.
ConvKNRM
(params=None, backend=None)¶ -
ConvKNRM model.
Examples
>>> model = ConvKNRM() >>> model.params['embedding_input_dim'] = 10000 >>> model.params['embedding_output_dim'] = 300 >>> model.params['embedding_trainable'] = True >>> model.params['filters'] = 128 >>> model.params['conv_activation_func'] = 'tanh' >>> model.params['max_ngram'] = 3 >>> model.params['use_crossmatch'] = True >>> model.params['kernel_num'] = 11 >>> model.params['sigma'] = 0.1 >>> model.params['exact_sigma'] = 0.001 >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model.
-
get_default_params
()¶ Get default parameters.
-
matchzoo.models.dense_baseline module¶
A simple densely connected baseline model.
-
class
matchzoo.models.dense_baseline.
DenseBaseline
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
A simple densely connected baseline model.
Examples
>>> model = DenseBaseline() >>> model.params['mlp_num_layers'] = 2 >>> model.params['mlp_num_units'] = 300 >>> model.params['mlp_num_fan_out'] = 128 >>> model.params['mlp_activation_func'] = 'relu' >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build() >>> model.compile()
-
build
()¶ Model structure.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
matchzoo.models.drmm module¶
An implementation of DRMM Model.
-
class
matchzoo.models.drmm.
DRMM
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
DRMM Model.
Examples
>>> model = DRMM() >>> model.params['mlp_num_layers'] = 1 >>> model.params['mlp_num_units'] = 5 >>> model.params['mlp_num_fan_out'] = 1 >>> model.params['mlp_activation_func'] = 'tanh' >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build() >>> model.compile()
-
classmethod
attention_layer
(attention_input, attention_mask=None)¶ Performs attention on the input.
参数: - attention_input (
Any
) -- The input tensor for attention layer. - attention_mask (
Optional
[Any
]) -- A tensor to mask the invalid values.
返回: The masked output tensor.
- attention_input (
-
build
()¶ Build model structure.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
classmethod
matchzoo.models.drmmtks module¶
An implementation of DRMMTKS Model.
-
class
matchzoo.models.drmmtks.
DRMMTKS
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
DRMMTKS Model.
Examples
>>> model = DRMMTKS() >>> model.params['embedding_input_dim'] = 10000 >>> model.params['embedding_output_dim'] = 100 >>> model.params['top_k'] = 20 >>> model.params['mlp_num_layers'] = 1 >>> model.params['mlp_num_units'] = 5 >>> model.params['mlp_num_fan_out'] = 1 >>> model.params['mlp_activation_func'] = 'tanh' >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
classmethod
attention_layer
(attention_input, attention_mask=None)¶ Performs attention on the input.
参数: - attention_input (
Any
) -- The input tensor for attention layer. - attention_mask (
Optional
[Any
]) -- A tensor to mask the invalid values.
返回: The masked output tensor.
- attention_input (
-
build
()¶ Build model structure.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
classmethod
matchzoo.models.dssm module¶
An implementation of DSSM, Deep Structured Semantic Model.
-
class
matchzoo.models.dssm.
DSSM
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
Deep structured semantic model.
Examples
>>> model = DSSM() >>> model.params['mlp_num_layers'] = 3 >>> model.params['mlp_num_units'] = 300 >>> model.params['mlp_num_fan_out'] = 128 >>> model.params['mlp_activation_func'] = 'relu' >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model structure.
DSSM use Siamese arthitecture.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
classmethod
get_default_preprocessor
()¶ 返回: Default preprocessor.
-
matchzoo.models.duet module¶
DUET Model.
-
class
matchzoo.models.duet.
DUET
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
DUET Model.
Examples
>>> model = DUET() >>> model.params['embedding_input_dim'] = 1000 >>> model.params['embedding_output_dim'] = 300 >>> model.params['lm_filters'] = 32 >>> model.params['lm_hidden_sizes'] = [64, 32] >>> model.params['dropout_rate'] = 0.5 >>> model.params['dm_filters'] = 32 >>> model.params['dm_kernel_size'] = 3 >>> model.params['dm_d_mpool'] = 4 >>> model.params['dm_hidden_sizes'] = [64, 32] >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model.
-
classmethod
get_default_params
()¶ Get default parameters.
-
matchzoo.models.knrm module¶
KNRM model.
-
class
matchzoo.models.knrm.
KNRM
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
KNRM model.
Examples
>>> model = KNRM() >>> model.params['embedding_input_dim'] = 10000 >>> model.params['embedding_output_dim'] = 10 >>> model.params['embedding_trainable'] = True >>> model.params['kernel_num'] = 11 >>> model.params['sigma'] = 0.1 >>> model.params['exact_sigma'] = 0.001 >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model.
-
classmethod
get_default_params
()¶ Get default parameters.
-
matchzoo.models.match_pyramid module¶
An implementation of MatchPyramid Model.
-
class
matchzoo.models.match_pyramid.
MatchPyramid
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
MatchPyramid Model.
Examples
>>> model = MatchPyramid() >>> model.params['embedding_output_dim'] = 300 >>> model.params['num_blocks'] = 2 >>> model.params['kernel_count'] = [16, 32] >>> model.params['kernel_size'] = [[3, 3], [3, 3]] >>> model.params['dpool_size'] = [3, 10] >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model structure.
MatchPyramid text matching as image recognition.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
matchzoo.models.mvlstm module¶
An implementation of MVLSTM Model.
-
class
matchzoo.models.mvlstm.
MVLSTM
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
MVLSTM Model.
Examples
>>> model = MVLSTM() >>> model.params['lstm_units'] = 32 >>> model.params['top_k'] = 50 >>> model.params['mlp_num_layers'] = 2 >>> model.params['mlp_num_units'] = 20 >>> model.params['mlp_num_fan_out'] = 10 >>> model.params['mlp_activation_func'] = 'relu' >>> model.params['dropout_rate'] = 0.5 >>> model.guess_and_fill_missing_params(verbose=0) >>> model.build()
-
build
()¶ Build model structure.
-
classmethod
get_default_params
()¶ 返回类型: ParamTable
返回: model default parameters.
-
matchzoo.models.naive module¶
Naive model with a simplest structure for testing purposes.
-
class
matchzoo.models.naive.
Naive
(params=None, backend=None)¶ 基类:
matchzoo.engine.base_model.BaseModel
Naive model with a simplest structure for testing purposes.
Bare minimum functioning model. The best choice to get things rolling. The worst choice to fit and evaluate performance.
-
build
()¶ Build.
-