class_docstr: Deep & Cross Network replaces the wide part in Wide&Deep with cross network,
  automatically construct limited high-degree cross features, and learns the corresponding weights.
class_docstr_tok: ["Deep","&","Cross","Network","replaces","the","wide","part","in","Wide","&","Deep","with","cross","network",",","automatically","construct","limited","high-degree","cross","features",",","and","learns","the","corresponding","weights","."]
code: def __init__(self, config, dataset):
      super(DCN, self).__init__(config, dataset)
  
      # load parameters info
      self.mlp_hidden_size = config["mlp_hidden_size"]
      self.cross_layer_num = config["cross_layer_num"]
      self.reg_weight = config["reg_weight"]
      self.dropout_prob = config["dropout_prob"]
  
      # define layers and loss
      # init weight and bias of each cross layer
      self.cross_layer_w = nn.ParameterList(
          nn.Parameter(
              torch.randn(
                  self.num_feature_field * self.embedding_size
              ).to(self.device)
          )
          for _ in range(self.cross_layer_num)
      )
      self.cross_layer_b = nn.ParameterList(
          nn.Parameter(
              torch.zeros(
                  self.num_feature_field * self.embedding_size
              ).to(self.device)
          )
          for _ in range(self.cross_layer_num)
      )
  
      # size of mlp hidden layer
      size_list = [
          self.embedding_size * self.num_feature_field
      ] + self.mlp_hidden_size
      # size of cross network output
      in_feature_num = (
          self.embedding_size * self.num_feature_field
          + self.mlp_hidden_size[-1]
      )
  
      self.mlp_layers = MLPLayers(
          size_list, dropout=self.dropout_prob, bn=True
      )
      self.predict_layer = nn.Linear(in_feature_num, 1)
      self.reg_loss = RegLoss()
      self.sigmoid = nn.Sigmoid()
      self.loss = nn.BCEWithLogitsLoss()
  
      # parameters initialization
      self.apply(self._init_weights)
  
file_path: RecBole/recbole/model/context_aware_recommender/dcn.py
imports: import torch
  import torch.nn
  from torch.nn.init import xavier_normal_, constant_
  from recbole.model.abstract_recommender import ContextRecommender
  from recbole.model.layers import MLPLayers
  from recbole.model.loss import RegLoss
label_desc: Use image node_id 1 to create a new DCN object from inherited base classes: ContextRecommender with example: obj = DCN(config, dataset)