• get_block_instance(): Try to create a block instance from the given code and an iterable of block candidates.
emloop_tensorflow.models.blocks.get_block_instance(code, blocks, block_kwargs=None)[source]

Try to create a block instance from the given code and an iterable of block candidates.


UnrecognizedCodeError – if none of the block candidates can parse the given code

Return type:

Tuple[Block, Type[Block]]


a tuple of (block instance, block type)


  • Block: Base emloop-tensorflow block concept.
  • BaseBlock: Base emloop-tensorflow block.
class emloop_tensorflow.models.blocks.Block(code, **kwargs)[source]

Bases: object

Base emloop-tensorflow block concept.

A block shall be configurable from a single string (code) and provide apply() method which takes and returns a single tensor.

Inheritance diagram of Block

__init__(code, **kwargs)[source]

Create new Block from the given code.

Parameters:code (str) – short human-readable code for block parametrization

Apply the block to the given tensor.

Parameters:x (Tensor) – Input tensor
Return type:Tensor
Returns:Output tensor

Get code for the inverse block.

Return type:str
class emloop_tensorflow.models.blocks.BaseBlock(code, regexp, defaults=None, **kwargs)[source]

Bases: emloop_tensorflow.models.blocks.Block

Base emloop-tensorflow block.

Inheritance diagram of BaseBlock

__init__(code, regexp, defaults=None, **kwargs)[source]

Try to parse and create new BaseBlock using the following procedure:

  1. try to match the given regexp to the given code (raise UnrecognizedCodeError if it fails)
  2. pass the matched groups to the _handle_parsed_args() method (must be overridden)
  • code (str) – block configuration code
  • regexp (str) – regular expression to be matched to the code
  • defaults (Optional[Tuple[Optional[Any]]]) – (in-order) default arguments for each of the regexp groups (optional)

UnrecognizedCodeError – if the given regexp can not be matched to the given code


Handle (most likely save) the arguments matched with the regexp in the code.

Parameters:args – parsed arguments
Return type:None


exception emloop_tensorflow.models.blocks.UnrecognizedCodeError[source]


Inheritance diagram of UnrecognizedCodeError