Skip to content

Commit 15a3b94

Browse files
author
Sigrid Keydana
authored
Merge pull request #681 from kevinykuo/bugfix/tfkeras-backend
Fix k_set_epsilon() and k_set_floatx() for tensorflow
2 parents 9ebc193 + 3e5c592 commit 15a3b94

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: keras
22
Type: Package
33
Title: R Interface to 'Keras'
4-
Version: 2.2.4.9000
4+
Version: 2.2.4.9001
55
Authors@R: c(
66
person("JJ", "Allaire", role = c("aut", "cre"), email = "[email protected]"),
77
person("François", "Chollet", role = c("aut", "cph")),

R/backend.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -867,9 +867,7 @@ k_epsilon <- function() {
867867
#' @rdname k_epsilon
868868
#' @export
869869
k_set_epsilon <- function(e) {
870-
keras$backend$set_epsilon(
871-
e = e
872-
)
870+
keras$backend$set_epsilon(e)
873871
}
874872

875873

@@ -994,9 +992,7 @@ k_floatx <- function() {
994992
#' @rdname k_floatx
995993
#' @export
996994
k_set_floatx <- function(floatx) {
997-
keras$backend$set_floatx(
998-
floatx = floatx
999-
)
995+
keras$backend$set_floatx(floatx)
1000996
}
1001997

1002998

tests/testthat/test-backend.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,20 @@ test_backend("k_concatenate", {
115115
k_concatenate(list(x, y), 1)
116116
})
117117

118+
test_backend("k_set_floatx", {
119+
skip_if_cntk()
120+
skip_if_theano()
121+
k_set_floatx("float16")
122+
expect_identical(k_floatx(), "float16")
123+
k_set_floatx("float32")
124+
expect_identical(k_floatx(), "float32")
125+
})
126+
127+
test_backend("k_set_epsilon", {
128+
skip_if_cntk()
129+
skip_if_theano()
130+
k_set_epsilon(1e-4)
131+
expect_equal(k_epsilon(), 1e-4)
132+
k_set_epsilon(1e-07)
133+
expect_equal(k_epsilon(), 1e-07)
134+
})

0 commit comments

Comments
 (0)