PyRates.pyrates.backend.tensorflow 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: Dict[str, str] | None = None, imports: List[str] | None = None, **kwargs)[source]

Bases: 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: ComputeVar, rhs: str, lhs_idx: str | None = None, rhs_shape: tuple | None = ())[source]
create_index_str(idx: str | int | tuple, separator: str = ',', apply: bool = True, scatter: bool = False, size: int | None = 1, max_length: int = 2) Tuple[str, dict][source]
finalize_idx_str(var: ComputeVar, idx: str)[source]
get_var(v: ComputeVar)[source] pyrates.backend.tensorflow.tensorflow_funcs module

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