class_docstr: DCNV2 improves the cross network by extending the original weight vector to a matrix,
  significantly improves the expressiveness of DCN. It also introduces the MoE and
  low rank techniques to reduce time cost.
class_docstr_tok: ["DCNV2","improves","the","cross","network","by","extending","the","original","weight","vector","to","a","matrix",",","significantly","improves","the","expressiveness","of","DCN",".","It","also","introduces","the","MoE","and","low","rank","techniques","to","reduce","time","cost","."]
code: def __init__(self, config, dataset):
      super(DCNV2, self).__init__(config, dataset)
  
      # load and compute parameters info
      self.mixed = config["mixed"]
      self.structure = config["structure"]
      self.cross_layer_num = config["cross_layer_num"]
      self.embedding_size = config["embedding_size"]
      self.mlp_hidden_size = config["mlp_hidden_size"]
      self.reg_weight = config["reg_weight"]
      self.dropout_prob = config["dropout_prob"]
  
      if self.mixed:
          self.expert_num = config["expert_num"]
          self.low_rank = config["low_rank"]
  
      self.in_feature_num = self.num_feature_field * self.embedding_size
  
      # define cross layers and bias
      if self.mixed:
          # U: (in_feature_num, low_rank)
          self.cross_layer_u = nn.ParameterList(
              nn.Parameter(
                  torch.randn(
                      self.expert_num,
                      self.in_feature_num,
                      self.low_rank,
                  )
              )
              for _ in range(self.cross_layer_num)
          )
          # V: (in_feature_num, low_rank)
          self.cross_layer_v = nn.ParameterList(
              nn.Parameter(
                  torch.randn(
                      self.expert_num,
                      self.in_feature_num,
                      self.low_rank,
                  )
              )
              for _ in range(self.cross_layer_num)
          )
          # C: (low_rank, low_rank)
          self.cross_layer_c = nn.ParameterList(
              nn.Parameter(
                  torch.randn(
                      self.expert_num, self.low_rank, self.low_rank
                  )
              )
              for _ in range(self.cross_layer_num)
          )
          self.gating = nn.ModuleList(
              nn.Linear(self.in_feature_num, 1)
              for _ in range(self.expert_num)
          )
      else:
          # W: (in_feature_num, in_feature_num)
          self.cross_layer_w = nn.ParameterList(
              nn.Parameter(
                  torch.randn(self.in_feature_num, self.in_feature_num)
              )
              for _ in range(self.cross_layer_num)
          )
      # bias: (in_feature_num, 1)
      self.bias = nn.ParameterList(
          nn.Parameter(torch.zeros(self.in_feature_num, 1))
          for _ in range(self.cross_layer_num)
      )
  
      # define deep and predict layers
      mlp_size_list = [self.in_feature_num] + self.mlp_hidden_size
      self.mlp_layers = MLPLayers(
          mlp_size_list, dropout=self.dropout_prob, bn=True
      )
      if self.structure == "parallel":
          self.predict_layer = nn.Linear(
              self.in_feature_num + self.mlp_hidden_size[-1], 1
          )
      elif self.structure == "stacked":
          self.predict_layer = nn.Linear(self.mlp_hidden_size[-1], 1)
  
      # define loss and activation functions
      self.reg_loss = RegLoss()
      self.sigmoid = nn.Sigmoid()
      self.tanh = nn.Tanh()
      self.softmax = nn.Softmax(dim=1)
      self.loss = nn.BCELoss()
  
      # parameters initialization
      self.apply(xavier_normal_initialization)
  
file_path: RecBole/recbole/model/context_aware_recommender/dcnv2.py
imports: import torch
  import torch.nn
  from recbole.model.abstract_recommender import ContextRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.layers import MLPLayers
  from recbole.model.loss import RegLoss
label_desc: Use image node_id 1 to create a new DCNV2 object from inherited base classes: ContextRecommender with example: obj = DCNV2(config, dataset)