TensorFlow Generator¶
This module defines the TFGenerator class that generates TF code for neural networks based on the B-UML model.
-
class besser.generators.nn.tf.tf_code_generator.TFGenerator(model: NN, output_dir: str | None =
None, generation_type: str ='subclassing', strip_layer_counter_suffix: bool =False, validate_graph_structure: bool =True)[source]¶ Bases:
NNCodeGeneratorTFGenerator is a class that inherits from NNCodeGenerator. It generates TF code for neural networks training and evaluation based on the B-UML input model.
- Parameters:¶
model (NN) – An instance of the NN Model class representing the B-UML model.
setup_layer (SetupLayerSyntax) – The class that defines the syntax of layers.
setup_tensorop (Callable) – The function that defines the syntax of tensorops.
output_dir (str, optional) – The output directory where the generated code will be saved. Defaults to None.
file_name (str) – The name of the file where the generated code is stored.
template_dir (str) – The name of the jinja template directory.
generation_type (str) – ‘subclassing’ or ‘sequential’.
-
regenerable =
True¶
- _wrap_in_lambda(syntax)[source]¶
Keras
Sequentialonly acceptskeras.Layerinstances, so a tensor-op expression must be wrapped inlayers.Lambda— a bare Python lambda raises at model construction. Mirrors the PyTorch override, which wraps in its generatedLambda(nn.Module).
- _cleanup_lambda_syntax(module, syntax, prev_out_var)[source]¶
TensorFlow-specific variable extraction, mapping, and cleanup.
-
_abc_impl =
<_abc._abc_data object>¶