Skip to content

Commit

Permalink
A few minor fixes to the stopping conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarbo committed Mar 18, 2024
1 parent bfb747f commit fd4acb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Encoding: UTF-8
Type: Package
Package: fastTopics
Version: 0.6-168
Version: 0.6-169
Date: 2024-03-18
Title: Fast Algorithms for Fitting Topic Models and Non-Negative
Matrix Factorizations to Count Data
Expand Down
19 changes: 12 additions & 7 deletions R/fit_poisson_nmf.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@
#' updates is less than \code{min.delta.loglik}. This should not be
#' kept at zero when \code{control$extrapolate = TRUE} because the
#' extrapolated updates are expected to occasionally keep the
#' likelihood unchanged.}
#' likelihood unchanged. Ignored if \code{min.delta.loglik < 0}.}
#'
#' \item{\code{min.res}}{Stop performing updates if the maximum KKT
#' residual is less than \code{min.res}.}
#' residual is less than \code{min.res}. Ignored if \code{min.res < 0}.}
#'
#' \item{\code{minval}}{A small, positive constant used to safeguard
#' the multiplicative updates. The safeguarded updates are implemented
Expand Down Expand Up @@ -440,7 +440,7 @@ fit_poisson_nmf <- function (X, k, fit0, numiter = 100,
cat(sprintf("Running at most %d %s updates, %s extrapolation ",
numiter,method.text,
ifelse(control$extrapolate,"with","without")))
cat("(fastTopics 0.6-168).\n")
cat("(fastTopics 0.6-169).\n")
}

# INITIALIZE ESTIMATES
Expand Down Expand Up @@ -553,11 +553,16 @@ fit_poisson_nmf_main_loop <- function (X, fit, numiter, update.factors,
progress[i,"res"],progress[i,"delta.f"],
progress[i,"delta.l"],progress[i,"nonzeros.f"],
progress[i,"nonzeros.l"],extrapolate * progress[i,"beta"]))
if (res < control$min.res) {
if (control$min.res >= 0 & res < control$min.res) {
if (verbose == "progressbar")
pb$terminate()
cat("Stopping condition is satisfied: ")
cat(sprintf("maximum KKT residual < %0.2e\n",control$min.res))
break
} else if (loglik.diff < control$min.delta.loglik) {
} else if (control$min.delta.loglik >= 0 &
loglik.diff < control$min.delta.loglik) {
if (verbose == "progressbar")
pb$terminate()
cat("Stopping condition is satisfied: ")
cat(sprintf("change in Poisson NMF loglik < %0.2e\n",
control$min.delta.loglik))
Expand Down Expand Up @@ -780,8 +785,8 @@ safeguard.fit <- function (fit, minval) {
fit_poisson_nmf_control_default <- function()
list(numiter = 4,
init.numiter = 10,
min.delta.loglik = 0,
min.res = 0,
min.delta.loglik = -1,
min.res = -1,
minval = 1e-10,
eps = 1e-8,
zero.threshold = 1e-6,
Expand Down

0 comments on commit fd4acb4

Please sign in to comment.