def init_parameter()

in sourcecode/scoring/reputation_matrix_factorization/reputation_matrix_factorization.py [0:0]


  def init_parameter(self, initDf, initCol, idKey, ratersOrNotes, device, defaultValue):
    if initDf is not None and initCol in initDf.columns:
      idToInitValue = dict(initDf[[idKey, initCol]].values)
      logger.info(f"Initializing {initCol}:")
      logger.info(
        f"  num in dataset: {ratersOrNotes.shape[0]}, vs. num we are initializing: {len(initDf)}"
      )
      paramWeightToInit = nn.Parameter(
        torch.tensor(
          [
            get_or_default_if_nan(lookupDict=idToInitValue, key=raterOrNoteId, default=defaultValue)
            for raterOrNoteId in ratersOrNotes
          ]
        )
        .to(torch.float32)
        .reshape(-1, 1)
        .to(device)
      )
      logger.info(f"  uninitialized {initCol}s: {(paramWeightToInit == 0).flatten().sum()}")
      logger.info(f"  initialized {initCol}s: {(paramWeightToInit != 0).flatten().sum()}")
      return paramWeightToInit
    else:
      logger.info(f"Not initializing {initCol}")
      return None