Skip to content

Commit 5c7062f

Browse files
authored
Merge pull request #361 from t-kalinowski/patch-1
use_compat() in v1 and v2 too
2 parents 1102ce9 + 46a86ba commit 5c7062f

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

R/compat.R

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
#' with previous versions. For instance, this is useful to run TensorFlow 1.x
66
#' code when using TensorFlow 2.x.
77
#'
8-
#' @inheritParams reticulate py_set_seed
9-
#'
10-
#' @param version The version to activate.
8+
#' @param version The version to activate. Must be `"v1"` or `"v2"`
119
#'
1210
#' @examples
1311
#' \dontrun{
@@ -16,17 +14,13 @@
1614
#' }
1715
#'
1816
#' @export
19-
use_compat <- function(version = c("v1")) {
20-
if (identical(tf_version(), NULL) || tf_version() < "2.0") return()
17+
use_compat <- function(version = c("v1", "v2")) {
18+
if (identical(tf_version(), NULL)) return()
2119

22-
# validate method
2320
version <- match.arg(version)
2421

2522
tf2 <- tf
2623

27-
# disable eager execution to match v1 default
28-
tf2$compat$v1$disable_eager_execution()
29-
3024
unlock <- get("unlockBinding")
3125
lock <- get("lockBinding")
3226

0 commit comments

Comments
 (0)