Description Usage Arguments Details Examples
The results of the computation are available right after the execution of a line of code.
If the return value is Tensor, it can be converted to base R object automatically if convert = TRUE
is specified. Users can also call tensor$eval()
to convert any Tensor objects inside the expr
scope to base R objects.
1 | tf_imperative(expr, new_step = FALSE, convert = TRUE)
|
expr |
A block of code expession |
new_step |
A boolean indicating whether the expression is evaluated as a new step.
A graph is constructed and kept around in the background, both for just executing using
the standard TensorFlow runtime, and also for allowing automatic differentiation via |
convert |
A boolean indicating whether to convert the returned Tensor object to base R object. |
Note that this function is currently only experimental, meaning that the interface is subject to change or remove at later releases.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
tf_imperative({
a <- tf$constant(list(list(7), list(6)))
b <- tf$constant(list(list(6, 7)))
list(
tf$matmul(a, b),
a * 4
)
})
# This is equivalent to the following:
tf <- tf$contrib$imperative
a <- tf$constant(list(list(7), list(6)))
b <- tf$constant(list(list(6, 7)))
res1 <- tf$matmul(a, b)
res2 <- a * 4
list(res1$eval(), res2$eval())
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.