From 172894492e6bf8b14489dc47a3912164ae15f786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20Batardi=C3=A8re?= <71976811+Bastien-mva@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:12:31 +0200 Subject: [PATCH 1/2] More accurate message when torch is diverging. --- R/PLNfit-class.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/PLNfit-class.R b/R/PLNfit-class.R index 44e071a4..fde22be9 100644 --- a/R/PLNfit-class.R +++ b/R/PLNfit-class.R @@ -146,7 +146,7 @@ PLNfit <- R6Class( ## Error message if objective diverges if (!is.finite(loss$item())) { - stop(sprintf("The ELBO diverged during the optimization procedure.\nConsider using:\n* a different optimizer (current optimizer: %s)\n* a smaller learning rate (current rate: %.3f)\nwith `control = PLN_param(config_optim = list(algorithm = ..., lr = ...))`", + stop(sprintf("The ELBO diverged during the optimization procedure.\nConsider using:\n* a different optimizer (current optimizer: %s)\n* a smaller learning rate (current rate: %.3f)\nwith `control = PLN_param(backend = "torch", config_optim = list(algorithm = ..., lr = ...))`", config$algorithm, config$lr)) } From 8cb8019891ff46f27be00430a55e5c8e280c1bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20Batardi=C3=A8re?= <71976811+Bastien-mva@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:21:07 +0200 Subject: [PATCH 2/2] used ' instead of " --- R/PLNfit-class.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/PLNfit-class.R b/R/PLNfit-class.R index fde22be9..86bd6d46 100644 --- a/R/PLNfit-class.R +++ b/R/PLNfit-class.R @@ -146,7 +146,7 @@ PLNfit <- R6Class( ## Error message if objective diverges if (!is.finite(loss$item())) { - stop(sprintf("The ELBO diverged during the optimization procedure.\nConsider using:\n* a different optimizer (current optimizer: %s)\n* a smaller learning rate (current rate: %.3f)\nwith `control = PLN_param(backend = "torch", config_optim = list(algorithm = ..., lr = ...))`", + stop(sprintf("The ELBO diverged during the optimization procedure.\nConsider using:\n* a different optimizer (current optimizer: %s)\n* a smaller learning rate (current rate: %.3f)\nwith `control = PLN_param(backend = 'torch', config_optim = list(algorithm = ..., lr = ...))`", config$algorithm, config$lr)) }