Neural Network model¶
This module defines the neural network metamodel.
-
besser.BUML.metamodel.nn.neural_network.ALLOWED_TENSOR_OP_TYPES : tuple[str, ...] =
('reshape', 'concatenate', 'multiply', 'matmultiply', 'permute', 'transpose', 'mean', 'max', 'squeeze', 'unsqueeze', 'binop_add', 'binop_subtract', 'binop_multiply', 'binop_divide', 'binop_floor_divide', 'subscript', 'shape_dim', 'normalize', 'repeat', 'interpolate', 'pad', 'dropout', 'zeros_like', 'split', 'identity')¶ The tensor operation types accepted by
TensorOp.tns_type.
-
class besser.BUML.metamodel.nn.neural_network.TensorOp(name: str, tns_type: str, concatenate_dim: int | None =
None, layers_of_tensors: list[str | float | int] | None =None, reshape_dim: list[int] | None =None, transpose_dim: list[int] | None =None, permute_dim: list[int] | None =None, input_reused: bool =False, *, reduce_dim: int | None =None, reduce_keepdims: bool =False, shape_dim: int | None =None, actual_vars: list[str] | None =None, subscript_indices: list[dict] | None =None, repeat_dim: list[int | str] | None =None, interpolate_size: tuple | None =None, interpolate_scale: float | None =None, interpolate_mode: str ='bilinear', pad_amount: list[list[int]] | None =None, pad_mode: str ='constant', pad_value: float =0.0, dropout_rate: float | None =None, dropout_training_aware: bool =True, split_dim: int =0, split_sizes: int | list[int] | None =None, permute_in: bool =False, permute_out: bool =False, input_var: str | None =None, output_var: str | None =None, output_vars: list[str] | None =None)[source]¶ Bases:
NamedElementThis class represents a tensor operation. It encapsulates attributes such as the name and the type of the tensor operation.
- Parameters:¶
name (str) – The name of the tensor operation.
tns_type (str) – The type of the tensor operation.
concatenate_dim (int) – The dimension along which the tensors will be concatenated. Only relevant for concatenate operation.
layers_of_tensors (list[str | float | int]) – The list that defines the inputs of the tensor op. Elements can be layer name strings or scalar values (float or int) for binary operations with constants. Passing Layer objects directly is not supported; use the layer name string instead.
reshape_dim (list[int]) – New shape for reshape operation.
transpose_dim (list[int]) – Transpose dimension specification. The transpose tensorop type swaps exactly 2 dimensions. Restricted to 3D tensors. For higher-dimensional permutations use ‘permute’ instead.
permute_dim (list[int]) – Desired ordering of dimensions for permute that performs a full arbitrary permutation over any number of dimensions.
reduce_dim (int) – Dimension for reduction operations like max or mean.
reduce_keepdims (bool) – Whether to keep dimensions after reduction.
shape_dim (int) – Dimension index to extract from shape.
input_reused (bool) – Whether input is reused by another operation.
actual_vars (list[str]) – Component type labels for each input in concatenate and binary operations. Each element is either “output” or “hidden”, indicating which component to reference from the corresponding layer. Used when layers have multiple output components (e.g., RNN layers with separate output and hidden states) to generate correct variable references during code generation.
subscript_indices (list[dict]) – A list of index or slice descriptors, one per dimension being subscripted. Each element is a dict with a required
"type"key that is either"index"or"slice". An"index"element requires a"value"key (int) representing a single position. A"slice"element accepts"start","stop", and"step"keys, each either an int orNone. For example, the subscript[:, -1, :]would be represented as:[{"type": "slice", "start": None, "stop": None, "step": None}, {"type": "index", "value": -1}, {"type": "slice", "start": None, "stop": None, "step": None}]repeat_dim (list[int | str]) – Repetition counts for repeat operation. Each element specifies how many times to repeat along that dimension. Elements can be integers for fixed counts (e.g., 2, 3) or strings representing variable/tensorop names that evaluate to integers at runtime (e.g., ‘batch_size’, ‘n’).
interpolate_size (Tuple[int, …]) – Target dimensions for interpolation as tuple (H, W) or (D, H, W). Example: (224, 224) for 2D resize.
interpolate_scale (float) – Scale factor for interpolation.
interpolate_mode (str) – Interpolation mode. Valid values: ‘nearest’, ‘linear’, ‘bilinear’, ‘bicubic’, ‘trilinear’, ‘area’, ‘nearest-exact’, ‘lanczos3’, ‘lanczos5’, ‘gaussian’, ‘mitchellcubic’. Default: ‘bilinear’.
pad_amount (list[list[int]]) – Padding amounts as nested list. Each inner list contains [before, after] padding for one dimension. Example: [[1, 1], [2, 2]] pads first dim by 1 on each side, second dim by 2.
pad_mode (str) – Padding mode like ‘constant’, ‘reflect’, or ‘replicate’.
pad_value (float) – Value for constant padding (default 0).
dropout_rate (float) – Dropout probability, range [0.0, 1.0]. Default: None.
dropout_training_aware (bool) – Whether dropout behavior changes between training and inference modes. Default: True.
split_dim (int) – Dimension along which to split (supports negative indexing). Default: 0.
split_sizes (int | list[int]) – Number of equal chunks (int) or size per chunk (list).
permute_in (bool) – Whether to permute input dimensions for spatial ops.
permute_out (bool) – Whether to permute output dimensions for spatial ops.
input_var (str) – Input variable name for this tensor operation.
output_var (str) – Output variable name for this tensor operation.
output_vars (list[str]) – Output variable names for multi-output operations (split/chunk).
- Attributes:¶
name (str) – The name of the tensor operation.
tns_type (str) – The type of the tensor operation.
concatenate_dim (int) – Concatenation dimension.
layers_of_tensors (list[str | float | int]) – The list that defines the inputs of the tensor op. Elements can be layer name strings or scalar values (float or int) for binary operations with constants. Passing Layer objects directly is not supported; use the layer name string instead.
reshape_dim (list[int]) – Reshape target shape.
transpose_dim (list[int]) – Transpose dimension specification. The transpose tensorop type swaps exactly 2 dimensions. Restricted to 3D tensors. For higher-dimensional permutations use ‘permute’ instead.
permute_dim (list[int]) – Desired ordering of dimensions for permute that performs a full arbitrary permutation over any number of dimensions.
reduce_dim (int) – Reduction dimension.
reduce_keepdims (bool) – Keep dimensions after reduction.
shape_dim (int) – Shape dimension to extract.
input_reused (bool) – Input reuse flag.
actual_vars (list[str]) – Component type labels (“output” or “hidden”) for each input. Used to select the correct component when layers have multiple outputs.
subscript_indices (list[dict]) – Subscript indices.
repeat_dim (list[int | str]) – Repetition counts for repeat operation. Each element specifies how many times to repeat along that dimension. Elements can be integers for fixed counts (e.g., 2, 3) or strings representing variable/tensorop names that evaluate to integers at runtime (e.g., ‘batch_size’, ‘n’).
interpolate_size (Tuple[int, …]) – Target dimensions as tuple.
interpolate_scale (float) – Interpolation scale.
interpolate_mode (str) – Interpolation mode. Default ‘bilinear’.
pad_amount (list[list[int]]) – Nested list of padding amounts per dimension.
pad_mode (str) – Padding mode (‘constant’, ‘reflect’, ‘replicate’).
pad_value (float) – Value for constant padding.
dropout_rate (float) – Dropout rate [0.0, 1.0]. Default: 0.5.
dropout_training_aware (bool) – Training-aware dropout. Default: False.
split_dim (int) – Split dimension (supports negative indexing). Default: 0.
split_sizes (int | list[int]) – Number of equal chunks (int) or size per chunk (list).
permute_in (bool) – Input permute flag.
permute_out (bool) – Output permute flag.
input_var (str) – Input variable name for this tensor operation.
output_var (str) – Output variable name for this tensor operation.
output_vars (list[str]) – Output variable names for multi-output operations (split/chunk).
- property concatenate_dim : int¶
Get the dimension along which the tensors will be concatenated with the cat operation.
- property layers_of_tensors : list[str | float | int]¶
Get the list that defines the inputs of the tensor op. Elements must be layer name strings or scalar values (float or int) for binary operations with constants. Passing Layer objects directly is not supported; use the layer name string instead.
- property reshape_dim : list[int]¶
Get the list specifying the new shape of the tensor after reshaping with the view operation.
- property permute_dim : list[int]¶
Get the list containing the desired ordering of dimensions for permute operation.
- property input_reused : bool¶
Get whether the input to this layer is reused as input to another layer.
- property actual_vars : list[str]¶
Get component type labels for each input. Returns a list of strings (“output” or “hidden”) indicating which component each input in layers_of_tensors refers to. Used by the code generator to emit correct variable references when layers have multiple output components (e.g., RNN layers with separate output and hidden states).
- property repeat_dim : list[int | str]¶
Get repetition counts for repeat operation. Each element specifies how many times to repeat along that dimension. Elements can be integers for fixed counts (e.g., 2, 3) or strings representing variable/tensorop names that evaluate to integers at runtime (e.g., ‘batch_size’, ‘n’).
- property interpolate_size¶
Get target size for interpolation.
- property pad_amount¶
Get padding amounts as nested list [[before, after], …] per dimension.
- property output_vars : list[str]¶
Get the output variable names for multi-output operations (split/chunk).
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.Layer(name: str, actv_func: str | None =
None, name_module_input: str | None =None, input_reused: bool =False, *, is_layer_call: bool =False, permute_in: bool =False, permute_out: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
NamedElementThis class represents a layer of the neural network. It encapsulates attributes such as the name of the layer and the activation function.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse). When True, the generator should NOT define this layer in __init__, only call it in forward/call.
permute_in (bool) – Whether to permute input dimensions before processing. Used for format conversions (e.g., NHWC to NCHW).
permute_out (bool) – Whether to permute output dimensions after processing. Used for format conversions (e.g., NCHW back to NHWC).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse). When True, the generator should NOT define this layer in __init__, only call it in forward/call.
permute_in (bool) – Whether to permute input dimensions before processing.
permute_out (bool) – Whether to permute output dimensions after processing.
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- property input_reused : bool¶
Get whether the input to this layer is reused as input to another layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.CNN(name: str, kernel_dim: list[int], stride_dim: list[int], padding_amount: int =
0, padding_type: str ='valid', actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, permute_in: bool =False, permute_out: bool =False, *, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
LayerRepresents a layer that is generally used in convolutional neural networks.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
kernel_dim (list[int]) – A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
padding_amount (int) – The amount of padding added to the input.
padding_type (str) – The type of padding applied to the input.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse). When True, the generator should NOT define this layer in __init__, only call it in forward/call.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
kernel_dim (list[int]) – A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
padding_amount (int) – The amount of padding added to the input.
padding_type (str) – The type of padding applied to the input.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.ConvolutionalLayer(name: str, kernel_dim: list[int], out_channels: int, stride_dim: list[int], in_channels: int | None =
None, padding_amount: int =0, padding_type: str ='valid', actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, permute_in: bool =False, permute_out: bool =False, *, dilation: list[int] | None =None, groups: int =1, bias: bool =True, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
CNNRepresents a convolutional layer.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
kernel_dim (list[int]) – A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
in_channels (int) – The number of channels in the input image.
out_channels (int) – The number of channels produced by the convolution.
padding_amount (int) – The amount of padding added to the input.
padding_type (str) – The type of padding applied to the input.
dilation (list[int]) – Spacing between kernel elements. Default is [1].
groups (int) – Number of blocked connections from input to output channels. Default is 1.
bias (bool) – If True, adds a learnable bias to the output. Default is True.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
kernel_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
in_channels (int) – The number of channels in the input image.
out_channels (int) – The number of channels produced by the convolution.
padding_amount (int) – Inherited from CNN. The amount of padding added to the input.
padding_type (str) – Inherited from CNN. The type of padding applied to the input.
dilation (list[int]) – Spacing between kernel elements.
groups (int) – Number of blocked connections from input to output channels.
bias (bool) – If True, adds a learnable bias to the output.
permute_in (bool) – Inherited from CNN. Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Inherited from CNN. Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.Conv1D(name: str, kernel_dim: list[int], out_channels: int, stride_dim: list[int] | None =
None, in_channels: int | None =None, padding_amount: int =0, padding_type: str ='valid', actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, permute_in: bool =False, permute_out: bool =False, *, dilation: list[int] | None =None, groups: int =1, bias: bool =True, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
ConvolutionalLayerRepresents a type of convolutional layer that applies a 1D convolution.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
kernel_dim (list[int]) – A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
in_channels (int) – The number of channels in the input image.
out_channels (int) – The number of channels produced by the convolution.
padding_amount (int) – The amount of padding added to the input.
padding_type (str) – The type of padding applied to the input.
dilation (list[int]) – Spacing between kernel elements. Default is [1].
groups (int) – Number of blocked connections from input to output channels. Default is 1.
bias (bool) – If True, adds a learnable bias to the output. Default is True.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
kernel_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
in_channels (int) – Inherited from ConvolutionalLayer. It represents the number of channels in the input image.
out_channels (int) – Inherited from ConvolutionalLayer. It represents the number of channels produced by the convolution.
padding_amount (int) – Inherited from CNN. It represents the amount of padding added to the input.
padding_type (str) – Inherited from CNN. It represents the type of padding applied to the input.
dilation (list[int]) – Inherited from ConvolutionalLayer. Spacing between kernel elements.
groups (int) – Inherited from ConvolutionalLayer. Number of blocked connections from input to output channels.
bias (bool) – Inherited from ConvolutionalLayer. If True, adds a learnable bias to the output.
permute_in (bool) – Inherited from CNN. Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Inherited from CNN. Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.Conv2D(name: str, kernel_dim: list[int], out_channels: int, stride_dim: list[int] | None =
None, in_channels: int | None =None, padding_amount: int =0, padding_type: str ='valid', actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, permute_in: bool =False, permute_out: bool =False, *, dilation: list[int] | None =None, groups: int =1, bias: bool =True, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
ConvolutionalLayerRepresents a type of convolutional layer that applies a 2D convolution.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
kernel_dim (list[int]) – A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
in_channels (int) – The number of channels in the input image.
out_channels (int) – The number of channels produced by the convolution.
padding_amount (int) – The amount of padding added to the input.
padding_type (str) – The type of padding applied to the input.
dilation (list[int]) – Spacing between kernel elements. Default is [1].
groups (int) – Number of blocked connections from input to output channels. Default is 1.
bias (bool) – If True, adds a learnable bias to the output. Default is True.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
kernel_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
in_channels (int) – Inherited from ConvolutionalLayer. It represents the number of channels in the input image.
out_channels (int) – Inherited from ConvolutionalLayer. It represents the number of channels produced by the convolution.
padding_amount (int) – Inherited from CNN. It represents the amount of padding added to the input.
padding_type (str) – Inherited from CNN. It represents the type of padding applied to the input.
dilation (list[int]) – Inherited from ConvolutionalLayer. Spacing between kernel elements.
groups (int) – Inherited from ConvolutionalLayer. Number of blocked connections from input to output channels.
bias (bool) – Inherited from ConvolutionalLayer. If True, adds a learnable bias to the output.
permute_in (bool) – Inherited from CNN. Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Inherited from CNN. Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.Conv3D(name: str, kernel_dim: list[int], out_channels: int, stride_dim: list[int] | None =
None, in_channels: int | None =None, padding_amount: int =0, padding_type: str ='valid', actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, permute_in: bool =False, permute_out: bool =False, *, dilation: list[int] | None =None, groups: int =1, bias: bool =True, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
ConvolutionalLayerRepresents a type of convolutional layer that applies a 3D convolution.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
kernel_dim (list[int]) – A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
in_channels (int) – The number of channels in the input image.
out_channels (int) – The number of channels produced by the convolution.
padding_amount (int) – The amount of padding added to the input.
padding_type (str) – The type of padding applied to the input.
dilation (list[int]) – Spacing between kernel elements. Default is [1].
groups (int) – Number of blocked connections from input to output channels. Default is 1.
bias (bool) – If True, adds a learnable bias to the output. Default is True.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
kernel_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
in_channels (int) – Inherited from ConvolutionalLayer. It represents the number of channels in the input image.
out_channels (int) – Inherited from ConvolutionalLayer. It represents the number of channels produced by the convolution.
padding_amount (int) – Inherited from CNN. It represents the amount of padding added to the input.
padding_type (str) – Inherited from CNN. It represents the type of padding applied to the input.
dilation (list[int]) – Inherited from ConvolutionalLayer. Spacing between kernel elements.
groups (int) – Inherited from ConvolutionalLayer. Number of blocked connections from input to output channels.
bias (bool) – Inherited from ConvolutionalLayer. If True, adds a learnable bias to the output.
permute_in (bool) – Inherited from CNN. Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Inherited from CNN. Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.PoolingLayer(name: str, pooling_type: str, dimension: str, kernel_dim: list[int] | None =
None, stride_dim: list[int] | None =None, padding_amount: int =0, padding_type: str ='valid', output_dim: list[int] | None =None, actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, permute_in: bool =False, permute_out: bool =False, *, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
CNNRepresents a type of layer that performs a pooling operation.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
dimension (str) – The dimensionality (1D, 2D, or 3D) of the pooling operation.
kernel_dim (list[int]) – A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
padding_amount (int) – The amount of padding added to the input.
padding_type (str) – The type of padding applied to the input.
pooling_type (str) – The type of pooling. Either average or max.
output_dim (list[int]) – The output dimensions of the adaptive pooling operation. Only relevant for adaptive pooling.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
dimension (str) – The dimensionality (1D, 2D, or 3D) of the pooling operation.
kernel_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).
stride_dim (list[int]) – Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).
padding_amount (int) – Inherited from CNN. It represents the amount of padding added to the input.
padding_type (str) – Inherited from CNN. It represents the type of padding applied to the input.
pooling_type (str) – The type of pooling. Either average or max.
output_dim (list[int]) – The output dimensions of the adaptive pooling operation. Only relevant for adaptive pooling.
permute_in (bool) – Inherited from CNN. Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Inherited from CNN. Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.LayerModifier(name: str, actv_func: str | None =
None, name_module_input: str | None =None, input_reused: bool =False, *, is_layer_call: bool =False, permute_in: bool =False, permute_out: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
Layer- Represents a type of layer that applies transformations or
adjustments to other layers, enhancing their behavior or performance.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.NormalizationLayer(name: str, *, eps: float =
1e-05, affine: bool =True, permute_in: bool =False, permute_out: bool =False, actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
LayerModifierRepresents a type of layer that applies normalization techniques.
- Parameters:¶
name (str) – The name of the layer.
eps (float) – Epsilon for numerical stability.
affine (bool) – Whether to learn affine parameters gamma/beta.
permute_in (bool) – Whether to permute input dimensions before processing.
permute_out (bool) – Whether to permute output dimensions after processing.
actv_func (str) – The type of the activation function.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
eps (float) – Epsilon value for numerical stability.
affine (bool) – Whether to learn affine parameters (gamma/beta).
permute_in (bool) – Inherited from Layer. Whether to permute input dimensions.
permute_out (bool) – Inherited from Layer. Whether to permute output dimensions.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.BatchNormLayer(name: str, num_features: int, dimension: str, actv_func: str | None =
None, name_module_input: str | None =None, input_reused: bool =False, *, eps: float =1e-05, momentum: float =0.1, affine: bool =True, track_running_stats: bool =True, permute_in: bool =False, permute_out: bool =False, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
NormalizationLayerRepresents a type of layer that normalizes inputs within mini-batches to maintain consistent mean and variance, enhancing training speed and stability.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
num_features (int) – The number of channels or features in each input sample.
dimension (str) – The dimensionality (1D, 2D, or 3D) of the input data to be normalized using batch normalization.
eps (float) – Epsilon for numerical stability.
momentum (float) – Momentum for running mean/variance.
affine (bool) – Whether to learn affine parameters gamma/beta.
track_running_stats (bool) – Whether to track running mean/variance.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
num_features (int) – The number of channels or features in each input sample.
dimension (str) – The dimensionality (1D, 2D, or 3D) of the input data to be normalized using batch normalization.
eps (float) – Inherited from NormalizationLayer. Epsilon value for numerical stability.
momentum (float) – Momentum for running mean/variance.
affine (bool) – Inherited from NormalizationLayer. Whether to learn affine parameters (gamma/beta).
track_running_stats (bool) – Whether to track running mean/variance.
permute_in (bool) – Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
permute_out (bool) – Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.LayerNormLayer(name: str, normalized_shape: list[int], actv_func: str | None =
None, name_module_input: str | None =None, input_reused: bool =False, *, eps: float =1e-05, affine: bool =True, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
NormalizationLayerRepresents a type of layer that normalizes the inputs across the features of a single data sample, rather than across the batch, to stabilize and accelerate training by reducing internal covariate shift.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
normalized_shape (list[int]) – A list of integers specifying the shape of the trailing dimensions over which layer normalization is applied. These correspond to the last N dimensions of the input tensor.
eps (float) – Epsilon for numerical stability.
affine (bool) – Whether to learn affine parameters gamma/beta.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
normalized_shape (list[int]) – A list of integers specifying the shape of the trailing dimensions over which layer normalization is applied. These correspond to the last N dimensions of the input tensor.
eps (float) – Inherited from NormalizationLayer. Epsilon value for numerical stability.
affine (bool) – Inherited from NormalizationLayer. Whether to learn affine parameters (gamma/beta).
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
- property normalized_shape : list[int]¶
Get the list containing the dimensions or axis indices over which layer normalization is applied.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.DropoutLayer(name: str, rate: float, name_module_input: str | None =
None, input_reused: bool =False, *, dimension: str | None =None, permute_in: bool =False, permute_out: bool =False, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
LayerModifierRepresents a type of layer that randomly sets a fraction of input units to zero during training to prevent overfitting and improve generalization.
- Parameters:¶
name (str) – The name of the layer.
rate (float) – It represents a float between 0 and 1. Fraction of the input units to drop.
dimension (str | None) – The dimensionality for spatial dropout (‘1’, ‘2’, ‘3’). None for regular element-wise dropout.
permute_in (bool) – Whether to permute input dimensions before processing.
permute_out (bool) – Whether to permute output dimensions after processing.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
rate (float) – It represents a float between 0 and 1. Fraction of the input units to drop.
dimension (str | None) – The dimensionality for spatial dropout.
permute_in (bool) – Inherited from Layer. Whether to permute input dimensions.
permute_out (bool) – Inherited from Layer. Whether to permute output dimensions.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.RNN(name: str, hidden_size: int, return_type: str =
'full', input_size: int | None =None, bidirectional: bool =False, dropout: float =0.0, batch_first: bool =True, actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, *, bias: bool =True, hx_source: str | None =None, is_layer_call: bool =False, hidden_state_var: str | None =None, cell_state_var: str | None =None, hidden_unused: bool =False, cell_unused: bool =False, hidden_subscript_source: str | None =None, hidden_subscript_target: str | None =None, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
LayerRepresents a type of layer used in recurrent neural networks (RNN) for processing sequential data by using memory from previous steps to inform current outputs.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
input_size (int) – It represents the dimensionality of the input features.
hidden_size (int) – It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.
bidirectional (bool) – Whether the layer is bidirectional or not.
dropout (float) – If non-zero, it introduces a Dropout layer on the outputs of the current sub layers except the last one.
batch_first (bool) – If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.
bias (bool) – If True, the layer uses bias weights. Default is True.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
return_type (str) – Whether to return the hidden states, the last output in the output sequence or the full sequence.
hx_source (str) – The name of the source layer for initial hidden state (used in encoder-decoder architectures).
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
hidden_state_var (str) – Variable name for hidden state output.
cell_state_var (str) – Variable name for cell state output (LSTM only).
hidden_unused (bool) – Whether hidden state output is unused by subsequent layers.
cell_unused (bool) – Whether cell state output is unused by subsequent layers (LSTM only).
hidden_subscript_source (str) – Source variable for hidden subscript assignment (e.g., ‘h’ in ‘x = h’).
hidden_subscript_target (str) – Target variable for hidden subscript assignment (e.g., ‘x’ in ‘x = h’).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
input_size (int) – It represents the dimensionality of the input features.
hidden_size (int) – It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.
bidirectional (bool) – Whether the layer is bidirectional or not.
dropout (float) – If non-zero, it introduces a Dropout layer on the outputs of the current sub layers except the last one.
batch_first (bool) – If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.
bias (bool) – If True, the layer uses bias weights.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
return_type (str) – Whether to return the hidden states, the last output in the output sequence or the full sequence.
hx_source (str) – The name of the source layer for initial hidden state.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
hidden_state_var (str) – Variable name for hidden state output.
cell_state_var (str) – Variable name for cell state output (LSTM only).
hidden_unused (bool) – Whether hidden state output is unused by subsequent layers.
cell_unused (bool) – Whether cell state output is unused by subsequent layers (LSTM only).
hidden_subscript_source (str) – Source variable for hidden subscript assignment (e.g., ‘h’ in ‘x = h’).
hidden_subscript_target (str) – Target variable for hidden subscript assignment (e.g., ‘x’ in ‘x = h’).
-
_abc_impl =
<_abc._abc_data object>¶
Get the number of units in the hidden state.
- property batch_first : bool¶
Get whether the input and output tensors are provided as (batch, seq, feature).
- property return_type : str¶
Whether to return the hidden states, the last output in the output sequence, the full sequence, or both output and hidden.
Get the variable name for hidden state output.
Get whether hidden state output is unused by subsequent layers.
- property cell_unused : bool¶
Get whether cell state output is unused by subsequent layers (LSTM only).
Get the source variable for hidden subscript assignment.
Get the target variable for hidden subscript assignment.
-
class besser.BUML.metamodel.nn.neural_network.SimpleRNNLayer(name: str, hidden_size: int, return_type: str =
'full', input_size: int | None =None, bidirectional: bool =False, dropout: float =0.0, batch_first: bool =True, actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, *, bias: bool =True, hx_source: str | None =None, is_layer_call: bool =False, hidden_state_var: str | None =None, cell_state_var: str | None =None, hidden_unused: bool =False, cell_unused: bool =False, hidden_subscript_source: str | None =None, hidden_subscript_target: str | None =None, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
RNNRepresents a fully-connected RNN layer where the output is to be fed back as the new input.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
input_size (int) – It represents the dimensionality of the input features.
hidden_size (int) – It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.
bidirectional (bool) – Whether the layer is bidirectional or not.
dropout (float) – If non-zero, it introduces a Dropout layer on the outputs of the RNN sub layers except the last one.
batch_first (bool) – If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.
bias (bool) – If True, the layer uses bias weights. Default is True.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
return_type (str) – Whether to return the hidden states, the last output in the output sequence or the full sequence.
hx_source (str) – The name of the source layer for initial hidden state.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
hidden_state_var (str) – Variable name for hidden state output.
hidden_unused (bool) – Whether hidden state output is unused.
hidden_subscript_source (str) – Source variable for hidden subscript assignment.
hidden_subscript_target (str) – Target variable for hidden subscript assignment.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
input_size (int) – Inherited from RNN. It represents the dimensionality of the input features.
hidden_size (int) – Inherited from RNN. It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.
bidirectional (bool) – Inherited from RNN. Whether the layer is bidirectional or not.
dropout (float) – Inherited from RNN. If non-zero, it introduces a Dropout layer on the outputs of the RNN sub layers except the last one.
batch_first (bool) – Inherited from RNN. If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.
bias (bool) – Inherited from RNN. If True, the layer uses bias weights.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
return_type (str) – Inherited from RNN. Whether to return the hidden states, the last output in the output sequence or the full sequence.
hx_source (str) – Inherited from RNN. The name of the source layer for initial hidden state.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
hidden_state_var (str) – Inherited from RNN. Variable name for hidden state output.
hidden_unused (bool) – Inherited from RNN. Whether hidden state output is unused.
hidden_subscript_source (str) – Inherited from RNN. Source variable for hidden subscript assignment.
hidden_subscript_target (str) – Inherited from RNN. Target variable for hidden subscript assignment.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.LSTMLayer(name: str, hidden_size: int, return_type: str =
'full', input_size: int | None =None, bidirectional: bool =False, dropout: float =0.0, batch_first: bool =True, actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, *, bias: bool =True, hx_source: str | None =None, is_layer_call: bool =False, hidden_state_var: str | None =None, cell_state_var: str | None =None, hidden_unused: bool =False, cell_unused: bool =False, hidden_subscript_source: str | None =None, hidden_subscript_target: str | None =None, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
RNNRepresents a Long Short-Term Memory layer.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
input_size (int) – It represents the dimensionality of the input features.
hidden_size (int) – It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.
bidirectional (bool) – Whether the layer is bidirectional or not.
dropout (float) – If non-zero, it introduces a Dropout layer on the outputs of the LSTM sub layers except the last one.
batch_first (bool) – If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.
bias (bool) – If True, the layer uses bias weights. Default is True.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
return_type (str) – Whether to return the hidden states, the last output in the output sequence or the full sequence.
hx_source (str) – The name of the source layer for initial hidden state (used in encoder-decoder architectures).
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
hidden_state_var (str) – Variable name for hidden state output.
cell_state_var (str) – Variable name for cell state output (LSTM only).
hidden_unused (bool) – Whether hidden state output is unused.
cell_unused (bool) – Whether cell state output is unused (LSTM only).
hidden_subscript_source (str) – Source variable for hidden subscript assignment.
hidden_subscript_target (str) – Target variable for hidden subscript assignment.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
input_size (int) – Inherited from RNN. It represents the dimensionality of the input features.
hidden_size (int) – Inherited from RNN. It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.
bidirectional (bool) – Inherited from RNN. Whether the layer is bidirectional or not.
dropout (float) – Inherited from RNN. If non-zero, it introduces a Dropout layer on the outputs of the LSTM sub layers except the last one.
batch_first (bool) – Inherited from RNN. If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.
bias (bool) – Inherited from RNN. If True, the layer uses bias weights.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
return_type (str) – Inherited from RNN. Whether to return the hidden states, the last output in the output sequence or the full sequence.
hx_source (str) – Inherited from RNN. The name of the source layer for initial hidden state.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
hidden_state_var (str) – Inherited from RNN. Variable name for hidden state output.
cell_state_var (str) – Inherited from RNN. Variable name for cell state output.
hidden_unused (bool) – Inherited from RNN. Whether hidden state output is unused.
cell_unused (bool) – Inherited from RNN. Whether cell state output is unused.
hidden_subscript_source (str) – Inherited from RNN. Source variable for hidden subscript assignment.
hidden_subscript_target (str) – Inherited from RNN. Target variable for hidden subscript assignment.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.GRULayer(name: str, hidden_size: int, return_type: str =
'full', input_size: int | None =None, bidirectional: bool =False, dropout: float =0.0, batch_first: bool =True, actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, *, bias: bool =True, hx_source: str | None =None, is_layer_call: bool =False, hidden_state_var: str | None =None, cell_state_var: str | None =None, hidden_unused: bool =False, cell_unused: bool =False, hidden_subscript_source: str | None =None, hidden_subscript_target: str | None =None, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
RNNRepresents a Gated Recurrent Unit layer.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
input_size (int) – It represents the dimensionality of the input features.
hidden_size (int) – It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.
bidirectional (bool) – Whether the layer is bidirectional or not.
dropout (float) – If non-zero, it introduces a Dropout layer on the outputs of the GRU sub layers except the last one.
batch_first (bool) – If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.
bias (bool) – If True, the layer uses bias weights. Default is True.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
return_type (str) – Whether to return the hidden states, the last output in the output sequence or the full sequence.
hx_source (str) – The name of the source layer for initial hidden state (used in encoder-decoder architectures).
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
hidden_state_var (str) – Variable name for hidden state output.
hidden_unused (bool) – Whether hidden state output is unused.
hidden_subscript_source (str) – Source variable for hidden subscript assignment.
hidden_subscript_target (str) – Target variable for hidden subscript assignment.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
input_size (int) – Inherited from RNN. It represents the dimensionality of the input features.
hidden_size (int) – Inherited from RNN. It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.
bidirectional (bool) – Inherited from RNN. Whether the layer is bidirectional or not.
dropout (float) – Inherited from RNN. If non-zero, it introduces a Dropout layer on the outputs of the GRU sub layers except the last one.
batch_first (bool) – Inherited from RNN. If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.
bias (bool) – Inherited from RNN. If True, the layer uses bias weights.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
return_type (str) – Inherited from RNN. Whether to return the hidden states, the last output in the output sequence or the full sequence.
hx_source (str) – Inherited from RNN. The name of the source layer for initial hidden state.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
hidden_state_var (str) – Inherited from RNN. Variable name for hidden state output.
hidden_unused (bool) – Inherited from RNN. Whether hidden state output is unused.
hidden_subscript_source (str) – Inherited from RNN. Source variable for hidden subscript assignment.
hidden_subscript_target (str) – Inherited from RNN. Target variable for hidden subscript assignment.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.GeneralLayer(name: str, actv_func: str | None =
None, name_module_input: str | None =None, input_reused: bool =False, *, is_layer_call: bool =False, permute_in: bool =False, permute_out: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
LayerRepresents a layer designed to handle general operations and transformations.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.LinearLayer(name: str, out_features: int, in_features: int | None =
None, actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, *, bias: bool =True, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
GeneralLayerRepresents a densely-connected NN layer that applies a linear transformation to the input data.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
in_features (int) – It represents the size of each input sample.
out_features (int) – It represents the size of each output sample.
bias (bool) – If True, adds a learnable bias to the output.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
in_features (int) – It represents the size of each input sample.
out_features (int) – It represents the size of each output sample.
bias (bool) – If True, adds a learnable bias to the output.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.FlattenLayer(name: str, start_dim: int =
1, end_dim: int =-1, actv_func: str | None =None, name_module_input: str | None =None, input_reused: bool =False, *, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
GeneralLayerRepresents a layer that flattens a contiguous range of dims into a tensor.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
start_dim (int) – The first dimension to flatten.
end_dim (int) – The last dim to flatten.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
start_dim (int) – The first dimension to flatten.
end_dim (int) – The last dim to flatten.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.EmbeddingLayer(name: str, num_embeddings: int, embedding_dim: int, actv_func: str | None =
None, name_module_input: str | None =None, input_reused: bool =False, *, padding_idx: int | None =None, permute_in: bool =False, permute_out: bool =False, is_layer_call: bool =False, input_var: str | None =None, output_var: str | None =None)[source]¶ Bases:
GeneralLayerRepresents a layer that learns dense vector representations of the input data.
- Parameters:¶
name (str) – The name of the layer.
actv_func (str) – The type of the activation function.
num_embeddings (int) – The size of the dictionary of embeddings.
embedding_dim (int) – The size of each embedding vector.
padding_idx (int) – If specified, the entries at padding_idx are masked and do not contribute to the gradient. Default is None.
permute_in (bool) – Whether to permute input dimensions before processing.
permute_out (bool) – Whether to permute output dimensions after processing.
name_module_input (str) – The name of the layer from which the inputs originate.
input_reused (bool) – Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – True if this represents a call to an already-defined layer (layer reuse).
input_var (str) – Input variable name for this layer.
output_var (str) – Output variable name for this layer.
- Attributes:¶
name (str) – Inherited from Layer. It represents the name of the layer.
actv_func (str) – Inherited from Layer. It represents the type of the activation function.
num_embeddings (int) – The size of the dictionary of embeddings.
embedding_dim (int) – The size of each embedding vector.
padding_idx (int) – If specified, the entries at padding_idx are masked.
permute_in (bool) – Whether to permute input dimensions before processing.
permute_out (bool) – Whether to permute output dimensions after processing.
name_module_input (str) – Inherited from Layer. The name of the layer from which the inputs originate.
input_reused (bool) – Inherited from Layer. Whether the input to this layer is reused as input to another layer.
is_layer_call (bool) – Inherited from Layer. True if this is a call to an already-defined layer.
input_var (str) – Inherited from Layer. Input variable name for this layer.
output_var (str) – Inherited from Layer. Output variable name for this layer.
-
_abc_impl =
<_abc._abc_data object>¶
- class besser.BUML.metamodel.nn.neural_network.Feature(name: str)[source]¶
Bases:
NamedElementA feature is a measurable property or characteristic of an object used to represent and describe it within a dataset.
- Parameters:¶
name (str) – The name of the feature.
- Attributes:¶
name (str) – The name of the feature.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.Label(col_name: str, label_name: str | None =
None)[source]¶ Bases:
objectA label is a value assigned to an observation, representing the target variable for prediction.
- Parameters:¶
col_name (str) – The name of the column containing the labels.
label_name (str) – The name of a label in the dataset. If the prediction task is regression, it can be omitted.
- Attributes:¶
col_name (str) – The name of the column containing the labels.
label_name (str) – The name of a label in the dataset. If the prediction task is regression, it can be omitted.
-
class besser.BUML.metamodel.nn.neural_network.Image(shape: list[int] | None =
None, normalize: bool =False)[source]¶ Bases:
FeatureImage represents features designed for handling data with spatial characteristics, typically including attributes such as height and width.
- Parameters:¶
shape (list[int]) – The shape of the image in the form [height, width, channels]. Default to [256, 256].
normalize (bool) – If true, the images will be normalized to zero mean and unit standard deviation.
- Attributes:¶
shape (list[int]) – The shape of the image in the form [height, width, channels]. Default to [256, 256].
normalize (bool) – If true, the images will be normalized to zero mean and unit standard deviation.
-
_abc_impl =
<_abc._abc_data object>¶
- class besser.BUML.metamodel.nn.neural_network.Structured(name: str)[source]¶
Bases:
FeatureRepresents features organized in a systematic manner, typically with well-defined columns and rows, often found in tabular datasets.
- Parameters:¶
name (str) – The name of the feature.
- Attributes:¶
name (str) – Inherited from Feature. It represents the name of the feature.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.Dataset(name: str, path_data: str, task_type: str | None =
None, input_format: str | None =None, image: Image | None =None, labels: set[Label] | None =None)[source]¶ Bases:
NamedElementRepresents the collection of data instances used for training or evaluation, where each instance comprises features and corresponding labels.
- Parameters:¶
name (str) – The name of the dataset.
path_data (str) – The file path or directory location containing the dataset.
task_type (str) – The type of prediction task associated with the dataset.
input_format (str) – The format of the input dataset.
image (Image) – An image instance that contains the shape desired for the images if input_format parameter is set to ‘images’.
labels (set[Label]) – The set of labels in the dataset.
- Attributes:¶
name (str) – The name of the dataset.
path_data (str) – The file path or directory location containing the dataset.
task_type (str) – The type of prediction task associated with the dataset.
input_format (str) – The format of the input dataset.
image (Image) – An image instance that contains the shape desired for the images if input_format parameter is set to ‘images’.
labels (set[Label]) – The set of labels in the dataset.
-
_abc_impl =
<_abc._abc_data object>¶
-
class besser.BUML.metamodel.nn.neural_network.Configuration(batch_size: int, epochs: int, learning_rate: float, optimizer: str, loss_function: str, metrics: list[str], weight_decay: float =
0, momentum: float =0)[source]¶ Bases:
objectRepresents a collection of parameters essential for training and evaluating neural networks.
- Parameters:¶
batch_size (int) – The number of data samples processed in each iteration during training or inference in a neural network.
epochs (int) – It refers to the number of complete passes through the entire dataset during the training, with each epoch consisting of one iteration through all data samples.
learning_rate (float) – The step size used to update the model parameters during optimization.
optimizer (str) – The method or algorithm used to adjust the model parameters iteratively during training to minimize the loss function and improve model performance.
loss_function (str) – The method used to calculate the difference between predicted and actual values, guiding the model towards better predictions.
metrics list[str] – Quantitative measures used to evaluate the performance of NN models.
weight_decay (float) – It represents the strength of L2 regularisation applied to the model’s parameters during optimization.
momentum (float) – It represents a hyperparameter in optimization that helps speed up training by using past gradients to smooth out updates.
- Attributes:¶
batch_size (int) – The number of data samples processed in each iteration during training or inference in a neural network.
epochs (int) – It refers to the number of complete passes through the entire dataset during the training, with each epoch consisting of one iteration through all data samples.
learning_rate (float) – The step size used to update the model parameters during optimization.
optimizer (str) – The method or algorithm used to adjust the model parameters iteratively during training to minimize the loss function and improve model performance.
loss_function (str) – The method used to calculate the difference between predicted and actual values, guiding the model towards better predictions.
metrics list[str] – Quantitative measures used to evaluate the performance of NN models.
weight_decay (float) – It represents the strength of L2 regularisation applied to the model’s parameters during optimization.
momentum (float) – It represents a hyperparameter in optimization that helps speed up training by using past gradients to smooth out updates.
- property batch_size : int¶
Get the number of data samples processed in each iteration during training or inference in a neural network.
- property epochs : int¶
Get the number of complete passes through the entire dataset during the training.
- property learning_rate : float¶
Get the step size used to update the model parameters during optimization.
- property optimizer : str¶
Get the algorithm used to adjust the model parameters iteratively during training to minimize the loss function.
- property loss_function : str¶
Get the method used to calculate the difference between predicted and actual values, guiding the model towards better predictions.
-
class besser.BUML.metamodel.nn.neural_network.NN(name: str, configuration: Configuration | None =
None, train_data: Dataset | None =None, test_data: Dataset | None =None, input_var: str | None =None, return_vars: str | None =None)[source]¶ Bases:
BehaviorImplementationIt is a subclass of the BehaviorImplementation class and comprises the fundamental properties and behaviors of a neural network model.
- Parameters:¶
name (str) – The name of the neural network model.
configuration (Configuration) – The parameters related to the NN training and evaluation.
train_data (Dataset) – The dataset used to train the NN model.
test_data (Dataset) – The dataset used to evaluate the NN model.
input_var (str) – Input variable name for the network.
return_vars (str) – Comma-separated string of variable names returned by the forward/call method (e.g., “rep, recon”).
- Attributes:¶
name (str) – The name of the neural network model.
configuration (Configuration) – The parameters related to the NN training and evaluation.
train_data (Dataset) – The dataset used to train the NN model.
test_data (Dataset) – The dataset used to evaluate the NN model.
input_var (str) – Input variable name for the network.
return_vars (str) – Comma-separated string of variable names returned by the forward/call method (e.g., “rep, recon”).
-
_abc_impl =
<_abc._abc_data object>¶
- property configuration : Configuration¶
Get the parameters related to the NN training and evaluation.
- Type:¶
- property return_vars : str¶
Get the comma-separated string of variable names returned by forward/call method.
- add_configuration(configuration: Configuration) Self[source]¶
Self: Add the configuration to the NN model.
- add_train_data(train_data: Dataset) Self[source]¶
Self: Add the training dataset to the NN model.
- resolve_var_chain()[source]¶
Propagate NN-level input_var and return_vars down into the first and last modules respectively. It should be called explicitly before code generation.
-
validate(raise_exception: bool =
True, validate_graph_structure: bool =True, _visited: set | None =None) dict[source]¶ Validate the neural network model.
- Checks performed:
Module names are unique within this NN scope.
Layer
name_module_inputreferences resolve to a module defined in the same NN (optional).TensorOp
layers_of_tensorsstring entries resolve to a module defined in the same NN or scalar values for binops (optional).Sub-NNs are acyclic (no NN directly or transitively contains itself).
Each sub-NN is itself valid (recursive validation).
Warnings are emitted for empty NNs and for missing configuration on a top-level NN that has training data.
- Parameters:¶
raise_exception – If True, raises
ValueErrorwhen errors are found. Warnings never raise.validate_graph_structure – If True, validates that module input references and tensor op references resolve correctly. Set to False during framework migration when intermediate layers/tensorops are created. Default True.
_visited – Internal — tracks NN instances already validated to stop infinite recursion on cyclic sub-NN graphs.
- Returns:¶
A mapping with the keys
success(bool),errors(list[str]) andwarnings(list[str]).- Return type:¶
- _is_multi_output_module(module)[source]¶
Check if a module returns multiple outputs (RNN layers or split tensorop).
- _get_previous_module(current_module)[source]¶
Get the module that appears immediately before current_module in self.modules.
- _validate_layer_input(errors: list)[source]¶
Validate that layers have required input specification when previous module returns multiple outputs.
- _module_names() set[source]¶
Names of every module declared in this NN (layers, tensor_ops, sub_nns).
- _validate_input_var_chain(errors: list)[source]¶
Validate input_var and output_var consistency across the NN.
- _validate_sub_nn_acyclic(errors: list) bool[source]¶
Detect cycles in the sub-NN graph rooted at this NN. Returns True if a cycle was found.
- _validate_sub_nns_recursive(errors: list, warnings: list, _visited: set, validate_graph_structure: bool)[source]¶
- _validate_dataset_consistency(warnings: list)[source]¶
Surface mismatches between training and test datasets that usually indicate user error.
- _validate_module_names(errors: list, warnings: list)[source]¶
Reject names that aren’t valid Python identifiers; warn (matching
NamedElement.name’s warn-not-error stance) on Python keywords.
- _validate_config_values(errors: list)[source]¶
Validate numerical bounds for configuration parameters to ensure they are within acceptable ranges.
- _validate_layer_values(errors: list)[source]¶
Validate numerical bounds for layer parameters to ensure they are within acceptable ranges.