elliot.recommender.neural.ConvMF package

Submodules

elliot.recommender.neural.ConvMF.convolutional_matrix_factorization module

Module description:

class elliot.recommender.neural.ConvMF.convolutional_matrix_factorization.ConvMF(data, config, params, *args, **kwargs)[source]

Bases: elliot.recommender.recommender_utils_mixin.RecMixin, elliot.recommender.base_recommender_model.BaseRecommenderModel

Convolutional Matrix Factorization for Document Context-Aware Recommendation

For further details, please refer to the paper

Parameters
  • embedding_size – Embedding dimension

  • lr – Learning rate

  • l_w – Regularization coefficient

  • l_b – Regularization coefficient of bias

  • cnn_channels – List of channels

  • cnn_kernels – List of kernels

  • cnn_strides – List of strides

  • dropout_prob – Dropout probability applied on the convolutional layers

To include the recommendation model, add it to the config file adopting the following pattern:

models:
  ConvMF:
    meta:
      save_recs: True
    epochs: 10
    batch_size: 512
    embedding_size: 100
    lr: 0.001
    l_w: 0.005
    l_b: 0.0005
    cnn_channels: (1, 32, 32)
    cnn_kernels: (2,2)
    cnn_strides: (2,2)
    dropout_prob: 0
get_recommendations(k: int = 100)[source]
property name
train()[source]

elliot.recommender.neural.ConvMF.convolutional_matrix_factorization_model module

Module description:

class elliot.recommender.neural.ConvMF.convolutional_matrix_factorization_model.ConvMatrixFactorizationModel(*args, **kwargs)[source]

Bases: tensorflow.python.keras.engine.training.Model

call(inputs, training=False, **kwargs)[source]

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).

Parameters
  • inputs – A tensor or list of 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.

get_recs(inputs, training=False, **kwargs)[source]

Get full predictions on the whole users/items matrix.

Returns

The matrix of predicted values.

get_top_k(preds, train_mask, k=100)[source]
predict(inputs, training=False, **kwargs)[source]

Get full predictions on the whole users/items matrix.

Returns

The matrix of predicted values.

train_step(batch)[source]

The logic for one training step.

This method can be overridden to support custom training logic. This method is called by Model.make_train_function.

This method should contain the mathemetical logic for one step of training. This typically includes the forward pass, loss calculation, backpropagation, and metric updates.

Configuration details for how this logic is run (e.g. tf.function and tf.distribute.Strategy settings), should be left to Model.make_train_function, which can also be overridden.

Parameters

data – A nested structure of `Tensor`s.

Returns

A dict containing values that will be passed to tf.keras.callbacks.CallbackList.on_train_batch_end. Typically, the values of the Model’s metrics are returned. Example: {‘loss’: 0.2, ‘accuracy’: 0.7}.

class elliot.recommender.neural.ConvMF.convolutional_matrix_factorization_model.ConvolutionalComponent(*args, **kwargs)[source]

Bases: tensorflow.python.keras.engine.training.Model

call(inputs, **kwargs)[source]

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).

Parameters
  • inputs – A tensor or list of 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 elliot.recommender.neural.ConvMF.convolutional_matrix_factorization_model.MLPComponent(*args, **kwargs)[source]

Bases: tensorflow.python.keras.engine.training.Model

call(inputs, training=False, **kwargs)[source]

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).

Parameters
  • inputs – A tensor or list of 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.

Module contents