easyrec.blocks¶
easyrec.blocks.interaction¶
- class easyrec.blocks.interaction.AFM(*args, **kwargs)¶
Bases:
keras.engine.training.Model
Attentional factorization machine layer.
- Parameters
one_hot_feature_columns – List[CategoricalColumn] encodes one hot feature fields, such as sex_id.
k – Dimension of the second-order weights.
- call(inputs, training=None, mask=None)¶
Calls the model on new inputs.
In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__ method, i.e. model(inputs), which relies on the underlying call method.
- Parameters
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a tensor or None (no mask).
- Returns
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class easyrec.blocks.interaction.FFM(*args, **kwargs)¶
Bases:
keras.engine.training.Model
Field-aware factorization machine layer.
- Parameters
one_hot_feature_columns – List[CategoricalColumn] encodes one hot feature fields, such as sex_id.
k – Dimension of the second-order weights.
- call(inputs, *args, **kwargs)¶
Calls the model on new inputs.
In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__ method, i.e. model(inputs), which relies on the underlying call method.
- Parameters
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a tensor or None (no mask).
- Returns
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class easyrec.blocks.interaction.FM(*args, **kwargs)¶
Bases:
keras.engine.training.Model
Factorization machine layer using vector w and matrix v.
- Parameters
one_hot_feature_columns – List[CategoricalColumn] encodes one hot feature fields, such as sex_id.
k – Dimension of the second-order weights.
- call(inputs, *args, **kwargs)¶
Calls the model on new inputs.
In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__ method, i.e. model(inputs), which relies on the underlying call method.
- Parameters
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a tensor or None (no mask).
- Returns
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class easyrec.blocks.interaction.NFM(*args, **kwargs)¶
Bases:
keras.engine.training.Model
Neural factorization machine layer.
- Parameters
one_hot_feature_columns – List[CategoricalColumn] encodes one hot feature fields, such as sex_id.
k – Dimension of the second-order weights.
units_list – Dimension of fully connected stack outputs.
activation – Activation to use.
- call(inputs, training=None, mask=None)¶
Calls the model on new inputs.
In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__ method, i.e. model(inputs), which relies on the underlying call method.
- Parameters
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a tensor or None (no mask).
- Returns
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
easyrec.blocks.nn¶
- class easyrec.blocks.nn.DenseBlock(*args, **kwargs)¶
Bases:
keras.engine.training.Model
Multi-perception layer.
- Parameters
units_list – Dimension of fully connected stack outputs.
activation – Activation to use.
- call(inputs, training=None, mask=None)¶
Calls the model on new inputs.
In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__ method, i.e. model(inputs), which relies on the underlying call method.
- Parameters
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a tensor or None (no mask).
- Returns
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class easyrec.blocks.nn.MultiHeadSelfAttention(*args, **kwargs)¶
Bases:
keras.engine.training.Model
Multi-head self attention layer.
- Parameters
input_dimension – Dimension of input.
qkv_dimension – Dimension of Query, Key and Value.
num_heads – Number of heads.
output_dimension – Dimension of final output.
use_normalization – Whether to use normalization in Query * Key process.
- call(inputs, training=None, mask=None)¶
Calls the model on new inputs.
In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__ method, i.e. model(inputs), which relies on the underlying call method.
- Parameters
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a tensor or None (no mask).
- Returns
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class easyrec.blocks.nn.ResidualBlock(*args, **kwargs)¶
Bases:
keras.engine.training.Model
Residual layer.
- call(inputs, training=None, mask=None)¶
Calls the model on new inputs.
In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__ method, i.e. model(inputs), which relies on the underlying call method.
- Parameters
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a tensor or None (no mask).
- Returns
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
- class easyrec.blocks.nn.SelfAttention(*args, **kwargs)¶
Bases:
keras.engine.training.Model
Self attention layer.
- Parameters
input_dimension – Dimension of input.
qkv_dimension – Dimension of Query, Key and Value.
use_normalization – Whether to use normalization in Query * Key process.
- call(inputs, training=None, mask=None)¶
Calls the model on new inputs.
In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be overridden when subclassing tf.keras.Model. To call a model on an input, always use the __call__ method, i.e. model(inputs), which relies on the underlying call method.
- Parameters
inputs – Input tensor, or dict/list/tuple of input tensors.
training – Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode.
mask – A mask or list of masks. A mask can be either a tensor or None (no mask).
- Returns
A tensor if there is a single output, or a list of tensors if there are more than one outputs.