Skip to content

Commit 29e055d

Browse files
authored
Merge pull request #8 from roflmaostc/improve_docs [skip ci]
Update documentation of loss
2 parents 68f2dff + 757024b commit 29e055d

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

docs/src/plugin_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.. _plugin_doc:
22

3-
Plugin documentation
3+
Documentation
44
====================
55

66
Dr.TVAM extends the Mitsuba 3 framework with a few *plugins* that are specific

docs/src/plugin_reference/loss.rst

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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
77
define ours as children of the base ``Loss`` class, which provides a common
88
interface to evaluate the loss. The ``Loss`` class overrides the ``__call__``
99
method, which allows to call it as if it were a regular function:
@@ -52,7 +52,8 @@ L2 Loss (``L2Loss``)
5252

5353
This loss function computes the squared error between the predicted and target
5454
values.
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

5758
Thresholded 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

7074
With ``'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$.
7682
This 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

Comments
 (0)