class Criterion[source]
Criterion(name:str,supervised:bool,differentiable:bool=True,lower_is_better:bool=True,compute_only_on_design_space:bool=True)
A parent class that inherits all criteria for both classical and learned methods. Criteria can be used as objective or loss functions, as well as evaluation metrics.
| Type | Default | Details | |
|---|---|---|---|
name |
str |
The name of this criterion which will be monitored in logging. | |
supervised |
bool |
Whether the criterion is supervised or not. | |
differentiable |
bool |
True |
Whether the criterion is differentiable or not. Only differentiable criteria can be used as loss/objective functions. |
lower_is_better |
bool |
True |
Whether lower values of the criterion correspond to better scores. |
compute_only_on_design_space |
bool |
True |
Whether the criterion should be evaluated on voxels that have a design space information of -1, i.e., the voxels can be freely optimized. This parameter does not effect all criteria. |
Criterion.get_θ_flat[source]
Criterion.get_θ_flat(solutions:list,binary:bool=False)
Returns a flattened density distribution tensor from the passed solutions.
| Type | Default | Details | |
|---|---|---|---|
solutions |
list |
A list of solutions from which the densities are extracted and flattened into one output tensor. | |
binary |
bool |
False |
Whether the densities should be binarized. |
Criterion.get_design_space_mask[source]
Criterion.get_design_space_mask(solutions:list)
Returns a flattened design space mask from the passed solutions. If compute_only_on_design_space=False, then a ones-vector is returned.
| Type | Default | Details | |
|---|---|---|---|
solutions |
list |
A list of solutions from which the design space mask is extracted and combined into a single output tensor. |
Criterion.__call__[source]
Criterion.__call__(solutions:list,gt_solutions:list=None,binary:bool=False)
Calculates the output of the criterion for all solutions. The gt_solutions are only used if self.criterion.supervised=True.
| Type | Default | Details | |
|---|---|---|---|
solutions |
list |
The solutions that should be evaluated with the criterion. | |
gt_solutions |
list |
None |
Ground truth solutions that are compared element-wise with the solutions. Only used if Criterion.supervised=True. |
binary |
bool |
False |
Whether the criterion should be evaluated on binarized densities. Does not have an effect on some criteria. |
Criterion.__add__[source]
Criterion.__add__(criterion:dl4to.criteria.Criterion)
The summation of two criteria results in a new combined criterion. Returns a dl4to.criteria.CombinedCriterion object.
| Type | Default | Details | |
|---|---|---|---|
criterion |
dl4to.criteria.Criterion |
A second criterion that should be combined with the current one. |
Criterion.__mul__[source]
Criterion.__mul__(λ:float)
The multiplication of a criterion with a scalar results in a weighted criterion. Returns a dl4to.criteria.WeightedCriterion object.
| Type | Default | Details | |
|---|---|---|---|
λ |
float |
The multiplier which the criterion is weighted with. |
class WeightedCriterion[source]
WeightedCriterion(criterion:dl4to.criteria.Criterion,λ:float) ::Criterion
A class that represents a criterion that has a weight factor in front of it. This is especially useful for constrained optimization or regularization.
Note that the unweighted criterion can be accessed via self.criterion.
| Type | Default | Details | |
|---|---|---|---|
criterion |
dl4to.criteria.Criterion |
The criterion object that is being weighted. | |
λ |
float |
The weighting factor for the criterion. |
class CombinedCriterion[source]
CombinedCriterion(criterion1:dl4to.criteria.Criterion,criterion2:dl4to.criteria.Criterion) ::Criterion
A class that represents the combination of two criteria by a plus sign "+" between them. Both individual criteria can be accessed via self.criterion1 and self.criterion2.
| Type | Default | Details | |
|---|---|---|---|
criterion1 |
dl4to.criteria.Criterion |
The first criterion of the summation. | |
criterion2 |
dl4to.criteria.Criterion |
The second criterion of the summation. |