Args: keys: keys of the corresponding items to model output and label. See also: :py:class:`monai.transforms.compose.MapTransform` sigmoid: whether to execute sigmoid function on model output before transform. it also can be a sequence
(
self,
keys: KeysCollection,
sigmoid: Sequence[bool] | bool = False,
softmax: Sequence[bool] | bool = False,
other: Sequence[Callable] | Callable | None = None,
allow_missing_keys: bool = False,
**kwargs,
)
| 114 | backend = Activations.backend |
| 115 | |
| 116 | def __init__( |
| 117 | self, |
| 118 | keys: KeysCollection, |
| 119 | sigmoid: Sequence[bool] | bool = False, |
| 120 | softmax: Sequence[bool] | bool = False, |
| 121 | other: Sequence[Callable] | Callable | None = None, |
| 122 | allow_missing_keys: bool = False, |
| 123 | **kwargs, |
| 124 | ) -> None: |
| 125 | """ |
| 126 | Args: |
| 127 | keys: keys of the corresponding items to model output and label. |
| 128 | See also: :py:class:`monai.transforms.compose.MapTransform` |
| 129 | sigmoid: whether to execute sigmoid function on model output before transform. |
| 130 | it also can be a sequence of bool, each element corresponds to a key in ``keys``. |
| 131 | softmax: whether to execute softmax function on model output before transform. |
| 132 | it also can be a sequence of bool, each element corresponds to a key in ``keys``. |
| 133 | other: callable function to execute other activation layers, |
| 134 | for example: `other = torch.tanh`. it also can be a sequence of Callable, each |
| 135 | element corresponds to a key in ``keys``. |
| 136 | allow_missing_keys: don't raise exception if key is missing. |
| 137 | kwargs: additional parameters to `torch.softmax` (used when ``softmax=True``). |
| 138 | Defaults to ``dim=0``, unrecognized parameters will be ignored. |
| 139 | |
| 140 | """ |
| 141 | super().__init__(keys, allow_missing_keys) |
| 142 | self.sigmoid = ensure_tuple_rep(sigmoid, len(self.keys)) |
| 143 | self.softmax = ensure_tuple_rep(softmax, len(self.keys)) |
| 144 | self.other = ensure_tuple_rep(other, len(self.keys)) |
| 145 | self.converter = Activations() |
| 146 | self.converter.kwargs = kwargs |
| 147 | |
| 148 | def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> dict[Hashable, NdarrayOrTensor]: |
| 149 | d = dict(data) |
nothing calls this directly
no test coverage detected