regressor
DARTSExecutionMonitor
A monitor of the execution of the DARTS algorithm.
Source code in src/autora/theorist/darts/regressor.py
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
|
__init__()
Initializes the execution monitor.
Source code in src/autora/theorist/darts/regressor.py
779 780 781 782 783 784 785 786 |
|
display()
A function to display the execution monitor. This function will generate two plots: (1) A plot of the training loss vs. epoch, (2) a plot of the architecture weights vs. epoch, divided into subplots by each edge in the mixture architecture.
Source code in src/autora/theorist/darts/regressor.py
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
|
execution_monitor(network, architect, epoch, **kwargs)
A function to monitor the execution of the DARTS algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
network |
Network
|
The DARTS network containing the weights each operation in the mixture architecture |
required |
architect |
Architect
|
The architect object used to construct the mixture architecture. |
required |
epoch |
int
|
The current epoch of the training. |
required |
**kwargs |
Any
|
other parameters which may be passed from the DARTS optimizer |
{}
|
Source code in src/autora/theorist/darts/regressor.py
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 |
|
DARTSRegressor
Bases: BaseEstimator
, RegressorMixin
Differentiable ARchiTecture Search Regressor.
DARTS finds a composition of functions and coefficients to minimize a loss function suitable for the dependent variable.
This class is intended to be compatible with the Scikit-Learn Estimator API.
Examples:
>>> import numpy as np
>>> num_samples = 1000
>>> X = np.linspace(start=0, stop=1, num=num_samples).reshape(-1, 1)
>>> y = 15. * np.ones(num_samples)
>>> estimator = DARTSRegressor(num_graph_nodes=1)
>>> estimator = estimator.fit(X, y)
>>> estimator.predict([[0.5]])
array([[15.051043]], dtype=float32)
Attributes:
Name | Type | Description |
---|---|---|
network_ |
Optional[Network]
|
represents the optimized network for the architecture search, without the output function |
model_ |
Optional[Network]
|
represents the best-fit model including the output function
after sampling of the network to pick a single computation graph.
By default, this is the computation graph with the maximum weights,
but can be set to a graph based on a sample on the edge weights
by running the |
Source code in src/autora/theorist/darts/regressor.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 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 628 629 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 |
|
__init__(batch_size=64, num_graph_nodes=2, output_type='real', classifier_weight_decay=0.01, darts_type='original', init_weights_function=None, param_updates_per_epoch=10, param_updates_for_sampled_model=100, param_learning_rate_max=0.025, param_learning_rate_min=0.01, param_momentum=0.9, param_weight_decay=0.0003, arch_updates_per_epoch=1, arch_learning_rate_max=0.003, arch_weight_decay=0.0001, arch_weight_decay_df=0.0003, arch_weight_decay_base=0.0, arch_momentum=0.9, fair_darts_loss_weight=1, max_epochs=10, grad_clip=5, primitives=PRIMITIVES, train_classifier_coefficients=False, train_classifier_bias=False, execution_monitor=lambda : None, sampling_strategy='max')
Initializes the DARTSRegressor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_size |
int
|
Batch size for the data loader. |
64
|
num_graph_nodes |
int
|
Number of nodes in the desired computation graph. |
2
|
output_type |
IMPLEMENTED_OUTPUT_TYPES
|
Type of output function to use. This function is applied to transform the output of the mixture architecture. |
'real'
|
classifier_weight_decay |
float
|
Weight decay for the classifier. |
0.01
|
darts_type |
IMPLEMENTED_DARTS_TYPES
|
Type of DARTS to use ('original' or 'fair'). |
'original'
|
init_weights_function |
Optional[Callable]
|
Function to initialize the parameters of each operation. |
None
|
param_updates_per_epoch |
int
|
Number of updates to perform per epoch. for the operation parameters. |
10
|
param_learning_rate_max |
float
|
Initial (maximum) learning rate for the operation parameters. |
0.025
|
param_learning_rate_min |
float
|
Final (minimum) learning rate for the operation parameters. |
0.01
|
param_momentum |
float
|
Momentum for the operation parameters. |
0.9
|
param_weight_decay |
float
|
Weight decay for the operation parameters. |
0.0003
|
arch_updates_per_epoch |
int
|
Number of architecture weight updates to perform per epoch. |
1
|
arch_learning_rate_max |
float
|
Initial (maximum) learning rate for the architecture. |
0.003
|
arch_weight_decay |
float
|
Weight decay for the architecture weights. |
0.0001
|
arch_weight_decay_df |
float
|
An additional weight decay that scales with the number of parameters (degrees of freedom) in the operation. The higher this weight decay, the more DARTS will prefer simple operations. |
0.0003
|
arch_weight_decay_base |
float
|
A base weight decay that is added to the scaled weight decay. arch_momentum: Momentum for the architecture weights. |
0.0
|
fair_darts_loss_weight |
int
|
Weight of the loss in fair darts which forces architecture weights to become either 0 or 1. |
1
|
max_epochs |
int
|
Maximum number of epochs to train for. |
10
|
grad_clip |
float
|
Gradient clipping value for updating the parameters of the operations. |
5
|
primitives |
Sequence[str]
|
List of primitives (operations) to use. |
PRIMITIVES
|
train_classifier_coefficients |
bool
|
Whether to train the coefficients of the classifier. |
False
|
train_classifier_bias |
bool
|
Whether to train the bias of the classifier. |
False
|
execution_monitor |
Callable
|
Function to monitor the execution of the model. |
lambda : None
|
primitives |
Sequence[str]
|
list of primitive operations used in the DARTS network,
e.g., 'add', 'subtract', 'none'. For details, see
|
PRIMITIVES
|
Source code in src/autora/theorist/darts/regressor.py
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 |
|
fit(X, y)
Runs the optimization for a given set of X
s and y
s.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
np.ndarray
|
independent variables in an n-dimensional array |
required |
y |
np.ndarray
|
dependent variables in an n-dimensional array |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
DARTSRegressor
|
the fitted estimator |
Source code in src/autora/theorist/darts/regressor.py
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 |
|
model_repr(input_labels=None, output_labels=None, output_function_label='', decimals_to_display=2, output_format='console')
Prints the equations of the model architecture.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_labels |
Optional[Sequence[str]]
|
which names to use for the independent variables (X) |
None
|
output_labels |
Optional[Sequence[str]]
|
which names to use for the dependent variables (y) |
None
|
output_function_label |
str
|
name to use for the output transformation |
''
|
decimals_to_display |
int
|
amount of rounding for the coefficient values |
2
|
output_format |
Literal['latex', 'console']
|
whether the output should be formatted for
the command line ( |
'console'
|
Returns:
Type | Description |
---|---|
str
|
The equations of the model architecture |
Source code in src/autora/theorist/darts/regressor.py
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 |
|
predict(X)
Applies the fitted model to a set of independent variables X
,
to give predictions for the dependent variable y
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
np.ndarray
|
independent variables in an n-dimensional array |
required |
Returns:
Name | Type | Description |
---|---|---|
y |
np.ndarray
|
predicted dependent variable values |
Source code in src/autora/theorist/darts/regressor.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
|
visualize_model(input_labels=None)
Visualizes the model architecture as a graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_labels |
Optional[Sequence[str]]
|
labels for the input nodes |
None
|
Source code in src/autora/theorist/darts/regressor.py
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 |
|