Description Usage Arguments Value Examples
View source: R/tf-ctrl-flow-wrappers.R
This is a minimal wrapper around tf.case()
that allows you to supply the
pred_fn_pairs
using the ~
.
1 2 3 4 5 6 7 |
..., pred_fn_pairs |
a list |
default |
a function, optionally specified with the |
exclusive |
bool, whether to evaluate all |
name |
a string, passed on to |
The result from tf$case()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
fizz_buzz_one <- function(x) {
tf_case(
x %% 15 == 0 ~ "FizzBuzz",
x %% 5 == 0 ~ "Buzz",
x %% 3 == 0 ~ "Fizz",
default = ~ tf$as_string(x, precision = 0L)
)
}
fn <- tf_function(autograph(function(n) {
for(e in tf$range(n))
tf$print(fizz_buzz_one(e))
}))
x <- tf$constant(16)
fn(x)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.