Skip to content

Commit

Permalink
Fixed CPU utilisation for NNs with neural_networks_seed = NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
ebecht committed Nov 1, 2019
1 parent 731a1b3 commit 908c139
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: infinityFlow
Title: Augmenting cytometry using massively parallel multivariate non-linear regressions
Version: 0.1.1
Version: 0.1.2
Authors@R: c(
person("Etienne","Becht",middle=NULL,email="[email protected]",role=c("cre","aut"))
)
Expand Down
12 changes: 12 additions & 0 deletions R/04_regression_all.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ fit_regressions=function(
library(glmnet)
if(!is.null(neural_networks_seed)){
use_session_with_seed(neural_networks_seed) ## This will make results reproducible, disable GPU and CPU parallelism (which is good actually). Source: https://keras.rstudio.com/articles/faq.html#how-can-i-obtain-reproducible-results-using-keras-during-development
} else {
config <- list()
config$intra_op_parallelism_threads <- 1L
config$inter_op_parallelism_threads <- 1L
session_conf <- do.call(tf$ConfigProto, config)
sess <- tf$Session(graph = tf$get_default_graph(), config = session_conf)
}
}
)
Expand Down Expand Up @@ -321,6 +327,12 @@ predict_from_models=function(
xp=xp[,make.names(chans)]
if(!is.null(neural_networks_seed)){
use_session_with_seed(neural_networks_seed) ## This will make results reproducible, disable GPU and CPU parallelism (which is good actually). Source: https://keras.rstudio.com/articles/faq.html#how-can-i-obtain-reproducible-results-using-keras-during-development
} else {
config <- list()
config$intra_op_parallelism_threads <- 1L
config$inter_op_parallelism_threads <- 1L
session_conf <- do.call(tf$ConfigProto, config)
sess <- tf$Session(graph = tf$get_default_graph(), config = session_conf)
}
}
))
Expand Down

0 comments on commit 908c139

Please sign in to comment.