Threshold
- class hybrid_learning.datasets.transforms.image_transforms.Threshold(threshold=0.5, val_low_class=0.0, val_high_class=1.0)[source]
Bases:
ImageTransform
Threshold tensors and set new values below and/or above the threshold. The operation is:
Each of the thresholds
val_low_class
andval_high_class
can also be set toNone
, in which case``x`` is used instead. Set values to both to obtain a binarizing operation.Note
val_low_class
needs not to be lower thanval_high_class
, so one can also invert binary masks with this.Public Data Attributes:
Settings to reproduce instance.
Inherited from : py: class:Transform
IDENTITY_CLASS
The identity class or classes for composition / addition.
Settings to reproduce instance.
Public Methods:
apply_to
(input_tensor)Binarize
input_tensor
according to the settings.Inherited from : py: class:ImageTransform
apply_to
(input_tensor)Binarize
input_tensor
according to the settings.Inherited from : py: class:Transform
apply_to
(input_tensor)Binarize
input_tensor
according to the settings.Special Methods:
__init__
([threshold, val_low_class, ...])Init.
Inherited from : py: class:ImageTransform
__call__
(img)Application of transformation.
Inherited from : py: class:Transform
__repr__
()Return repr(self).
__eq__
(other)Return self==value.
__copy__
()Return a shallow copy of self using settings.
__add__
(other)Return a flat composition of
self
withother
.__radd__
(other)Return a flat composition of
other
andself
.__call__
(img)Application of transformation.
- Parameters
- apply_to(input_tensor)[source]
Binarize
input_tensor
according to the settings. In case any of this instances settings are tensors, these are moved to the same device asinput_tensor
.
- threshold: Union[float, Tensor]
Threshold by which to decide the class; low class if
x<=post_target_thresh
, else high