nodes
nodes
¤
TorchBinaryParameterOp
¤
Bases: TorchParameterOp, ABC
Source code in cirkit/backend/torch/parameters/nodes.py
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 381 | |
config
property
¤
in_shape1
property
¤
in_shape2
property
¤
__call__(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
377 378 | |
__init__(in_shape1, in_shape2, *, num_folds=1)
¤
Initialize the parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_shape1
|
tuple[int, ...]
|
The shape of the first input without the fold dimension. \((K_1,\dots,K_n)\) |
required |
in_shape2
|
tuple[int, ...]
|
The shape of the second input without the fold dimension. \((L_1,\dots,L_n)\) |
required |
num_folds
|
int
|
number of fold for the input. |
1
|
Source code in cirkit/backend/torch/parameters/nodes.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
forward(x1, x2)
abstractmethod
¤
Source code in cirkit/backend/torch/parameters/nodes.py
380 381 | |
TorchClampParameter
¤
Bases: TorchEntrywiseParameterOp
Exp reparameterization.
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
config
property
¤
vmax = vmax
instance-attribute
¤
vmin = vmin
instance-attribute
¤
__init__(in_shape, vmin=None, vmax=None, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
706 707 708 709 710 711 712 713 714 715 716 717 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
728 729 | |
TorchConjugateParameter
¤
Bases: TorchEntrywiseParameterOp
Conjugate parameterization.
Source code in cirkit/backend/torch/parameters/nodes.py
743 744 745 746 747 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
746 747 | |
TorchEntrywiseParameterOp
¤
Bases: TorchUnaryParameterOp, ABC
Source code in cirkit/backend/torch/parameters/nodes.py
384 385 386 387 | |
shape
property
¤
TorchEntrywiseReduceParameterOp
¤
Bases: TorchEntrywiseParameterOp, ABC
The base class for normalized reparameterization.
Source code in cirkit/backend/torch/parameters/nodes.py
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
config
property
¤
dim = dim
instance-attribute
¤
__init__(in_shape, *, dim=-1, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
432 433 434 435 436 437 438 439 440 441 442 | |
TorchExpParameter
¤
Bases: TorchEntrywiseParameterOp
Exp reparameterization.
Source code in cirkit/backend/torch/parameters/nodes.py
657 658 659 660 661 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
660 661 | |
TorchFlattenParameter
¤
Bases: TorchUnaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
config
property
¤
end_dim = end_dim
instance-attribute
¤
shape
cached
property
¤
start_dim = start_dim
instance-attribute
¤
__init__(in_shape, num_folds=1, start_dim=0, end_dim=-1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
844 845 | |
TorchGaussianProductLogPartition
¤
Bases: TorchParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 | |
config
property
¤
shape
property
¤
__init__(in_mean1_shape, in_stddev1_shape, in_mean2_shape, in_stddev2_shape, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 | |
forward(mean1, stddev1, mean2, stddev2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
976 977 978 979 980 981 982 983 984 985 986 987 988 989 | |
TorchGaussianProductMean
¤
Bases: TorchParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | |
config
property
¤
shape
property
¤
__init__(in_mean1_shape, in_stddev1_shape, in_mean2_shape, in_stddev2_shape, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | |
forward(mean1, stddev1, mean2, stddev2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
899 900 901 902 903 904 905 906 907 908 | |
TorchGaussianProductStddev
¤
Bases: TorchBinaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 | |
config
property
¤
shape
property
¤
__init__(in_stddev1_shape, in_stddev2_shape, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
912 913 914 915 916 917 918 919 | |
forward(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
932 933 934 935 936 937 938 939 | |
TorchHadamardParameter
¤
Bases: TorchBinaryParameterOp
Hadamard product reparameterization.
Source code in cirkit/backend/torch/parameters/nodes.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | |
shape
property
¤
__init__(in_shape1, in_shape2, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
514 515 516 517 518 519 520 521 522 | |
forward(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
528 529 | |
TorchIndexParameter
¤
Bases: TorchUnaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
config
property
¤
dim = dim
instance-attribute
¤
indices
property
¤
shape
property
¤
__init__(in_shape, indices, dim=-1, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
488 489 | |
TorchKroneckerParameter
¤
Bases: TorchBinaryParameterOp
Kronecker product reparameterization.
Source code in cirkit/backend/torch/parameters/nodes.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
shape
cached
property
¤
__init__(in_shape1, in_shape2, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
535 536 537 538 539 540 541 542 543 544 | |
forward(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
550 551 | |
TorchLogParameter
¤
Bases: TorchEntrywiseParameterOp
Log reparameterization.
Source code in cirkit/backend/torch/parameters/nodes.py
664 665 666 667 668 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
667 668 | |
TorchLogSoftmaxParameter
¤
Bases: TorchEntrywiseReduceParameterOp
Log-Softmax reparameterization.
Range: (-inf, 0). Constraints: logsumexp is 0.
Source code in cirkit/backend/torch/parameters/nodes.py
776 777 778 779 780 781 782 783 784 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
783 784 | |
TorchMatMulParameter
¤
Bases: TorchBinaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
shape
property
¤
__init__(in_shape1, in_shape2, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
788 789 790 791 792 793 794 795 796 797 | |
forward(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
803 804 805 806 | |
TorchMixingWeightParameter
¤
Bases: TorchUnaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | |
shape
property
¤
__init__(in_shape, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
849 850 851 852 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
858 859 860 861 862 863 | |
TorchOuterProductParameter
¤
Bases: TorchBinaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
config
property
¤
dim = dim
instance-attribute
¤
shape
property
¤
__init__(in_shape1, in_shape2, dim=-1, *, num_folds=1)
¤
Initialize the reduce operation using the shapes and dimensions.
The two inputs need to have the same dimensions except for the one at the index
\(i\) on which we want to reduce. The parameter dim specify \(i\), but as the actual
computations involve a fold dimension, the value of dim will always be shifted by one.
In the actual computation \(i=\text{dim}+1\) to take the fold into account.
\(i_1\) and \(i_2\) denotes the same position in the shape (same dimension) but different dimension sizes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_shape1
|
tuple[int, ...]
|
Shape of the first input vector without the fold dimension. \((K_1,\dots,K_{i_1}, \dots, K_n)\). |
required |
in_shape2
|
tuple[int, ...]
|
Shape of the second input vector without the fold dimension. \((K_1,\dots,K_{i_2}, \dots, K_n)\). |
required |
dim
|
int
|
Dimension on which we want to reduce. This dimension index is
on the |
-1
|
num_folds
|
int
|
Number of folds for the input vector. |
1
|
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
forward(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
606 607 608 609 610 611 612 613 | |
TorchOuterSumParameter
¤
Bases: TorchBinaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
config
property
¤
dim = dim
instance-attribute
¤
shape
property
¤
__init__(in_shape1, in_shape2, *, num_folds=1, dim=-1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |
forward(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
647 648 649 650 651 652 653 654 | |
TorchParameterInput
¤
Bases: TorchParameterNode, ABC
The torch parameter input node. A parameter input is a parameter node in the computational graph that comptues parameter that does not have inputs. See TorchParameter for more details.
Source code in cirkit/backend/torch/parameters/nodes.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
__call__()
¤
Source code in cirkit/backend/torch/parameters/nodes.py
60 61 | |
extra_repr()
¤
Source code in cirkit/backend/torch/parameters/nodes.py
63 64 | |
forward()
abstractmethod
¤
Evaluate a torch parameter input node.
Returns:
| Name | Type | Description |
|---|---|---|
Tensor |
Tensor
|
A tensor of shape \((F,K_1,\ldots,K_n)\), where \(F\) is the number of folds, and |
Tensor
|
\((K_1,\ldots,K_n)\) is the shape of the tensors within each fold. |
Source code in cirkit/backend/torch/parameters/nodes.py
66 67 68 69 70 71 72 73 | |
TorchParameterNode
¤
Bases: AbstractTorchModule, ABC
The abstract parameter node class. A parameter node is a node in the computational graph that computes parameters. See TorchParameter for more details.
Source code in cirkit/backend/torch/parameters/nodes.py
13 14 15 16 17 18 19 20 21 22 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 | |
config
property
¤
Retrieves the configuration of the parameter node, i.e., a dictionary mapping
hyperparameters of the parameter node to their values. The hyperparameter names must
match the argument names in the __init__ method.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict[str, Any]: A dictionary from hyperparameter names to their value. |
fold_settings
property
¤
shape
abstractmethod
property
¤
sub_modules
property
¤
reset_parameters()
¤
Source code in cirkit/backend/torch/parameters/nodes.py
50 51 | |
TorchParameterOp
¤
Bases: TorchParameterNode, ABC
Base abstract class for Parameter node that do computations
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
config
property
¤
in_shapes
property
¤
__init__(*in_shapes, num_folds=1)
¤
Initialize the parameter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*in_shapes
|
tuple[int, ...]
|
The shapes of each input that the parameter accepts. Important: This shape does not include the fold dimension: \((K_1,\dots,K_n)\). |
()
|
num_folds
|
int
|
The number of folds used for all inputs. |
1
|
Source code in cirkit/backend/torch/parameters/nodes.py
286 287 288 289 290 291 292 293 294 295 296 | |
extra_repr()
¤
Source code in cirkit/backend/torch/parameters/nodes.py
306 307 308 309 310 311 | |
TorchPointerParameter
¤
Bases: TorchParameterInput
Reprensents fold based slices of an existing TorchTensorParameter. These slices can be: - A single fold index. - A list of potentially non contiguous fold index. - The full tensor.
Source code in cirkit/backend/torch/parameters/nodes.py
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 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
config
property
¤
fold_idx
property
¤
shape
property
¤
The shape of the output parameter.
__init__(parameter, *, fold_idx=None)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
deref()
¤
Source code in cirkit/backend/torch/parameters/nodes.py
275 276 | |
forward()
¤
Source code in cirkit/backend/torch/parameters/nodes.py
278 279 280 | |
TorchPolynomialDifferential
¤
Bases: TorchUnaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | |
order = order
instance-attribute
¤
shape
property
¤
__init__(in_shape, *, num_folds=1, order=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
1026 1027 1028 1029 1030 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
1046 1047 1048 1049 1050 1051 1052 | |
TorchPolynomialProduct
¤
Bases: TorchBinaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | |
shape
property
¤
forward(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | |
TorchReduceLSEParameter
¤
Bases: TorchReduceParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
760 761 762 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
761 762 | |
TorchReduceParameterOp
¤
Bases: TorchUnaryParameterOp, ABC
The base class for normalized reparameterization.
Source code in cirkit/backend/torch/parameters/nodes.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 | |
config
property
¤
dim = dim
instance-attribute
¤
shape
property
¤
__init__(in_shape, dim=-1, *, num_folds=1)
¤
Initialize the reduce operation using the shapes and dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_shape
|
tuple[int, ...]
|
Shape of the input vector without the fold dimension. \((K_1,\dots,K_n)\). |
required |
dim
|
int
|
Dimension on which we want to reduce. This dimension index is
on the |
-1
|
num_folds
|
int
|
Number of folds for the input vector. |
1
|
Source code in cirkit/backend/torch/parameters/nodes.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
TorchReduceProductParameter
¤
Bases: TorchReduceParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
755 756 757 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
756 757 | |
TorchReduceSumParameter
¤
Bases: TorchReduceParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
750 751 752 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
751 752 | |
TorchScaledSigmoidParameter
¤
Bases: TorchEntrywiseParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | |
config
property
¤
vmax = vmax
instance-attribute
¤
vmin = vmin
instance-attribute
¤
__init__(in_shape, vmin, vmax, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
684 685 686 687 688 689 690 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
699 700 | |
TorchSigmoidParameter
¤
Bases: TorchEntrywiseParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
678 679 680 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
679 680 | |
TorchSoftmaxParameter
¤
Bases: TorchEntrywiseReduceParameterOp
Softmax reparameterization.
Range: (0, 1), 0 available if input is masked, 1 available when only one element valid. Constraints: sum to 1.
Source code in cirkit/backend/torch/parameters/nodes.py
765 766 767 768 769 770 771 772 773 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
772 773 | |
TorchSoftplusParameter
¤
Bases: TorchEntrywiseParameterOp
Softmax reparameterization.
Range: (0, + inf), 0 available if input is masked. Constraints: Positive.
Source code in cirkit/backend/torch/parameters/nodes.py
732 733 734 735 736 737 738 739 740 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
739 740 | |
TorchSquareParameter
¤
Bases: TorchEntrywiseParameterOp
Square reparameterization.
Source code in cirkit/backend/torch/parameters/nodes.py
671 672 673 674 675 | |
forward(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
674 675 | |
TorchSumParameter
¤
Bases: TorchBinaryParameterOp
Source code in cirkit/backend/torch/parameters/nodes.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
shape
property
¤
__init__(in_shape1, in_shape2, *, num_folds=1)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
493 494 495 496 497 498 499 500 501 | |
forward(x1, x2)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
507 508 | |
TorchTensorParameter
¤
Bases: TorchParameterInput
A torch tensor parameter is a TorchParameterInput that stores a torch.nn.parameter.Parameter object.
Source code in cirkit/backend/torch/parameters/nodes.py
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
config
property
¤
device
property
¤
Retrieve the device of the parameter.
Returns:
| Type | Description |
|---|---|
device
|
torch.device: The parameter device. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the parameter has not been initialized. See the reset_parameters method. |
dtype
property
¤
Retrieve the data type of the parameter.
Returns:
| Type | Description |
|---|---|
dtype
|
torch.dtype: The parameter data type. |
fold_settings
property
¤
initializer
property
¤
requires_grad
property
writable
¤
Retrieve whether the torch parameter requires gradients.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if it requires gradients, False otherwise. |
shape
property
¤
__init__(*shape, requires_grad=True, dtype=None, initializer_=None, num_folds=1)
¤
Initializes a torch tensor parameter. Given a shape \((K_1,\ldots,K_n)\) and a number of folds \(F\), it eventually materializes a torch parameter of shape \((F,K_1,\ldots,K_n)\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*shape
|
int
|
The shape of the tensor parameter folds \((K_1,\ldots,K_n)\). |
()
|
requires_grad
|
bool
|
Whether the parameter requires the computation of gradients. |
True
|
dtype
|
dtype | None
|
The data type of the parameter. If it is None, then it defaults to the current default torch data type, i.e., it is given by torch.get_default_dtype. |
None
|
initializer_
|
Callable[[Tensor], Tensor] | None
|
The in-place initializer used to initialize the tensor parameter. It is a callable with only a tensor as input. If it is None, then it defaults to sampling from a standard normal distribution, i.e., torch.nn.init.normal_. |
None
|
num_folds
|
int
|
The number of folds \(F\). |
1
|
Source code in cirkit/backend/torch/parameters/nodes.py
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 | |
forward()
¤
Evaluate a torch parameter input node.
Returns:
| Name | Type | Description |
|---|---|---|
Tensor |
Tensor
|
A tensor of shape \((F,K_1,\ldots,K_n)\), where \(F\) is the number of folds, and |
Tensor
|
\((K_1,\ldots,K_n)\) is the shape of the tensors within each fold. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the parameter has not been initialized. See the reset_parameters method. |
Source code in cirkit/backend/torch/parameters/nodes.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
reset_parameters()
¤
Allocate and initialize the torch tensor parameter. If the tensor has already been allocated, then this function simply call the initializer to reset the parameter values.
Source code in cirkit/backend/torch/parameters/nodes.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
TorchUnaryParameterOp
¤
Bases: TorchParameterOp, ABC
Abstract class for operators with a single input.
Source code in cirkit/backend/torch/parameters/nodes.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
config
property
¤
in_shape
property
¤
__call__(x)
¤
Source code in cirkit/backend/torch/parameters/nodes.py
336 337 | |
__init__(in_shape, *, num_folds=1)
¤
Initialize the parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_shape
|
tuple[int, ...]
|
The shape of the input without the fold dimension. \((K_1,\dots,K_n)\) |
required |
num_folds
|
int
|
number of fold for the input. |
1
|
Source code in cirkit/backend/torch/parameters/nodes.py
317 318 319 320 321 322 323 324 325 | |
forward(x)
abstractmethod
¤
Source code in cirkit/backend/torch/parameters/nodes.py
339 340 | |