deepctr.sequence module¶

class
deepctr.sequence.
AttentionSequencePoolingLayer
(hidden_size=(80, 40), activation='sigmoid', weight_normalization=False, **kwargs)[source]¶ The Attentional sequence pooling operation used in DIN.
 Input shape
 A list of three tensor: [query,keys,keys_length]
 query is a 3D tensor with shape:
(batch_size, 1, embedding_size)
 keys is a 3D tensor with shape:
(batch_size, T, embedding_size)
 keys_length is a 2D tensor with shape:
(batch_size, 1)
 Output shape
 3D tensor with shape:
(batch_size, 1, embedding_size)
.
 3D tensor with shape:
 Arguments
 hidden_size:list of positive integer, the attention net layer number and units in each layer.
 activation: Activation function to use in attention net.
 weight_normalization: bool.Whether normalize the attention score of local activation unit.
 References
 [Zhou G, Zhu X, Song C, et al. Deep interest network for clickthrough rate prediction[C]//Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining. ACM, 2018: 10591068.](https://arxiv.org/pdf/1706.06978.pdf)

call
(inputs, **kwargs)[source]¶ This is where the layer’s logic lives.
 Arguments:
 inputs: Input tensor, or list/tuple of input tensors. **kwargs: Additional keyword arguments.
 Returns:
 A tensor or list/tuple of tensors.

get_config
()[source]¶ Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Container (one layer of abstraction above).
 Returns:
 Python dictionary.

class
deepctr.sequence.
SequencePoolingLayer
(seq_len_max, mode='mean', **kwargs)[source]¶ The SequencePoolingLayer is used to apply pooling operation(sum,mean,max) on variablelength sequence feature/multivalue feature.
 Input shape
 A list of two tensor [seq_value,seq_len]
 seq_value is a 3D tensor with shape:
(batch_size, T, embedding_size)
 seq_len is a 2D tensor with shape :
(batch_size, 1)
,indicate valid length of each sequence.
 Output shape
 3D tensor with shape:
(batch_size, 1, embedding_size)
.
 3D tensor with shape:
 Arguments
 seq_len_max:Positive integer indicates that the max length of all the sequence feature,usually same as T.If set to 1,then the input need to support masking.
 mode:str.Pooling operation to be used,can be sum,mean or max.

call
(seq_value_len_list, mask=None, **kwargs)[source]¶ This is where the layer’s logic lives.
 Arguments:
 inputs: Input tensor, or list/tuple of input tensors. **kwargs: Additional keyword arguments.
 Returns:
 A tensor or list/tuple of tensors.

compute_mask
(inputs, mask)[source]¶ Computes an output mask tensor.
 Arguments:
 inputs: Tensor or list of tensors. mask: Tensor or list of tensors.
 Returns:
 None or a tensor (or list of tensors,
 one per output tensor of the layer).

get_config
()[source]¶ Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Container (one layer of abstraction above).
 Returns:
 Python dictionary.