LSST Applications 29.1.0,g0fba68d861+6b120c4394,g123d84c11c+8c5ae1fdc5,g1ec0fe41b4+191117f6ec,g1fd858c14a+c8450ae71a,g3533f9d6cb+a04f9ee0ab,g35bb328faa+8c5ae1fdc5,g3f0dcc2b1b+7df08700bd,g4178042926+b4254969db,g44ba364a48+04455b336b,g53246c7159+8c5ae1fdc5,g60b5630c4e+a04f9ee0ab,g663da51e9b+b05e6e1875,g67b6fd64d1+250bf6acd3,g78460c75b0+7e33a9eb6d,g786e29fd12+668abc6043,g8352419a5c+8c5ae1fdc5,g87e3079a85+d3fa38de54,g8852436030+cd899e2626,g89139ef638+250bf6acd3,g93a033419f+31ead11197,g989de1cb63+250bf6acd3,g9f33ca652e+f6053ecf14,ga1e959baac+5fbc491aed,ga2f891cd6c+a04f9ee0ab,gabe3b4be73+8856018cbb,gabf8522325+1f7e6d67b9,gac2eed3f23+250bf6acd3,gb1101e3267+0c331e9486,gb89ab40317+250bf6acd3,gcf25f946ba+cd899e2626,gd107969129+8964d67276,gd6cbbdb0b4+6bbecc8878,gde0f65d7ad+d65f9e019a,ge278dab8ac+eb3bbeb12f,ge410e46f29+250bf6acd3,gf5e32f922b+8c5ae1fdc5,gff02db199a+747430a128,gffe7e49bb4+a04f9ee0ab
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.scarlet.lite.parameters Namespace Reference

Classes

class  AdaproxParameter
 
class  FistaParameter
 
class  FixedParameter
 
class  Parameter
 
class  SingleItemArray
 

Functions

Callable step_function_wrapper (float step)
 
Parameter parameter (np.ndarray|Parameter x)
 
 _adam_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _nadam_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _amsgrad_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _padam_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _adamx_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _radam_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 relative_step (np.ndarray x, float factor=0.1, float minimum=0, int|Sequence[int]|None axis=None)
 

Variables

int DEFAULT_ADAPROX_FACTOR = 1e-2
 
dict phi_psi
 

Function Documentation

◆ _adam_phi_psi()

lsst.scarlet.lite.parameters._adam_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 243 of file parameters.py.

243def _adam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
244 # moving averages
245 m[:] = (1 - b1[it]) * g + b1[it] * m
246 v[:] = (1 - b2) * (g**2) + b2 * v
247
248 # bias correction
249 t = it + 1
250 phi = m / (1 - b1[it] ** t)
251 psi = np.sqrt(v / (1 - b2**t)) + eps
252 return phi, psi
253
254
255# noinspection PyUnusedLocal

◆ _adamx_phi_psi()

lsst.scarlet.lite.parameters._adamx_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 298 of file parameters.py.

298def _adamx_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
299 # moving averages
300 m[:] = (1 - b1[it]) * g + b1[it] * m
301 v[:] = (1 - b2) * (g**2) + b2 * v
302
303 phi = m
304 factor = (1 - b1[it]) ** 2 / (1 - b1[it - 1]) ** 2
305 vhat[:] = np.maximum(factor * vhat, v)
306 # sanitize zero-gradient elements
307 if eps > 0:
308 vhat = np.maximum(vhat, eps)
309 psi = np.sqrt(vhat)
310 return phi, psi
311
312
313# noinspection PyUnusedLocal

◆ _amsgrad_phi_psi()

lsst.scarlet.lite.parameters._amsgrad_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 269 of file parameters.py.

269def _amsgrad_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
270 # moving averages
271 m[:] = (1 - b1[it]) * g + b1[it] * m
272 v[:] = (1 - b2) * (g**2) + b2 * v
273
274 phi = m
275 vhat[:] = np.maximum(vhat, v)
276 # sanitize zero-gradient elements
277 if eps > 0:
278 vhat = np.maximum(vhat, eps)
279 psi = np.sqrt(vhat)
280 return phi, psi
281
282

◆ _nadam_phi_psi()

lsst.scarlet.lite.parameters._nadam_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 256 of file parameters.py.

256def _nadam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
257 # moving averages
258 m[:] = (1 - b1[it]) * g + b1[it] * m
259 v[:] = (1 - b2) * (g**2) + b2 * v
260
261 # bias correction
262 t = it + 1
263 phi = (b1[it] * m[:] + (1 - b1[it]) * g) / (1 - b1[it] ** t)
264 psi = np.sqrt(v / (1 - b2**t)) + eps
265 return phi, psi
266
267
268# noinspection PyUnusedLocal

◆ _padam_phi_psi()

lsst.scarlet.lite.parameters._padam_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 283 of file parameters.py.

283def _padam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
284 # moving averages
285 m[:] = (1 - b1[it]) * g + b1[it] * m
286 v[:] = (1 - b2) * (g**2) + b2 * v
287
288 phi = m
289 vhat[:] = np.maximum(vhat, v)
290 # sanitize zero-gradient elements
291 if eps > 0:
292 vhat = np.maximum(vhat, eps)
293 psi = vhat**p
294 return phi, psi
295
296
297# noinspection PyUnusedLocal

◆ _radam_phi_psi()

lsst.scarlet.lite.parameters._radam_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 314 of file parameters.py.

314def _radam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
315 rho_inf = 2 / (1 - b2) - 1
316
317 # moving averages
318 m[:] = (1 - b1[it]) * g + b1[it] * m
319 v[:] = (1 - b2) * (g**2) + b2 * v
320
321 # bias correction
322 t = it + 1
323 phi = m / (1 - b1[it] ** t)
324 rho = rho_inf - 2 * t * b2**t / (1 - b2**t)
325
326 if rho > 4:
327 psi = np.sqrt(v / (1 - b2**t))
328 r = np.sqrt((rho - 4) * (rho - 2) * rho_inf / (rho_inf - 4) / (rho_inf - 2) / rho)
329 psi /= r
330 else:
331 psi = np.ones(g.shape, g.dtype)
332 # sanitize zero-gradient elements
333 if eps > 0:
334 psi = np.maximum(psi, np.sqrt(eps))
335 return phi, psi
336
337
338# Dictionary to link ADAM variation names to their functional algorithms.

◆ parameter()

Parameter lsst.scarlet.lite.parameters.parameter ( np.ndarray | Parameter x)
Convert a `np.ndarray` into a `Parameter`.

Parameters
----------
x:
    The array or parameter to convert into a `Parameter`.

Returns
-------
result:
    `x`, converted into a `Parameter` if necessary.

Definition at line 165 of file parameters.py.

165def parameter(x: np.ndarray | Parameter) -> Parameter:
166 """Convert a `np.ndarray` into a `Parameter`.
167
168 Parameters
169 ----------
170 x:
171 The array or parameter to convert into a `Parameter`.
172
173 Returns
174 -------
175 result:
176 `x`, converted into a `Parameter` if necessary.
177 """
178 if isinstance(x, Parameter):
179 return x
180 return Parameter(x, {}, 0)
181
182

◆ relative_step()

lsst.scarlet.lite.parameters.relative_step ( np.ndarray x,
float factor = 0.1,
float minimum = 0,
int | Sequence[int] | None axis = None )
Step size set at `factor` times the mean of `X` in direction `axis`

Definition at line 467 of file parameters.py.

472):
473 """Step size set at `factor` times the mean of `X` in direction `axis`"""
474 return np.maximum(minimum, factor * x.mean(axis=axis))

◆ step_function_wrapper()

Callable lsst.scarlet.lite.parameters.step_function_wrapper ( float step)
Wrapper to make a numerical step into a step function

Parameters
----------
step:
    The step to take for a given array.

Returns
-------
step_function:
    The step function that takes an array and returns the
    numerical step.

Definition at line 46 of file parameters.py.

46def step_function_wrapper(step: float) -> Callable:
47 """Wrapper to make a numerical step into a step function
48
49 Parameters
50 ----------
51 step:
52 The step to take for a given array.
53
54 Returns
55 -------
56 step_function:
57 The step function that takes an array and returns the
58 numerical step.
59 """
60 return lambda x: step
61
62

Variable Documentation

◆ DEFAULT_ADAPROX_FACTOR

int lsst.scarlet.lite.parameters.DEFAULT_ADAPROX_FACTOR = 1e-2

Definition at line 43 of file parameters.py.

◆ phi_psi

dict lsst.scarlet.lite.parameters.phi_psi
Initial value:
1= {
2 "adam": _adam_phi_psi,
3 "nadam": _nadam_phi_psi,
4 "amsgrad": _amsgrad_phi_psi,
5 "padam": _padam_phi_psi,
6 "adamx": _adamx_phi_psi,
7 "radam": _radam_phi_psi,
8}

Definition at line 339 of file parameters.py.