pyrates.backend.tensorflow module

Tensorflow backend. Contains all tensorflow-based internal function definitions and links to tensorflow functions.

pyrates.backend.tensorflow.tensorflow_backend module

Wraps tensorflow such that it’s low-level functions can be used by PyRates to create and simulate a compute graph.

class pyrates.backend.tensorflow.tensorflow_backend.TensorflowBackend(ops: Optional[Dict[str, str]] = None, imports: Optional[List[str]] = None, **kwargs)[source]

Bases: pyrates.backend.base.base_backend.BaseBackend

Wrapper to tensorflow. This class provides an interface to all tensorflow functionalities that may be accessed via pyrates. All tensorflow variables and operations will be stored in a layered compute graph that can be executed to evaluate the (dynamic) behavior of the graph.

  • ops

    Additional operations this backend instance can perform, defined as key-value pairs. The key can then be used in every equation parsed into this backend. The value is a dictionary again, with two keys:

    1. name - the name of the function/operation (used during code generation)

    2) call - the call signature of the function including import abbreviations (i.e. tf.add for tensorflow’s add function)

  • dtypes – Additional data-types this backend instance can use, defined as key-value pairs.
  • name – Name of the backend instance. Used during code generation to create a recognizable file structure.
  • float_default_type – Default float precision. If no data-type is indicated for a particular variable, this will be used.
  • imports – Can be used to pass additional import statements that are needed for code generation of the custom functions provided via ops. Will be added to the top of each generated code file.
add_var_update(lhs: pyrates.backend.computegraph.ComputeVar, rhs: str, lhs_idx: Optional[str] = None, rhs_shape: Optional[tuple] = ())[source]
create_index_str(idx: Union[str, int, tuple], separator: str = ',', apply: bool = True, scatter: bool = False, size: Optional[int] = 1, max_length: int = 2) → Tuple[str, dict][source]
finalize_idx_str(var: pyrates.backend.computegraph.ComputeVar, idx: str)[source]
get_var(v: pyrates.backend.computegraph.ComputeVar)[source]

pyrates.backend.tensorflow.tensorflow_funcs module

Contains tensorflow function definitions that may be used for PyRates model equations.