Module¶
-
class
openrec.legacy.modules.
Module
(train=True, l2_reg=None, scope=None, reuse=False)¶ The module is the OpenRec abstraction for modules. A module may belong to one of the three categories, extractions, fusions, and interactions, depending on its functionality (Read [1] for details).
Parameters: - train (bool, optional) – An indicator for training or servining phase.
- l2_reg (float, optional) – Weight for L2 regularization, i.e., weight decay.
- scope (str, optional) – Scope for module variables.
- reuse (bool, optional) – Whether or not to reuse module variables.
Notes
The module abstraction is used to construct recommenders. It should be extended by all module implementations. During initialization, functions
self._build_shared_graph
,self._build_training_graph
, andself._build_serving_graph
are called as follows.A module implementation should follow two steps below:
- Build computational graphs. Override
self._build_shared_graph()
,self._build_training_graph()
, and/orself._build_serving_graph()
functions to build training/serving computational graphs. - Define a loss and an output list. Define a loss (
self._loss
) to be included in training and an output list of Tensorflow tensors (self._outputs
).
References
[1] Yang, L., Bagdasaryan, E., Gruenstein, J., Hsieh, C., and Estrin, D., 2018, June. OpenRec: A Modular Framework for Extensible and Adaptable Recommendation Algorithms. In Proceedings of WSDM‘18, February 5-9, 2018, Marina Del Rey, CA, USA. -
_build_serving_graph
()¶ Build serving-specific computational graphs (may be overridden).
Build shared computational graphs across training and serving (may be overridden).
-
_build_training_graph
()¶ Build training-specific computational graphs (may be overridden).
-
get_loss
()¶ Retrieve the training loss.
Returns: Training loss Return type: float or Tensor
-
get_outputs
()¶ Retrieve the output list of Tensorflow tensors.
Returns: An output list of Tensorflow tensors Return type: list