transformers4rec.tf.layers package

Submodules

transformers4rec.tf.layers.interaction module

class transformers4rec.tf.layers.interaction.DotProductInteraction(*args, **kwargs)[source]

Bases: keras.engine.base_layer.Layer

build(input_shape)[source]
call(inputs)[source]
compute_output_shape(input_shape)[source]
get_config()[source]

transformers4rec.tf.layers.outer_product module

class transformers4rec.tf.layers.outer_product.XDeepFmOuterProduct(*args, **kwargs)[source]

Bases: keras.engine.base_layer.Layer

Layer implementing the outer product transformation used in the Compressed Interaction Network (CIN) proposed in in https://arxiv.org/abs/1803.05170. Treats the feature dimension H_k of a B x H_k x D feature embedding tensor as a feature map of the D embedding elements, and computes element-wise multiplication interaction between these maps and those from an initial input tensor x_0 before taking the inner product with a parameter matrix.

Parameters

dim (int) – Feature dimension of the layer. Output will be of shape (batch_size, dim, embedding_dim)

build(input_shapes)[source]
call(inputs)[source]
Parameters

inputs (array-like(tf.Tensor)) – The two input tensors, the first of which should be the output of the previous layer, and the second of which should be the input to the CIN.

compute_output_shape(input_shapes)[source]

Module contents

class transformers4rec.tf.layers.DotProductInteraction(*args, **kwargs)[source]

Bases: keras.engine.base_layer.Layer

build(input_shape)[source]
call(inputs)[source]
compute_output_shape(input_shape)[source]
get_config()[source]
class transformers4rec.tf.layers.XDeepFmOuterProduct(*args, **kwargs)[source]

Bases: keras.engine.base_layer.Layer

Layer implementing the outer product transformation used in the Compressed Interaction Network (CIN) proposed in in https://arxiv.org/abs/1803.05170. Treats the feature dimension H_k of a B x H_k x D feature embedding tensor as a feature map of the D embedding elements, and computes element-wise multiplication interaction between these maps and those from an initial input tensor x_0 before taking the inner product with a parameter matrix.

Parameters

dim (int) – Feature dimension of the layer. Output will be of shape (batch_size, dim, embedding_dim)

build(input_shapes)[source]
call(inputs)[source]
Parameters

inputs (array-like(tf.Tensor)) – The two input tensors, the first of which should be the output of the previous layer, and the second of which should be the input to the CIN.

compute_output_shape(input_shapes)[source]