Neural Network model#

This module defines the neural network metamodel.

class besser.BUML.metamodel.nn.neural_network.BatchNormLayer(name: str, num_features: int, dimension: str, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: NormalizationLayer

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

num_features#

The number of channels or features in each input sample.

Type:

int

dimension#

The dimensionality (1D, 2D, or 3D) of the input data to be normalized using batch normalization.

Type:

str

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property dimension: str#

Get the dimensionality of the input data to be normalized.

Type:

str

property num_features: int#

Get the number of channels or features.

Type:

int

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, name_module_input: str = None, input_reused: bool = False, permute_in: bool = False, permute_out: bool = False)[source]#

Bases: Layer

Represents 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

kernel_dim#

A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).

Type:

List[int]

stride_dim#

A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).

Type:

List[int]

padding_amount#

The amount of padding added to the input.

Type:

int

padding_type#

The type of padding applied to the input.

Type:

str

permute_in#

Whether the dimensions of the input need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.

Type:

bool

permute_out#

Whether the dimensions of the output need to be permuted. Relevant for PyTorch. It is used to make PyTorch model equivalent to TensorFlow model.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property kernel_dim: List[int]#

Get the list of dimensions of the kernel.

Type:

List[int]

property padding_amount: int#

Get the amount of padding added to the input.

Type:

int

property padding_type: str#

Get the type of padding applied to the input.

Type:

str

property permute_in: bool#

Get whether to permute the dim of the input.

Type:

bool

property permute_out: bool#

Get whether to permute the dim of the output.

Type:

bool

property stride_dim: List[int]#

Get the list of dimensions of the stride.

Type:

List[int]

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: object

Represents 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.

  • List[str] (metrics) – 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.

batch_size#

The number of data samples processed in each iteration during training or inference in a neural network.

Type:

int

epochs#

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.

Type:

int

learning_rate#

The step size used to update the model parameters during optimization.

Type:

float

optimizer#

The method or algorithm used to adjust the model parameters iteratively during training to minimize the loss function and improve model performance.

Type:

str

loss_function#

The method used to calculate the difference between predicted and actual values, guiding the model towards better predictions.

Type:

str

metrics List[str]

Quantitative measures used to evaluate the performance of NN models.

weight_decay#

It represents the strength of L2 regularisation applied to the model’s parameters during optimization.

Type:

float

momentum#

It represents a hyperparameter in optimization that helps speed up training by using past gradients to smooth out updates.

Type:

float

property batch_size: int#

Get the number of data samples processed in each iteration during training or inference in a neural network.

Type:

int

property epochs: int#

Get the number of complete passes through the entire dataset during the training.

Type:

int

property learning_rate: float#

Get the step size used to update the model parameters during optimization.

Type:

float

property loss_function: str#

Get the method used to calculate the difference between predicted and actual values, guiding the model towards better predictions.

Type:

str

property metrics: List[str]#

Get the measures for evaluating the performance of the model.

Type:

List[str]

property momentum: float#

Get the value of the momentum hyperparameter.

Type:

float

property optimizer: str#

Get the algorithm used to adjust the model parameters iteratively during training to minimize the loss function.

Type:

str

property weight_decay: float#

Get the strength of L2 regularisation applied during optimization.

Type:

float

class besser.BUML.metamodel.nn.neural_network.Conv1D(name: str, kernel_dim: List[int], out_channels: int, stride_dim: List[int] = None, in_channels: int = None, padding_amount: int = 0, padding_type: str = 'valid', actv_func: str = None, name_module_input: str = None, input_reused: bool = False, permute_in: bool = False, permute_out: bool = False)[source]#

Bases: ConvolutionalLayer

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

kernel_dim#

Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).

Type:

List[int]

stride_dim#

Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).

Type:

List[int]

in_channels#

Inherited from ConvolutionalLayer. It represents the number of channels in the input image.

Type:

int

out_channels#

Inherited from ConvolutionalLayer. It represents the number of channels produced by the convolution.

Type:

int

padding_amount#

Inherited from CNN. It represents the amount of padding added to the input.

Type:

int

padding_type#

Inherited from CNN. It represents the type of padding applied to the input.

Type:

str

permute_in#

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.

Type:

bool

permute_out#

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.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property kernel_dim: List[int]#

Get the list of dimensions of the kernel.

Type:

List[int]

property stride_dim: List[int]#

Get the list of dimensions of the stride.

Type:

List[int]

class besser.BUML.metamodel.nn.neural_network.Conv2D(name: str, kernel_dim: List[int], out_channels: int, stride_dim: List[int] = None, in_channels: int = None, padding_amount: int = 0, padding_type: str = 'valid', actv_func: str = None, name_module_input: str = None, input_reused: bool = False, permute_in: bool = False, permute_out: bool = False)[source]#

Bases: ConvolutionalLayer

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

kernel_dim#

Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).

Type:

List[int]

stride_dim#

Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).

Type:

List[int]

in_channels#

Inherited from ConvolutionalLayer. It represents the number of channels in the input image.

Type:

int

out_channels#

Inherited from ConvolutionalLayer. It represents the number of channels produced by the convolution.

Type:

int

padding_amount#

Inherited from CNN. It represents the amount of padding added to the input.

Type:

int

padding_type#

Inherited from CNN. It represents the type of padding applied to the input.

Type:

str

permute_in#

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.

Type:

bool

permute_out#

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.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property kernel_dim: List[int]#

Get the list of dimensions of the kernel.

Type:

List[int]

property stride_dim: List[int]#

Get the list of dimensions of the stride.

Type:

List[int]

class besser.BUML.metamodel.nn.neural_network.Conv3D(name: str, kernel_dim: List[int], out_channels: int, stride_dim: List[int] = None, in_channels: int = None, padding_amount: int = 0, padding_type: str = 'valid', actv_func: str = None, name_module_input: str = None, input_reused: bool = False, permute_in: bool = False, permute_out: bool = False)[source]#

Bases: ConvolutionalLayer

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

kernel_dim#

Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).

Type:

List[int]

stride_dim#

Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).

Type:

List[int]

in_channels#

Inherited from ConvolutionalLayer. It represents the number of channels in the input image.

Type:

int

out_channels#

Inherited from ConvolutionalLayer. It represents the number of channels produced by the convolution.

Type:

int

padding_amount#

Inherited from CNN. It represents the amount of padding added to the input.

Type:

int

padding_type#

Inherited from CNN. It represents the type of padding applied to the input.

Type:

str

permute_in#

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.

Type:

bool

permute_out#

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.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property kernel_dim: List[int]#

Get the list of dimensions of the kernel.

Type:

List[int]

property stride_dim: List[int]#

Get the list of dimensions of the stride.

Type:

List[int]

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, padding_amount: int = 0, padding_type: str = 'valid', actv_func: str = None, name_module_input: str = None, input_reused: bool = False, permute_in: bool = False, permute_out: bool = False)[source]#

Bases: CNN

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

kernel_dim#

Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).

Type:

List[int]

stride_dim#

Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).

Type:

List[int]

in_channels#

The number of channels in the input image.

Type:

int

out_channels#

The number of channels produced by the convolution.

Type:

int

padding_amount#

Inherited from CNN. The amount of padding added to the input.

Type:

int

padding_type#

Inherited from CNN. The type of padding applied to the input.

Type:

str

permute_in#

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.

Type:

bool

permute_out#

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.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property in_channels: int#

Get the number of channels in the input image.

Type:

int

property out_channels: int#

Get the number of channels produced by the convolution.

Type:

int

class besser.BUML.metamodel.nn.neural_network.Dataset(name: str, path_data: str, task_type: str = None, input_format: str = None, image: Image = None, labels: set[Label] = None)[source]#

Bases: NamedElement

Represents 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.

name#

The name of the dataset.

Type:

str

path_data#

The file path or directory location containing the dataset.

Type:

str

task_type#

The type of prediction task associated with the dataset.

Type:

str

input_format#

The format of the input dataset.

Type:

str

image#

An image instance that contains the shape desired for the images if input_format parameter is set to ‘images’.

Type:

Image

labels#

The set of labels in the dataset.

Type:

set[Label]

_abc_impl = <_abc._abc_data object>#
add_image(image: Image)[source]#

Image: Add the dimensions of the image.

add_label(label: Label)[source]#

Label: add a label to the set of labels.

property image: Image#

Get the dimensions of the images.

Type:

Image

property input_format: str#

Get the format of the input dataset.

Type:

str

property labels: set[Label]#

Get the set of labels.

Type:

set[Label]

property path_data: str#

Get the directory location containing the dataset.

Type:

str

property task_type: str#

Get the type of prediction task associated with the dataset.

Type:

str

class besser.BUML.metamodel.nn.neural_network.DropoutLayer(name: str, rate: float, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: LayerModifier

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

rate#

It represents a float between 0 and 1. Fraction of the input units to drop.

Type:

float

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property rate: float#

Get the fraction of the input units to drop.

Type:

float

class besser.BUML.metamodel.nn.neural_network.EmbeddingLayer(name: str, num_embeddings: int, embedding_dim: int, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: GeneralLayer

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

num_embeddings#

The size of the dictionary of embeddings.

Type:

int

embedding_dim#

The size of each embedding vector.

Type:

int

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property embedding_dim: int#

Get the size of each embedding vector.

Type:

int

property num_embeddings: int#

Get the size of the dictionary of embeddings.

Type:

int

class besser.BUML.metamodel.nn.neural_network.Feature(name: str)[source]#

Bases: NamedElement

A 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.

name#

The name of the feature.

Type:

str

_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, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: GeneralLayer

Represents 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

start_dim#

The first dimension to flatten.

Type:

int

end_dim#

The last dim to flatten.

Type:

int

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property end_dim: int#

Get the last dimension to flatten.

Type:

int

property start_dim: int#

Get the first dimension to flatten.

Type:

int

class besser.BUML.metamodel.nn.neural_network.GRULayer(name: str, hidden_size: int, return_type: str = 'full', input_size: int = None, bidirectional: bool = False, dropout: float = 0.0, batch_first: bool = True, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: RNN

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

input_size#

Inherited from RNN. It represents the dimensionality of the input features.

Type:

int

hidden_size#

Inherited from RNN. It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.

Type:

int

bidirectional#

Inherited from RNN. Whether the layer is bidirectional or not.

Type:

bool

dropout#

Inherited from RNN. If non-zero, it introduces a Dropout layer on the outputs of the GRU sub layers except the last one.

Type:

float

batch_first#

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.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

return_type#

Inherited from RNN. Whether to return the hidden states, the last output in the output sequence or the full sequence.

Type:

str

_abc_impl = <_abc._abc_data object>#
class besser.BUML.metamodel.nn.neural_network.GeneralLayer(name: str, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: Layer

Represents 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
class besser.BUML.metamodel.nn.neural_network.Image(shape: List[int] = None, normalize: bool = False)[source]#

Bases: Feature

Image 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.

shape#

The shape of the image in the form [height, width, channels]. Default to [256, 256].

Type:

list[int]

normalize#

If true, the images will be normalized to zero mean and unit standard deviation.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property normalize: bool#

If true, the images will be normalized to zero mean and unit standard deviation.

Type:

bool

property shape: List[int]#

Get the shape of the image.

Type:

List[int]

class besser.BUML.metamodel.nn.neural_network.LSTMLayer(name: str, hidden_size: int, return_type: str = 'full', input_size: int = None, bidirectional: bool = False, dropout: float = 0.0, batch_first: bool = True, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: RNN

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

input_size#

Inherited from RNN. It represents the dimensionality of the input features.

Type:

int

hidden_size#

Inherited from RNN. It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.

Type:

int

bidirectional#

Inherited from RNN. Whether the layer is bidirectional or not.

Type:

bool

dropout#

Inherited from RNN. If non-zero, it introduces a Dropout layer on the outputs of the LSTM sub layers except the last one.

Type:

float

batch_first#

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.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

return_type#

Inherited from RNN. Whether to return the hidden states, the last output in the output sequence or the full sequence.

Type:

str

_abc_impl = <_abc._abc_data object>#
class besser.BUML.metamodel.nn.neural_network.Label(col_name: str, label_name: str = None)[source]#

Bases: object

A 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.

col_name#

The name of the column containing the labels.

Type:

str

label_name#

The name of a label in the dataset. If the prediction task is regression, it can be omitted.

Type:

str

property col_name: str#

Get the name of the column containing the labels.

Type:

str

property label_name: str#

Get the name of the label.

Type:

str

class besser.BUML.metamodel.nn.neural_network.Layer(name: str, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: NamedElement

This 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.

name#

The name of the layer.

Type:

str

actv_func#

The type of the activation function.

Type:

str

name_module_input#

The name of the layer from which the inputs originate.

Type:

str

input_reused#

Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property actv_func: str#

Get the actv_func.

Type:

str

property input_reused: bool#

Get whether the input to this layer is reused as input to another layer.

Type:

bool

property name_module_input: str#

Get the name of the layer from which the inputs originate.

Type:

str

class besser.BUML.metamodel.nn.neural_network.LayerModifier(name: str, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
class besser.BUML.metamodel.nn.neural_network.LayerNormLayer(name: str, normalized_shape: List[int], actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: NormalizationLayer

Represents 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 refering to the dimensions or axis indices over which layer normalization is applied, specifying which parts of the tensor are normalized.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

normalized_shape#

A list refering to the dimensions or axis indices over which layer normalization is applied, specifying which parts of the tensor are normalized.

Type:

List[int]

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property normalized_shape: List[int]#

Get the list containing the dimensions or axis indices over which layer normalization is applied.

Type:

List[int]

class besser.BUML.metamodel.nn.neural_network.LinearLayer(name: str, out_features: int, in_features: int = None, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: GeneralLayer

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

in_features#

It represents the size of each input sample.

Type:

int

out_features#

It represents the size of each output sample.

Type:

int

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property in_features: int#

Get the size of the input sample.

Type:

int

property out_features: int#

Get the size of the output sample.

Type:

int

class besser.BUML.metamodel.nn.neural_network.NN(name: str, configuration: Configuration = None, train_data: Dataset = None, test_data: Dataset = None)[source]#

Bases: BehaviorImplementation

It 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.

name#

The name of the neural network model.

Type:

str

configuration#

The parameters related to the NN training and evaluation.

Type:

Configuration

train_data#

The dataset used to train the NN model.

Type:

Dataset

test_data#

The dataset used to evaluate the NN model.

Type:

Dataset

_abc_impl = <_abc._abc_data object>#
add_configuration(configuration: Configuration) Self[source]#

Self: Add the configuration to the NN model.

add_layer(layer: Layer) Self[source]#

Self: Add a layer to the NN model.

add_sub_nn(sub_nn: NN)[source]#

Self: Add a subnn to the NN model.

add_tensor_op(tensor_op: TensorOp) Self[source]#

Self: Add a tensor Op to the NN model.

add_test_data(test_data: Dataset) Self[source]#

Self: Add the test dataset to the NN model.

add_train_data(train_data: Dataset) Self[source]#

Self: Add the training dataset to the NN model.

property configuration: Configuration#

Get the parameters related to the NN training and evaluation.

Type:

Configuration

property layers: List[Layer]#

Get the list of layers.

Type:

List[Layer]

property modules: List[NN | Layer | TensorOp]#

Get the modules list of the main model.

Type:

List[Union[NN, Layer, TensorOp]]

property sub_nns: List[NN]#

Get the sub NN models list of the main model.

Type:

List[NN]

property tensor_ops: List[TensorOp]#

Get the list of tensor Ops.

Type:

List[TensorOp]

property test_data: Dataset#

Get the dataset used to evaluate the NN model.

Type:

Dataset

property train_data: Dataset#

Get the dataset used to train the NN model.

Type:

Dataset

class besser.BUML.metamodel.nn.neural_network.NormalizationLayer(name: str, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: LayerModifier

Represents a type of layer that applies normalization techniques.

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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_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, stride_dim: List[int] = None, padding_amount: int = 0, padding_type: str = 'valid', output_dim: List[int] = None, actv_func: str = None, name_module_input: str = None, input_reused: bool = False, permute_in: bool = False, permute_out: bool = False)[source]#

Bases: CNN

Represents 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.

  • dimension – The dimensionality of the pooling. Either 1D, 2D or 3D.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

dimension#

The dimensionality (1D, 2D, or 3D) of the pooling operation.

Type:

str

kernel_dim#

Inherited from CNN. A list containing the dimensions of the convolving or pooling kernel (i.e., [depth, height, width]).

Type:

List[int]

stride_dim#

Inherited from CNN. A list containing the dimensions of the stride of the convolution or pooling (i.e., [depth, height, width]).

Type:

List[int]

padding_amount#

Inherited from CNN. It represents the amount of padding added to the input.

Type:

int

padding_type#

Inherited from CNN. It represents the type of padding applied to the input.

Type:

str

pooling_type#

The type of pooling. Either average or max.

Type:

str

dimension#

The dimensionality of the pooling. Either 1D, 2D or 3D.

Type:

str

output_dim#

The output dimensions of the adaptive pooling operation. Only relevant for adaptive pooling.

Type:

List[int]

permute_in#

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.

Type:

bool

permute_out#

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.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

_abc_impl = <_abc._abc_data object>#
property dimension: str#

Get the dimensionality of the pooling.

Type:

str

property kernel_dim: List[int]#

Get the list of dimensions of the kernel.

Type:

List[int]

property output_dim: List[int]#

Get the output dimensions of the adaptive pooling.

Type:

List[int]

property pooling_type: str#

Get the type of pooling applied.

Type:

str

property stride_dim: List[int]#

Get the list of dimensions of the stride.

Type:

List[int]

class besser.BUML.metamodel.nn.neural_network.RNN(name: str, hidden_size: int, return_type: str = 'full', input_size: int = None, bidirectional: bool = False, dropout: float = 0.0, batch_first: bool = True, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: Layer

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

input_size#

It represents the dimensionality of the input features.

Type:

int

hidden_size#

It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.

Type:

int

bidirectional#

Whether the layer is bidirectional or not.

Type:

bool

dropout#

If non-zero, it introduces a Dropout layer on the outputs of the current sub layers except the last one.

Type:

float

batch_first#

If True, the input and output tensors are provided as (batch, seq, feature) instead of (seq, batch, feature). Only relevant to PyTorch.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

return_type#

Whether to return the hidden states, the last output in the output sequence or the full sequence.

Type:

str

_abc_impl = <_abc._abc_data object>#
property batch_first: bool#

Get whether the input and output tensors are provided as (batch, seq, feature).

Type:

bool

property bidirectional: bool#

Get whether the layer is bidirectional or not.

Type:

bool

property dropout: float#

Get the dropout ratio of the layer.

Type:

float

property hidden_size: int#

Get the number of units in the hidden state.

Type:

int

property input_size: int#

Get the dimensionality of the input features of the layer.

Type:

int

property return_type: str#

Whether to return the hidden states, the last output in the output sequence or the full sequence.

Type:

str

class besser.BUML.metamodel.nn.neural_network.SimpleRNNLayer(name: str, hidden_size: int, return_type: str = 'full', input_size: int = None, bidirectional: bool = False, dropout: float = 0.0, batch_first: bool = True, actv_func: str = None, name_module_input: str = None, input_reused: bool = False)[source]#

Bases: RNN

Represents 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.

  • 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.

name#

Inherited from Layer. It represents the name of the layer.

Type:

str

actv_func#

Inherited from Layer. It represents the type of the activation function.

Type:

str

input_size#

Inherited from RNN. It represents the dimensionality of the input features.

Type:

int

hidden_size#

Inherited from RNN. It represents the number of units in the hidden state, which captures the network’s internal representation of the input sequence.

Type:

int

bidirectional#

Inherited from RNN. Whether the layer is bidirectional or not.

Type:

bool

dropout#

Inherited from RNN. If non-zero, it introduces a Dropout layer on the outputs of the RNN sub layers except the last one.

Type:

float

batch_first#

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.

Type:

bool

name_module_input#

Inherited from Layer. The name of the layer from which the inputs originate.

Type:

str

input_reused#

Inherited from Layer. Whether the input to this layer is reused as input to another layer.

Type:

bool

return_type#

Inherited from RNN. Whether to return the hidden states, the last output in the output sequence or the full sequence.

Type:

str

_abc_impl = <_abc._abc_data object>#
class besser.BUML.metamodel.nn.neural_network.Structured(name: str)[source]#

Bases: Feature

Represents 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.

name#

Inherited from Feature. It represents the name of the feature.

Type:

str

_abc_impl = <_abc._abc_data object>#
class besser.BUML.metamodel.nn.neural_network.TensorOp(name: str, tns_type: str, concatenate_dim: int = None, layers_of_tensors: List[str | float] = None, reshape_dim: List[int] = None, transpose_dim: List[int] = None, permute_dim: List[int] = None, input_reused: bool = False)[source]#

Bases: NamedElement

This 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.

  • type (str) – The type of the tensor operation.

  • concatenate_dim (int) – The dimension along which the tensors will be concatenated with the cat operation.

  • layers_of_tensors (List[Union[str, float]]) – The list that defines the inputs of the tensor op. Elements of the list can be either names of layers from which the tensors originate or scalar values.

  • reshape_dim (List[int]) – A list specifying the new shape of the tensor after the reshape operation.

  • transpose_dim (List[int]) – A list specifying the transpose dimensions. Only relevant with the transpose operation.

  • permute_dim (List[int]) – A list containing the desired ordering of dimensions. Only relevant with the permute operation.

  • input_reused (bool) – Whether the input to this tensor op is reused as input to another layer (or tensor op).

name#

The name of the tensor operation.

Type:

str

type#

The type of the tensor operation.

Type:

str

concatenate_dim#

The dimension along which the tensors will be concatenated with the cat operation.

Type:

int

layers_of_tensors#

The list that defines the inputs of the tensor op. Elements of the list can be either names of layers from which the tensors originate or scalar values.

Type:

List[Union[str, float]]

reshape_dim#

A list specifying the new shape of the tensor after the reshape operation.

Type:

List[int]

transpose_dim#

A list specifying the transpose dimensions. Only relevant with the transpose operation.

Type:

List[int]

permute_dim#

A list containing the desired ordering of dimensions. Only relevant with the permute operation.

Type:

List[int]

input_reused#

Whether the input to this tensor op is reused as input to another layer (or tensor op).

Type:

bool

_abc_impl = <_abc._abc_data object>#
property concatenate_dim: int#

Get the dimension along which the tensors will be concatenated with the cat operation.

Type:

int

property input_reused: bool#

Get whether the input to this layer is reused as input to another layer.

Type:

bool

property layers_of_tensors: List[str | float]#

Get the list that defines the inputs of the tensor op. Elements of the list can be either names of layers from which the tensors originate or scalar values.

Type:

List[Union[str, float]]

property permute_dim: List[int]#

Get the list containing the desired ordering of dimensions for permute operation.

Type:

List[int]

property reshape_dim: List[int]#

Get the list specifying the new shape of the tensor after reshaping with the view operation.

Type:

List[int]

property tns_type: str#

Get the type of the tensorOp.

Type:

str

property transpose_dim: List[int]#

Get the list specifying the transpose dimensions.

Type:

List[int]