ANN Models
physXAI.models.ann.ann_design
Classes
ANNModel
Bases: SingleStepModel, ABC
Abstract Base Class for single-step Artificial Neural Network models. Provides common functionality for compiling, fitting, plotting, saving, loading, and managing configurations for Keras-based ANN models.
Source code in physXAI/models/ann/ann_design.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
Attributes
batch_size: int = batch_size
instance-attribute
epochs: int = epochs
instance-attribute
learning_rate: float = learning_rate
instance-attribute
early_stopping_epochs: Optional[int] = early_stopping_epochs
instance-attribute
random_seed: int = random_seed
instance-attribute
Functions
__init__(batch_size: int = 32, epochs: int = 1000, learning_rate: float = 0.001, early_stopping_epochs: Optional[int] = 100, random_seed: int = 42, **kwargs)
Initializes common hyperparameters for ANN training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_size
|
int
|
Number of samples per gradient update. |
32
|
epochs
|
int
|
Number of times to iterate over the entire training dataset. |
1000
|
learning_rate
|
float
|
Learning rate for the Adam optimizer. |
0.001
|
early_stopping_epochs
|
int
|
Number of epochs with no improvement after which training will be stopped. If None, early stopping is disabled. |
100
|
random_seed
|
int
|
Seed for random number generators to ensure reproducibility. |
42
|
Source code in physXAI/models/ann/ann_design.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
generate_model(**kwargs)
abstractmethod
Abstract method to be implemented by subclasses to define and return a Keras model.
The td (TrainingData) object is expected to be passed via kwargs.
Source code in physXAI/models/ann/ann_design.py
51 52 53 54 55 56 57 | |
compile_model(model)
Compiles the Keras model with Adam optimizer, Mean Squared Error loss, and Root Mean Squared Error metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Keras model to compile. |
required |
Source code in physXAI/models/ann/ann_design.py
59 60 61 62 63 64 65 66 67 68 | |
fit_model(model, td: TrainingDataGeneric)
Fits the Keras model to the training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Keras model to fit. |
required |
td
|
TrainingDataGeneric
|
The TrainingData object |
required |
Source code in physXAI/models/ann/ann_design.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
plot(td: TrainingDataGeneric)
Generates and displays various plots related to model performance and training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
td
|
TrainingDataGeneric
|
The TrainingData object |
required |
Source code in physXAI/models/ann/ann_design.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
save_model(model, save_path: str)
Saves the Keras model to the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Keras model to save. |
required |
save_path
|
str
|
The directory or full path where the model should be saved. |
required |
Source code in physXAI/models/ann/ann_design.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
load_model(load_path: str)
Loads a Keras model from the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
load_path
|
str
|
The path from which to load the model. |
required |
Returns:
| Type | Description |
|---|---|
|
keras.Model: The loaded Keras model. |
Source code in physXAI/models/ann/ann_design.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
get_config() -> dict
Source code in physXAI/models/ann/ann_design.py
191 192 193 194 195 196 197 198 199 200 | |
ClassicalANNModel
Bases: ANNModel
A classical (standard feed-forward) Artificial Neural Network model.
Source code in physXAI/models/ann/ann_design.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
Attributes
n_layers: int = n_layers
instance-attribute
n_neurons: Union[int, list[int]] = n_neurons
instance-attribute
activation_function: Union[str, list[str]] = activation_function
instance-attribute
rescale_output: bool = rescale_output
instance-attribute
model_config = {'n_layers': self.n_layers, 'n_neurons': self.n_neurons, 'activation_function': self.activation_function, 'rescale_output': self.rescale_output}
instance-attribute
Functions
__init__(n_layers: int = 1, n_neurons: Union[int, list[int]] = 32, activation_function: Union[str, list[str]] = 'softplus', rescale_output: bool = True, batch_size: int = 32, epochs: int = 1000, learning_rate: float = 0.001, early_stopping_epochs: Optional[int] = 100, random_seed: int = 42, **kwargs)
Initializes the ClassicalANNModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_layers
|
int
|
Number of hidden layers. |
1
|
n_neurons
|
int or list[int]
|
Number of neurons in each hidden layer. If int, same for all. If list, specifies for each layer. |
32
|
activation_function
|
str or list[str]
|
Activation function(s) for hidden layers. If str, same for all. If list, specifies for each layer. |
'softplus'
|
rescale_output
|
bool
|
Whether to rescale the model's output to the original target range. |
True
|
batch_size
|
int
|
Number of samples per gradient update. |
32
|
epochs
|
int
|
Number of times to iterate over the entire training dataset. |
1000
|
learning_rate
|
float
|
Learning rate for the Adam optimizer. |
0.001
|
early_stopping_epochs
|
int
|
Number of epochs with no improvement after which training will be stopped. If None, early stopping is disabled. |
100
|
random_seed
|
int
|
Seed for random number generators to ensure reproducibility. |
42
|
Source code in physXAI/models/ann/ann_design.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
generate_model(**kwargs)
Generates the Keras model using ClassicalANNConstruction.
Source code in physXAI/models/ann/ann_design.py
244 245 246 247 248 249 250 251 | |
get_config() -> dict
Source code in physXAI/models/ann/ann_design.py
253 254 255 256 257 258 259 260 261 | |
LinANNModel
Bases: ANNModel
A hybrid model combining a Linear Regression model with an ANN (likely RBF) that models the residuals of the linear regression.
Source code in physXAI/models/ann/ann_design.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
Attributes
n_layers: int = n_layers
instance-attribute
n_neurons: Union[int, list[int]] = n_neurons
instance-attribute
rescale_output: bool = rescale_output
instance-attribute
model_config = {'n_layers': self.n_layers, 'n_neurons': self.n_neurons, 'rescale_output': self.rescale_output, 'random_state': random_seed}
instance-attribute
Functions
__init__(n_layers: int = 1, n_neurons: Union[int, list[int]] = 32, rescale_output: bool = True, batch_size: int = 32, epochs: int = 1000, learning_rate: float = 0.001, early_stopping_epochs: int = 100, random_seed: int = 42, **kwargs)
Initializes the LinANNModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_layers
|
int
|
Number of hidden layers for the residual-fitting ANN. |
1
|
n_neurons
|
int or list[int]
|
Number of neurons for the residual-fitting ANN. |
32
|
rescale_output
|
bool
|
Whether to rescale the final combined output. |
True
|
batch_size
|
int
|
Number of samples per gradient update. |
32
|
epochs
|
int
|
Number of times to iterate over the entire training dataset. |
1000
|
learning_rate
|
float
|
Learning rate for the Adam optimizer. |
0.001
|
early_stopping_epochs
|
int
|
Number of epochs with no improvement after which training will be stopped. If None, early stopping is disabled. |
100
|
random_seed
|
int
|
Seed for random number generators to ensure reproducibility. |
42
|
Source code in physXAI/models/ann/ann_design.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
generate_model(**kwargs)
Generates the hybrid Linear + ANN model. First, a Linear Regression model is trained. Then, an ANN (e.g., RBF) is constructed to model its residuals.
Source code in physXAI/models/ann/ann_design.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
get_config() -> dict
Source code in physXAI/models/ann/ann_design.py
319 320 321 322 323 324 325 326 | |
RBFModel
Bases: ANNModel
A Radial Basis Function (RBF) Network model.
Source code in physXAI/models/ann/ann_design.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
Attributes
n_layers: int = n_layers
instance-attribute
n_neurons: Union[int, list[int]] = n_neurons
instance-attribute
rescale_output: bool = rescale_output
instance-attribute
model_config = {'n_layers': self.n_layers, 'n_neurons': self.n_neurons, 'rescale_output': self.rescale_output, 'random_state': random_seed}
instance-attribute
Functions
__init__(n_layers: int = 1, n_neurons: Union[int, list[int]] = 32, rescale_output: bool = True, batch_size: int = 32, epochs: int = 1000, learning_rate: float = 0.001, early_stopping_epochs: int = 100, random_seed: int = 42, **kwargs)
Initializes the RBFModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_layers
|
int
|
Number of RBF layers. |
1
|
n_neurons
|
int or list[int]
|
Number of RBF neurons in each layer. |
32
|
rescale_output
|
bool
|
Whether to rescale the model's output. |
True
|
batch_size
|
int
|
Number of samples per gradient update. |
32
|
epochs
|
int
|
Number of times to iterate over the entire training dataset. |
1000
|
learning_rate
|
float
|
Learning rate for the Adam optimizer. |
0.001
|
early_stopping_epochs
|
int
|
Number of epochs with no improvement after which training will be stopped. If None, early stopping is disabled. |
100
|
random_seed
|
int
|
Seed for random number generators to ensure reproducibility. |
42
|
Source code in physXAI/models/ann/ann_design.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
generate_model(**kwargs)
Generates the Keras RBF model using RBFModelConstruction.
Source code in physXAI/models/ann/ann_design.py
364 365 366 367 368 369 370 371 | |
get_config() -> dict
Source code in physXAI/models/ann/ann_design.py
373 374 375 376 377 378 379 380 | |
CMNNModel
Bases: ANNModel
A Constrained Monotonic Neural Network (CMNN) model. Allows enforcing monotonicity constraints on input features.
Source code in physXAI/models/ann/ann_design.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
Attributes
n_layers: int = n_layers
instance-attribute
n_neurons: Union[int, list[int]] = n_neurons
instance-attribute
activation_function: Union[str, list[str]] = activation_function
instance-attribute
rescale_output: bool = rescale_output
instance-attribute
monotonies: dict[str, int] = monotonies
instance-attribute
activation_split: list[float] = activation_split
instance-attribute
model_config = {'n_layers': self.n_layers, 'n_neurons': self.n_neurons, 'activation_function': self.activation_function, 'rescale_output': self.rescale_output, 'monotonicities': self.monotonies, 'activation_split': activation_split}
instance-attribute
Functions
__init__(n_layers: int = 1, n_neurons: Union[int, list[int]] = 32, activation_function: Union[str, list[str]] = 'softplus', rescale_output: bool = True, monotonies: dict[str, int] = None, activation_split: list[float] = None, batch_size: int = 32, epochs: int = 1000, learning_rate: float = 0.001, early_stopping_epochs: int = 100, random_seed: int = 42, **kwargs)
Initializes the CMNNModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_layers
|
int
|
Number of hidden layers. |
1
|
n_neurons
|
int or list[int]
|
Number of neurons per layer. |
32
|
activation_function
|
str or list[str]
|
Activation function(s). |
'softplus'
|
rescale_output
|
bool
|
Whether to rescale output. |
True
|
monotonies
|
dict[str, int]
|
Dictionary mapping feature names to monotonicity type (-1 for decreasing, 0 for no constraint, 1 for increasing). |
None
|
activation_split
|
list[float]
|
Proportions for splitting neurons into convex, concave, and saturated activation paths. E.g., [0.5, 0.25, 0.25]. |
None
|
batch_size
|
int
|
Number of samples per gradient update. |
32
|
epochs
|
int
|
Number of times to iterate over the entire training dataset. |
1000
|
learning_rate
|
float
|
Learning rate for the Adam optimizer. |
0.001
|
early_stopping_epochs
|
int
|
Number of epochs with no improvement after which training will be stopped. If None, early stopping is disabled. |
100
|
random_seed
|
int
|
Seed for random number generators to ensure reproducibility. |
42
|
Source code in physXAI/models/ann/ann_design.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
generate_model(**kwargs)
Generates the Keras CMNN model using CMNNModelConstruction.
Source code in physXAI/models/ann/ann_design.py
431 432 433 434 435 436 437 438 | |
get_config() -> dict
Source code in physXAI/models/ann/ann_design.py
440 441 442 443 444 445 446 447 448 449 450 | |
PINNModel
Bases: ANNModel
A Physics-Informed Neural Network (PINN) model. This implementation uses a CMNN as its base architecture and incorporates a custom multi-component loss function.
Source code in physXAI/models/ann/ann_design.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | |
Attributes
n_layers: int = n_layers
instance-attribute
n_neurons: Union[int, list[int]] = n_neurons
instance-attribute
activation_function: Union[str, list[str]] = activation_function
instance-attribute
rescale_output: bool = rescale_output
instance-attribute
monotonies: dict[str, int] = monotonies
instance-attribute
activation_split: list[float] = activation_split
instance-attribute
pinn_weights: list[float] = pinn_weights
instance-attribute
model_config = {'n_layers': self.n_layers, 'n_neurons': self.n_neurons, 'activation_function': self.activation_function, 'rescale_output': self.rescale_output, 'monotonicities': self.monotonies, 'activation_split': activation_split}
instance-attribute
pinn_loss = multi_y_loss(keras.losses.MeanSquaredError(name='MSE'), self.pinn_weights, 'mse')
instance-attribute
pinn_metrics = [multi_y_loss(keras.metrics.RootMeanSquaredError(name='rmse'), self.pinn_weights, 'rmse')]
instance-attribute
Functions
__init__(n_layers: int = 1, n_neurons: Union[int, list[int]] = 32, activation_function: Union[str, list[str]] = 'softplus', pinn_weights: list[float] = None, rescale_output: bool = True, monotonies: dict[str, int] = None, activation_split: list[float] = None, batch_size: int = 32, epochs: int = 1000, learning_rate: float = 0.001, early_stopping_epochs: int = 100, random_seed: int = 42, **kwargs)
Initializes the PINNModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pinn_weights
|
list[float]
|
Weights for the additional components in the multi_y_loss.
The length should be |
None
|
n_layers
|
int
|
Number of hidden layers. |
1
|
n_neurons
|
int or list[int]
|
Number of neurons per layer. |
32
|
activation_function
|
str or list[str]
|
Activation function(s). |
'softplus'
|
rescale_output
|
bool
|
Whether to rescale output. |
True
|
monotonies
|
dict[str, int]
|
Dictionary mapping feature names to monotonicity type (-1 for decreasing, 0 for no constraint, 1 for increasing). |
None
|
activation_split
|
list[float]
|
Proportions for splitting neurons into convex, concave, and saturated activation paths. E.g., [0.5, 0.25, 0.25]. |
None
|
batch_size
|
int
|
Number of samples per gradient update. |
32
|
epochs
|
int
|
Number of times to iterate over the entire training dataset. |
1000
|
learning_rate
|
float
|
Learning rate for the Adam optimizer. |
0.001
|
early_stopping_epochs
|
int
|
Number of epochs with no improvement after which training will be stopped. If None, early stopping is disabled. |
100
|
random_seed
|
int
|
Seed for random number generators to ensure reproducibility. |
42
|
Source code in physXAI/models/ann/ann_design.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | |
generate_model(**kwargs)
Generates the Keras model (typically a CMNN) to be used as the PINN.
Source code in physXAI/models/ann/ann_design.py
511 512 513 514 515 516 517 518 | |
compile_model(model)
Compiles the PINN model with the custom multi_y_loss and corresponding metrics.
Source code in physXAI/models/ann/ann_design.py
520 521 522 523 524 525 526 527 | |
pipeline(td: TrainingDataGeneric, save_path: str = None, plot: bool = True, save_model: bool = True)
Overrides the base pipeline to include PINN weight checking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
td
|
TrainingData
|
The training data, used to infer the number of target components. |
required |
save_path
|
str
|
Path to save the model. |
None
|
plot
|
bool
|
Whether to plot the results. Defaults to True. |
True
|
save_model
|
bool
|
Whether to save the trained model. Defaults to True. |
True
|
Source code in physXAI/models/ann/ann_design.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
online_pipeline(td: TrainingDataGeneric, load_path: str = None, save_path: str = None, plot: bool = True, save_model: bool = True)
Overrides the online pipeline to include PINN weight checking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
td
|
TrainingData
|
The training data, used to infer the number of target components. |
required |
load_path
|
str
|
Path to load the model. |
None
|
save_path
|
str
|
Path to save the model (If None, standard save path of Logger is used). |
None
|
plot
|
bool
|
Whether to plot the results. Defaults to True. |
True
|
save_model
|
bool
|
Whether to save the trained model. Defaults to True. |
True
|
Source code in physXAI/models/ann/ann_design.py
566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
evaluate(model, td: TrainingDataGeneric)
Evaluates the PINN model using custom MetricsPINN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
The keras model to be evaluated. |
required | |
td
|
TrainingData
|
The training data |
required |
Source code in physXAI/models/ann/ann_design.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | |
load_model(load_path: str)
Loads a Keras model from the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
load_path
|
str
|
The path from which to load the model. |
required |
Returns:
| Type | Description |
|---|---|
|
keras.Model: The loaded Keras model. |
Source code in physXAI/models/ann/ann_design.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
get_config() -> dict
Source code in physXAI/models/ann/ann_design.py
616 617 618 619 620 621 622 623 624 625 626 627 | |
RNNModel
Bases: MultiStepModel
A Recurrent Neural Network (RNN) model for multi-step forecasting. Inherits from MultiStepModel.
Source code in physXAI/models/ann/ann_design.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | |
Attributes
epochs: int = epochs
instance-attribute
learning_rate: float = learning_rate
instance-attribute
early_stopping_epochs: int = early_stopping_epochs
instance-attribute
random_seed: int = random_seed
instance-attribute
rnn_units: int = rnn_units
instance-attribute
rnn_layer: str = rnn_layer
instance-attribute
init_layer: str = init_layer
instance-attribute
model_config = {'rnn_units': rnn_units, 'init_layer': init_layer, 'rnn_layer': rnn_layer}
instance-attribute
Functions
__init__(rnn_units: int = 32, rnn_layer: str = 'RNN', init_layer=None, epochs: int = 1000, learning_rate: float = 0.001, early_stopping_epochs: Optional[int] = 100, random_seed: int = 42, **kwargs)
Initializes the RNNModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rnn_units
|
int
|
Number of units in the RNN layer. |
32
|
rnn_layer
|
str
|
Type of RNN layer ('RNN', 'LSTM', 'GRU'). |
'RNN'
|
init_layer
|
str
|
Type of layer ('dense', 'RNN', 'LSTM', 'GRU')
used for initializing RNN state if warmup is used.
Defaults to the same as |
None
|
epochs
|
int
|
Number of times to iterate over the entire training dataset. |
1000
|
learning_rate
|
float
|
Learning rate for the Adam optimizer. |
0.001
|
early_stopping_epochs
|
int
|
Number of epochs with no improvement after which training will be stopped. If None, early stopping is disabled. |
100
|
random_seed
|
int
|
Seed for random number generators to ensure reproducibility. |
42
|
Source code in physXAI/models/ann/ann_design.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
generate_model(**kwargs)
Generates the Keras RNN model using RNNModelConstruction.
Source code in physXAI/models/ann/ann_design.py
676 677 678 679 680 681 682 683 | |
compile_model(model)
Compiles the RNN model.
Source code in physXAI/models/ann/ann_design.py
685 686 687 688 689 690 691 | |
fit_model(model, td: TrainingDataMultiStep)
Fits the Keras model to the training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Keras model to fit. |
required |
td
|
TrainingDataMultiStep
|
The TrainingData object from TrainingDataMultiStep |
required |
Source code in physXAI/models/ann/ann_design.py
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 | |
plot(td: TrainingDataMultiStep)
Generates and displays various plots related to model performance and training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
td
|
TrainingDataMultiStep
|
The TrainingData object from TrainingDataMultiStep |
required |
Source code in physXAI/models/ann/ann_design.py
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | |
save_model(model, save_path: str)
Saves the Keras model to the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The Keras model to save. |
required |
save_path
|
str
|
The directory or full path where the model should be saved. |
required |
Source code in physXAI/models/ann/ann_design.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 | |
load_model(load_path: str)
Loads a Keras model from the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
load_path
|
str
|
The path from which to load the model. |
required |
Returns:
| Type | Description |
|---|---|
|
keras.Model: The loaded Keras model. |
Source code in physXAI/models/ann/ann_design.py
769 770 771 772 773 774 775 776 777 778 779 780 781 782 | |
get_config() -> dict
Source code in physXAI/models/ann/ann_design.py
784 785 786 787 788 789 790 791 792 793 794 795 | |