matchzoo.layers package¶
Submodules¶
matchzoo.layers.dynamic_pooling_layer module¶
An implementation of Dynamic Pooling Layer.
-
class
matchzoo.layers.dynamic_pooling_layer.
DynamicPoolingLayer
(psize1, psize2, **kwargs)¶ 基类:
keras.engine.base_layer.Layer
Layer that computes dynamic pooling of one tensor.
参数: - psize1 (
int
) -- pooling size of dimension 1 - psize2 (
int
) -- pooling size of dimension 2 - kwargs -- Standard layer keyword arguments.
Examples
>>> import matchzoo as mz >>> layer = mz.layers.DynamicPoolingLayer(3, 2) >>> num_batch, left_len, right_len, num_dim = 5, 3, 2, 10 >>> layer.build([[num_batch, left_len, right_len, num_dim], ... [num_batch, left_len, right_len, 3]])
-
build
(input_shape)¶ Build the layer.
参数: input_shape -- the shapes of the input tensors, for DynamicPoolingLayer we need tow input tensors.
-
call
(inputs, **kwargs)¶ The computation logic of DynamicPoolingLayer.
参数: inputs ( list
) -- two input tensors.返回类型: Any
-
compute_output_shape
(input_shape)¶ Calculate the layer output shape.
参数: input_shape ( list
) -- the shapes of the input tensors, for DynamicPoolingLayer we need tow input tensors.返回类型: tuple
-
get_config
()¶ Get the config dict of DynamicPoolingLayer.
返回类型: dict
- psize1 (
matchzoo.layers.matching_layer module¶
An implementation of Matching Layer.
-
class
matchzoo.layers.matching_layer.
MatchingLayer
(normalize=False, matching_type='dot', **kwargs)¶ 基类:
keras.engine.base_layer.Layer
Layer that computes a matching matrix between samples in two tensors.
参数: - normalize (
bool
) -- Whether to L2-normalize samples along the dot product axis before taking the dot product. If set to True, then the output of the dot product is the cosine proximity between the two samples. - matching_type (
str
) -- the similarity function for matching - kwargs -- Standard layer keyword arguments.
Examples
>>> import matchzoo as mz >>> layer = mz.layers.MatchingLayer(matching_type='dot', ... normalize=True) >>> num_batch, left_len, right_len, num_dim = 5, 3, 2, 10 >>> layer.build([[num_batch, left_len, num_dim], ... [num_batch, right_len, num_dim]])
-
build
(input_shape)¶ Build the layer.
参数: input_shape ( list
) -- the shapes of the input tensors, for MatchingLayer we need tow input tensors.
-
call
(inputs, **kwargs)¶ The computation logic of MatchingLayer.
参数: inputs ( list
) -- two input tensors.返回类型: Any
-
compute_output_shape
(input_shape)¶ Calculate the layer output shape.
参数: input_shape ( list
) -- the shapes of the input tensors, for MatchingLayer we need tow input tensors.返回类型: tuple
-
get_config
()¶ Get the config dict of MatchingLayer.
返回类型: dict
- normalize (