tf_function function

Creates a callable TensorFlow graph from an R function.

Creates a callable TensorFlow graph from an R function.

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.

tf_function(f, input_signature = NULL, autograph = TRUE, ...)

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: TRUE or FALSE. If TRUE (the default), you can use tensors in R control flow expressions if, while, for and break and they will be traced into the tensorflow graph. A guide to getting started and additional details can be found: here
  • ...: additional arguments passed on to tf.function (vary based on Tensorflow version). See here for details.

Details

A guide to getting started with list("tf.function") can be found here.

  • Maintainer: Tomasz Kalinowski
  • License: Apache License 2.0
  • Last published: 2024-04-15