diff --git a/DESCRIPTION b/DESCRIPTION index 03626df..f76e3f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: DeepPatientLevelPrediction Type: Package Title: Deep Learning For Patient Level Prediction Using Data In The OMOP Common Data Model -Version: 1.1.4 +Version: 1.1.5 Date: 18-04-2023 Authors@R: c( person("Egill", "Fridgeirsson", email = "e.fridgeirsson@erasmusmc.nl", role = c("aut", "cre")), diff --git a/NEWS.md b/NEWS.md index 8202096..fa7b721 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +DeepPatientLevelPrediction 1.1.5 +====================== + - Fix bug where device function was not working for LRFinder + DeepPatientLevelPrediction 1.1.4 ====================== - Remove torchopt dependancy since adamw is now in torch diff --git a/R/LRFinder.R b/R/LRFinder.R index 2ef7d8c..9f670e4 100644 --- a/R/LRFinder.R +++ b/R/LRFinder.R @@ -78,7 +78,7 @@ lrFinder <- function(dataset, modelType, modelParams, estimatorSettings, optimizer$zero_grad() batch <- dataset[sample(batchIndex, estimatorSettings$batchSize)] - batch <- batchToDevice(batch, device=estimatorSettings$device) + batch <- batchToDevice(batch, device=device) output <- model(batch$batch) diff --git a/tests/testthat/test-LRFinder.R b/tests/testthat/test-LRFinder.R index 30bdc8d..f6c263e 100644 --- a/tests/testthat/test-LRFinder.R +++ b/tests/testthat/test-LRFinder.R @@ -39,6 +39,28 @@ test_that("LR finder works", { expect_true(lr<=10.0) expect_true(lr>=3e-4) +}) + +test_that("LR finder works with device specified by a function", { + + deviceFun <- function(){ + dev = "cpu" + } + lr <- lrFinder(dataset, modelType = ResNet, modelParams = list(catFeatures=dataset$numCatFeatures(), + numFeatures=dataset$numNumFeatures(), + sizeEmbedding=8, + sizeHidden=16, + numLayers=1, + hiddenFactor=1), + estimatorSettings = setEstimator(batchSize=32, + seed = 42, + device = deviceFun), + minLR = 3e-4, + maxLR = 10.0, + numLR = 20, + divergenceThreshold = 1.1) + expect_true(lr<=10.0) + expect_true(lr>=3e-4) }) \ No newline at end of file