Built-in Optimizers
+ +Built-in Optimizers#
+SpaRSA#
+ + +Source code in simulai/optimization/_builtin.py
+ 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 + 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 |
|
+ __init__(lambd=None, alpha_0=None, epsilon=1e-10, sparsity_tol=1e-15, use_mean=False, transform=None)
+
+#
+
+
+ Sparse Regression Algorithm
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
lambd |
+
+ float
+ |
+
+
+
+ Quadratic regularization penalty. + |
+
+ None
+ |
+
alpha_0 |
+
+ float
+ |
+
+
+
+ Update step lenght. + |
+
+ None
+ |
+
epsilon |
+
+ float
+ |
+
+
+
+ Error tolerance. + |
+
+ 1e-10
+ |
+
sparsity_tol |
+
+ float
+ |
+
+
+
+ Sparsity tolerance. + |
+
+ 1e-15
+ |
+
use_mean |
+
+ bool
+ |
+
+
+
+ Use mean for evaluating loss or not. + |
+
+ False
+ |
+
transform |
+
+ callable
+ |
+
+
+
+ A transformation to be applied to the data. + |
+
+ None
+ |
+
Source code in simulai/optimization/_builtin.py
+ 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 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 |
|
+ fit(input_data=None, target_data=None)
+
+#
+
+
+ Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
input_data |
+
+ ndarray
+ |
+
+
+
+ Input data for training the model. + |
+
+ None
+ |
+
target_data |
+
+ ndarray
+ |
+
+
+
+ Target data for training the model. + |
+
+ None
+ |
+
Returns:
+ +Source code in simulai/optimization/_builtin.py
+ 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 |
|
BBI#
+ + +
+ Bases: Optimizer
Source code in simulai/optimization/_builtin_pytorch.py
+ 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 + 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 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 |
|
+ __init__(params=None, lr=0.001, eps1=1e-10, eps2=1e-40, v0=0, threshold0=1000, threshold=3000, deltaEn=0.0, consEn=True, n_fixed_bounces=1)
+
+#
+
+
+ Optimizer based on the BBI model of inflation.
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
params |
+
+ iterable
+ |
+
+
+
+ iterable of parameters to optimize or dicts defining parameter groups + |
+
+ None
+ |
+
lr |
+
+ float
+ |
+
+
+
+ learning rate + |
+
+ 0.001
+ |
+
v0 |
+
+ float
+ |
+
+
+
+ expected minimum of the potential (Delta V in the paper) + |
+
+ 0
+ |
+
threshold0 |
+
+ int
+ |
+
+
+
+ threshold for fixed bounces (T0 in the paper) + |
+
+ 1000
+ |
+
threshold1 |
+
+ int
+ |
+
+
+
+ threshold for progress-dependent bounces (T1 in the paper) + |
+ + required + | +
deltaEn |
+
+ float
+ |
+
+
+
+ extra initial energy (delta E in the paper) + |
+
+ 0.0
+ |
+
consEn |
+
+ bool
+ |
+
+
+
+ if True enforces energy conservation at every step + |
+
+ True
+ |
+
n_fixed_bounces |
+
+ int
+ |
+
+
+
+ number of bounces every T0 iterations (Nb in the paper) + |
+
+ 1
+ |
+
Source code in simulai/optimization/_builtin_pytorch.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 |
|
+ step(closure)
+
+#
+
+
+ Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
closure |
+
+ callable
+ |
+
+
+
+ A function which enclosures the loss +evaluation. + |
+ + required + | +
Returns: + torch.Tensor: The evaluation for the loss function.
+ +Source code in simulai/optimization/_builtin_pytorch.py
+ 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 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 |
|