11.. _loss :
22
3- Objective functions
3+ Loss function
44===================
55
6- Objective functions are a central element of any inverse problem formulation. We
6+ Loss functions are a central element of any inverse problem formulation. We
77define ours as children of the base ``Loss `` class, which provides a common
88interface to evaluate the loss. The ``Loss `` class overrides the ``__call__ ``
99method, which allows to call it as if it were a regular function:
@@ -52,7 +52,8 @@ L2 Loss (``L2Loss``)
5252
5353This loss function computes the squared error between the predicted and target
5454values.
55- It requires no additional parameter.
55+ It requires no additional parameter. We do not recommend using this loss as
56+ the ThresholdedLoss provides a better results and control.
5657
5758Thresholded loss (``ThresholdedLoss ``)
5859^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -66,13 +67,18 @@ predicted volume:
6667 tl `` are penalized.
6768* Finally, object voxels whose recorded dose is *higher * than ``1.0 `` are also
6869 penalized, to avoid some regions being overexposed.
70+ * Additionally, a sparsity loss can be added to increase the overall energy
71+ efficiency of the patterns. We prefer homogenous patterns without
72+ spiking values since those reduce the overall energy of the patterns.
6973
7074With ``'sum' `` reduction, its full expression is:
7175
72- .. math ::
7376
74- L = \sum _{i \in \text {Object}} \operatorname {ReLU} \left (t_u - v_i \right )^K + \sum _{i \notin\text {Object}} \operatorname {ReLU} \left (v_i - t_l \right )^K + \sum _{i \in \text {Object}} \operatorname {ReLU} \left (v_i - 1 \right )^K
77+ .. math ::
7578
79+ L = w_{\text {object}} \cdot \sum _{i\in \text {Object}} \operatorname {ReLU}\left (t_u - v_i\right )^K + w_{\text {void}} \cdot \sum _{i\notin\text {Object}} \operatorname {ReLU}\left (v_i - t_l\right )^K\\ + w_{\text {limit}}\cdot \sum _{i\in \text {Object}} \operatorname {ReLU}\left (v_i - 1 \right )^K + w_{\text {sparsity}} \cdot \sum _{p \in \text {patterns}} p^M
80+
81+ where $v_i$ is the intensity value at voxel $i$.
7682This objective function was introduced by Wechsler et al. `[2024]
7783<https://opg.optica.org/oe/fulltext.cfm?uri=oe-32-8-14705&id=548744> `_.
7884
@@ -89,6 +95,10 @@ It requires the following additional parameters:
8995 * - ``K ``
9096 - ``int ``
9197 - The power to which to raise the error. Defaults to ``2 ``.
98+
99+ * - ``M ``
100+ - ``int ``
101+ - The power to which to raise the pattern values. Defaults to ``4 ``.
92102
93103 * - ``tl ``
94104 - ``float ``
@@ -98,3 +108,19 @@ It requires the following additional parameters:
98108 - ``float ``
99109 - The upper threshold, in ``[0, 1] ``. Defaults to ``0.95 ``.
100110
111+ * - ``weight_object ``
112+ - ``float ``
113+ - Weight of the object term. Defaults to ``1 ``.
114+
115+ * - ``weight_void ``
116+ - ``float ``
117+ - Weight of the void term. Defaults to ``1 ``.
118+
119+ * - ``weight_limit ``
120+ - ``float ``
121+ - Weight of the overpolymerization term. Defaults to ``1 ``.
122+
123+ * - ``weight_sparsity ``
124+ - ``float ``
125+ - Weight of the sparsity term. Defaults to ``0 ``.
126+
0 commit comments