deepctr_torch.layers.sequence module

class deepctr_torch.layers.sequence.AGRUCell(input_size, hidden_size, bias=True)[source]

Attention based GRU (AGRU)

Reference: - Deep Interest Evolution Network for Click-Through Rate Prediction[J]. arXiv preprint arXiv:1809.03672, 2018.

forward(inputs, hx, att_score)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class deepctr_torch.layers.sequence.AUGRUCell(input_size, hidden_size, bias=True)[source]

Effect of GRU with attentional update gate (AUGRU)

Reference: - Deep Interest Evolution Network for Click-Through Rate Prediction[J]. arXiv preprint arXiv:1809.03672, 2018.

forward(inputs, hx, att_score)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class deepctr_torch.layers.sequence.AttentionSequencePoolingLayer(att_hidden_units=(80, 40), att_activation='sigmoid', weight_normalization=False, return_score=False, supports_masking=False, embedding_dim=4, **kwargs)[source]

The Attentional sequence pooling operation used in DIN & DIEN.

Arguments
  • att_hidden_units:list of positive integer, the attention net layer number and units in each layer.
  • att_activation: Activation function to use in attention net.
  • weight_normalization: bool.Whether normalize the attention score of local activation unit.
  • supports_masking:If True,the input need to support masking.
References
  • [Zhou G, Zhu X, Song C, et al. Deep interest network for click-through rate prediction[C]//Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining. ACM, 2018: 1059-1068.](https://arxiv.org/pdf/1706.06978.pdf)
forward(query, keys, keys_length, mask=None)[source]
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).
class deepctr_torch.layers.sequence.DynamicGRU(input_size, hidden_size, bias=True, gru_type='AGRU')[source]
forward(inputs, att_scores=None, hx=None)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class deepctr_torch.layers.sequence.KMaxPooling(k, axis, device='cpu')[source]

K Max pooling that selects the k biggest value along the specific axis.

Input shape
  • nD tensor with shape: (batch_size, ..., input_dim).
Output shape
  • nD tensor with shape: (batch_size, ..., output_dim).
Arguments
  • k: positive integer, number of top elements to look for along the axis dimension.
  • axis: positive integer, the dimension to look for elements.
forward(inputs)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class deepctr_torch.layers.sequence.SequencePoolingLayer(mode='mean', supports_masking=False, device='cpu')[source]

The SequencePoolingLayer is used to apply pooling operation(sum,mean,max) on variable-length sequence feature/multi-value 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).
Arguments
  • mode:str.Pooling operation to be used,can be sum,mean or max.
forward(seq_value_len_list)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.