Simulai adjusters
Loss terms adjusters/rescalers #
WeightsEstimator #
Source code in simulai/optimization/_adjusters.py
8 9 10 11 12 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 52 53 54 55 |
|
GeometricMean #
Source code in simulai/optimization/_adjusters.py
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 |
|
__call__(residual=List[torch.Tensor], loss_evaluator=Callable, loss_history=Dict[str, float], **kwargs)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
residual |
List[Tensor]
|
List containing all the equation-based loss terms. |
List[Tensor]
|
loss_evaluator |
Callable
|
A Python class or function for evaluating the loss function. |
Callable
|
Source code in simulai/optimization/_adjusters.py
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 |
|
__init__()
#
Simple and naive approach for balancing the loss terms in which they are rescaled to have the same order of magnitude of the geometric mean between all the terms.
Source code in simulai/optimization/_adjusters.py
64 65 66 67 68 69 |
|
ShiftToMax #
Source code in simulai/optimization/_adjusters.py
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 |
|
__call__(residual=List[torch.Tensor], loss_evaluator=Callable, loss_history=Dict[str, float], **kwargs)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
residual |
List[Tensor]
|
List containing all the equation-based loss terms. |
List[Tensor]
|
loss_evaluator |
Callable
|
A Python class or function for evaluating the loss function. |
Callable
|
Source code in simulai/optimization/_adjusters.py
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 |
|
__init__()
#
Simple and naive approach for balancing the loss terms in which they are rescaled to have the same order of magnitude of the maximum value of all the terms.
Source code in simulai/optimization/_adjusters.py
99 100 101 102 103 104 105 |
|
AnnealingWeights #
Bases: WeightsEstimator
Source code in simulai/optimization/_adjusters.py
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 |
|
__call__(residual=None, operator=None, **kwargs)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
residual |
tensor
|
Tensor containing the equation residual. |
None
|
operator |
NetworkTemplate
|
Model being trained. |
None
|
Returns:
Type | Description |
---|---|
List[tensor]
|
List[torch.tensor]: A list containing the updated loss weights. |
Source code in simulai/optimization/_adjusters.py
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 |
|
__init__(alpha=None, init_weight=1.0, bound_weight=1.0, extra_data_weight=1.0)
#
Learning rate Annealing technique used for scaling equation-based loss terms (see https://arxiv.org/abs/2001.04536)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alpha |
float
|
1 - update step. |
None
|
init_weight |
float
|
Initial value for the initial condition weight. |
1.0
|
bound_weight |
float
|
Initial value for the boundary condition weight. |
1.0
|
extra_data_weight |
float
|
Initial value for the weight related to data-drive loss terms. |
1.0
|
Source code in simulai/optimization/_adjusters.py
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 |
|
InverseDirichletWeights #
Bases: WeightsEstimator
Source code in simulai/optimization/_adjusters.py
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 262 263 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 |
|
__call__(residual=None, loss_evaluator=None, loss_history=None, operator=None, **kwargs)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
residual |
List[Tensor]
|
List of equation-based loss terms. |
None
|
loss_evaluator |
Callable
|
Python function or class which evaluates the loss function. |
None
|
operator |
Callable
|
Model being trained. |
None
|
Returns: List[torch.Tensor]: List of loss updated loss terms.
Source code in simulai/optimization/_adjusters.py
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 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
__init__(alpha=None, initial_weights=None)
#
Inverse Dirichlet technique used for scaling equation-based loss terms (see https://iopscience.iop.org/article/10.1088/2632-2153/ac3712/pdf)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alpha |
float
|
1 - update step. |
None
|
initial_weights |
List[float]
|
List containing the initial states of all the loss function terms. |
None
|
Source code in simulai/optimization/_adjusters.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|