R/gdepoch.R

Defines functions gdepoch

Documented in gdepoch

#' gdepoch
#'
#' @keywords internal
#'
#' @description Run a gradient descent epoch (L and R are starting points,
#' gamma is stgammaize)
#'
#' @return a list containing two matrices generated by the gradient descent for
#' the current epoch
gdepoch <- function(L, R, lambda, gamma, is, js, D,
                    error_matrix = NULL) {
  if (is.null(error_matrix)) {
    error_matrix <- (D - L %*% R)
  }

  locLoss <- localLoss(L, R, is, js, error_matrix)

  ## perform a gradient step on L and R with step size gamma
  ## by using the gradient matrices


  L <- L + gamma * 2 * (locLoss$dL - lambda * L)
  R <- R + gamma * 2 * (locLoss$dR - lambda * R)



  ## return result
  return(list(L = L, R = R))
}

Try the BEclear package in your browser

Any scripts or data that you put into this service are public.

BEclear documentation built on Nov. 8, 2020, 8:07 p.m.