hoops_ai.ml.EXPERIMENTAL

Quick Overview

Classes

GraphClassification([num_classes, ...])

GraphClassification is a user-friendly wrapper around the UVNet model.

GraphNodeClassification([num_classes, ...])

GraphNodeClassification is a user-friendly wrapper around the BrepSeg model.

class hoops_ai.ml.EXPERIMENTAL.GraphClassification(num_classes=10, result_dir=None, log_file='cnn_graph_training_errors.log', generate_stream_cache_for_visu=False)

Bases: FlowModel

GraphClassification is a user-friendly wrapper around the UVNet model. It provides default hyperparameters and an interface for users to interact without directly accessing the UVnet class.

Parameters:
  • num_classes (int, optional) – Number of classes for classification. Default: 10

  • log_file (str, optional) – Path to the log file. Default: ‘training_errors.log’

  • result_dir (str)

  • generate_stream_cache_for_visu (bool)

collate_function(batch)

Return a collate function for this model.

Return type:

Any

convert_encoded_data_to_graph(storage, graph_handler, filename)

Converts encoded data from storage into a graph representation, which serves as input for the ML model.

Parameters:
Return type:

Dict[str, Any]

encode_cad_data(cad_file, cad_loader, storage)

Opens the CAD file and encodes its data into a format suitable for machine learning. Stores the encoded data using the provided storage handler.

Parameters:
Return type:

Tuple[int, int]

encode_label_data(label_storage, storage)

Uses the LabelStorage object to retrieve the labeling information for a given input Stores the label data for the specific machine learning Task

return the str key when the label data is found in the storage object and the size of the label data

Parameters:
Return type:

Tuple[str, int]

load_model_input_from_files(graph_file, data_id, label_file=None)

Loads a single graph from a file to be used as input for the machine learning model.

Parameters:
  • graph_file (str)

  • data_id (int)

  • label_file (str)

Return type:

Any

metrics()

Publish/push the ml metrics after traiing the model

Return type:

MetricStorage

model_name()
Return type:

str

predict_and_postprocess(batch)

Post-processes and formats the raw model output into a structured prediction. Returns a numpy array with top 3 predictions and their probability percentages as integers.

Returns:

Array with shape (batch_size, 2, 3), where: - First dimension: batch items - Second dimension [0]: class indices (int) - Second dimension [1]: probability percentages (int)

Return type:

numpy.ndarray

retrieve_model(check_point=None)

Retrieves the PyTorch Lightning model used in this flow.

Parameters:

check_point (str)

Return type:

pytorch_lightning.LightningModule

class hoops_ai.ml.EXPERIMENTAL.GraphNodeClassification(num_classes=25, n_layers_encode=8, dim_node=256, d_model=512, n_heads=32, dropout=0.3, attention_dropout=0.3, act_dropout=0.3, learning_rate=0.002, optimizer_betas=(0.99, 0.999), scheduler_factor=0.5, scheduler_patience=5, scheduler_threshold=0.0001, scheduler_min_lr=1e-06, scheduler_cooldown=2, max_warmup_steps=5000, log_file='training_errors.log', result_dir=None, generate_stream_cache_for_visu=False, **kwargs)

Bases: FlowModel

GraphNodeClassification is a user-friendly wrapper around the BrepSeg model. It provides default hyperparameters and an interface for users to interact without directly accessing the BrepSeg class.

Parameters:
  • num_classes (int, optional) – Number of classes for classification. Default: 10

  • n_layers_encode (int, optional) – Number of encoding layers in the BrepEncoder. Default: 6

  • dim_node (int, optional) – Dimension of node embeddings. Default: 256

  • d_model (int, optional) – Dimension of the model in BrepEncoder. Default: 512

  • n_heads (int, optional) – Number of attention heads in BrepEncoder. Default: 8

  • dropout (float, optional) – Dropout rate for the classifier. Default: 0.3

  • attention_dropout (float, optional) – Dropout rate for attention layers. Default: 0.1

  • act_dropout (float, optional) – Dropout rate for activation layers. Default: 0.1

  • learning_rate (float, optional) – Initial learning rate for the optimizer. Default: 0.002

  • optimizer_betas (Tuple[float, float], optional) – Betas for the AdamW optimizer. Default: (0.99, 0.999)

  • scheduler_factor (float, optional) – Factor for ReduceLROnPlateau scheduler. Default: 0.5

  • scheduler_patience (int, optional) – Patience for ReduceLROnPlateau scheduler. Default: 5

  • scheduler_threshold (float, optional) – Threshold for ReduceLROnPlateau scheduler. Default: 1e-4

  • scheduler_min_lr (float, optional) – Minimum learning rate for scheduler. Default: 1e-6

  • scheduler_cooldown (int, optional) – Cooldown period for scheduler. Default: 2

  • max_warmup_steps (int, optional) – Number of warmup steps for learning rate scaling. Default: 5000

  • log_file (str, optional) – Path to the log file. Default: ‘training_errors.log’

  • **kwargs (Any) – Additional keyword arguments for BrepSeg.

  • result_dir (str)

  • generate_stream_cache_for_visu (bool)

  • **kwargs

collate_function(batch)

Return a collate function for this model.

Return type:

Any

convert_encoded_data_to_graph(storage, graph_handler, filename)

Converts encoded data from storage into a graph representation, which serves as input for the ML model.

Parameters:
Return type:

Dict[str, Any]

encode_cad_data(cad_file, cad_loader, storage)

Opens the CAD file and encodes its data into a format suitable for machine learning. Stores the encoded data using the provided storage handler.

Parameters:
Return type:

Tuple[int, int]

encode_label_data(label_storage, storage)

Uses the LabelStorage object to retrieve the labeling information for a given input Stores the label data for the specific machine learning Task

return the str key when the label data is found in the storage object and the size of the label data

Parameters:
Return type:

Tuple[str, int]

load_model_input_from_files(graph_file, data_id, label_file=None)

Loads a single graph from a file to be used as input for the machine learning model.

Parameters:
  • graph_file (str)

  • data_id (int)

  • label_file (str)

Return type:

Any

metrics()

Publish/push the ml metrics after training the model

Return type:

MetricStorage

model_name()
Return type:

str

predict_and_postprocess(batch)

Post-processes and formats the raw model output into a structured prediction. Returns the predictions and their associated probabilities.

Return type:

Any

retrieve_model(check_point=None)

Retrieves the PyTorch Lightning model used in this flow.

Parameters:

check_point (str)

Return type:

pytorch_lightning.LightningModule