From 681e5c1a6a260656e5446afd39778fc21746019c Mon Sep 17 00:00:00 2001 From: Eric Weine Date: Thu, 1 Aug 2024 11:57:20 -0500 Subject: [PATCH] made code more memory efficient --- R/fit.R | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/R/fit.R b/R/fit.R index 5664ebc..66102a3 100644 --- a/R/fit.R +++ b/R/fit.R @@ -263,13 +263,10 @@ fit_glmpca_pois <- function( update_indices_f <- sort(setdiff(1:K,fixed_f)) - FF_to_update <- FF_test - #browser() - # now, I just need to project the results back update_factors_faster_parallel( L_T = t(res$fit$LL), - FF = FF_to_update, + FF = FF_test, M = as.matrix(res$fit$LL[update_indices_f,,drop = FALSE] %*% Y_test), update_indices = update_indices_f - 1, num_iter = 1000, @@ -280,7 +277,7 @@ fit_glmpca_pois <- function( # now, I need to reconstruct FF, and hopefully compute the log-likelihood FF[, train_idx] <- res$fit$FF - FF[, test_idx] <- FF_to_update + FF[, test_idx] <- FF_test res$fit$FF <- FF if (inherits(Y,"sparseMatrix")) { @@ -291,7 +288,7 @@ fit_glmpca_pois <- function( loglik_func <- lik_glmpca_pois_log } - test_loglik <- loglik_func(Y_test,res$fit$LL,FF_to_update,test_loglik_const) + test_loglik <- loglik_func(Y_test,res$fit$LL,FF_test,test_loglik_const) res$loglik <- res$loglik + test_loglik }