Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tf_function

Creates a callable TensorFlow graph from an R function.


Description

tf_function constructs a callable that executes a TensorFlow graph created by tracing the TensorFlow operations in f. This allows the TensorFlow runtime to apply optimizations and exploit parallelism in the computation defined by f.

Usage

tf_function(
  f,
  input_signature = NULL,
  autograph = FALSE,
  experimental_autograph_options = NULL
)

Arguments

f

the function to be compiled

input_signature

A possibly nested sequence of tf$TensorSpec objects specifying the shapes and dtypes of the tensors that will be supplied to this function. If NULL, a separate function is instantiated for each inferred input signature. If input_signature is specified, every input to f must be a tensor.

autograph

Whether autograph should be applied on f before tracing a graph. This allows for dynamic control flow (if's, loops etc.) in the traced graph. See https://www.tensorflow.org/guide/autograph for more information. Note: We set the default to FALSE until this functionality is available from R.

experimental_autograph_options

Experimental knobs (in the form of a tuple of tf$autograph$Feature values) to control behavior when autograph = TRUE.


tensorflow

R Interface to 'TensorFlow'

v2.4.0
Apache License 2.0
Authors
Daniel Falbel [ctb, cph, cre], JJ Allaire [aut, cph], RStudio [cph, fnd], Yuan Tang [aut, cph] (<https://orcid.org/0000-0001-5243-233X>), Dirk Eddelbuettel [ctb, cph], Nick Golding [ctb, cph], Tomasz Kalinowski [ctb, cph], Google Inc. [ctb, cph] (Examples and Tutorials)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.