コード例 #1
0
    def __init__(
        self,
        keys: KeysCollection,
        sigmoid: Union[Sequence[bool], bool] = False,
        softmax: Union[Sequence[bool], bool] = False,
        other: Optional[Union[Sequence[Callable], Callable]] = None,
    ) -> None:
        """
        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 of bool, each element corresponds to a key in ``keys``.
            softmax: whether to execute softmax function on model output before transform.
                it also can be a sequence of bool, each element corresponds to a key in ``keys``.
            other: callable function to execute other activation layers,
                for example: `other = lambda x: torch.tanh(x)`. it also can be a sequence of Callable, each
                element corresponds to a key in ``keys``.

        """
        super().__init__(keys)
        self.sigmoid = ensure_tuple_rep(sigmoid, len(self.keys))
        self.softmax = ensure_tuple_rep(softmax, len(self.keys))
        self.other = ensure_tuple_rep(other, len(self.keys))
        self.converter = Activations()
コード例 #2
0
ファイル: dictionary.py プロジェクト: yang20085936/MONAI
 def __init__(self,
              keys: Hashable,
              output_postfix: str = "act",
              sigmoid=False,
              softmax=False,
              other=None):
     """
     Args:
         keys (hashable items): keys of the corresponding items to model output and label.
             See also: :py:class:`monai.transforms.compose.MapTransform`
         output_postfix (str): the postfix string to construct keys to store converted data.
             for example: if the keys of input data is `pred` and `label`, output_postfix is `act`,
             the output data keys will be: `pred_act`, `label_act`.
             if set to None, will replace the original data with the same key.
         sigmoid (bool, tuple or list of bool): whether to execute sigmoid function on model
             output before transform.
         softmax (bool, tuple or list of bool): whether to execute softmax function on model
             output before transform.
         other (Callable, tuple or list of Callables): callable function to execute other activation layers,
             for example: `other = lambda x: torch.tanh(x)`
     """
     super().__init__(keys)
     if output_postfix is not None and not isinstance(output_postfix, str):
         raise ValueError("output_postfix must be a string.")
     self.output_postfix = output_postfix
     self.sigmoid = ensure_tuple_rep(sigmoid, len(self.keys))
     self.softmax = ensure_tuple_rep(softmax, len(self.keys))
     self.other = ensure_tuple_rep(other, len(self.keys))
     self.converter = Activations()
コード例 #3
0
ファイル: dictionary.py プロジェクト: wentaozhu/MONAI
    def __init__(self,
                 keys: KeysCollection,
                 sigmoid=False,
                 softmax=False,
                 other=None):
        """
        Args:
            keys: keys of the corresponding items to model output and label.
                See also: :py:class:`monai.transforms.compose.MapTransform`
            sigmoid (bool, tuple or list of bool): whether to execute sigmoid function on model
                output before transform.
            softmax (bool, tuple or list of bool): whether to execute softmax function on model
                output before transform.
            other (Callable, tuple or list of Callables): callable function to execute other activation layers,
                for example: `other = lambda x: torch.tanh(x)`

        """
        super().__init__(keys)
        self.sigmoid = ensure_tuple_rep(sigmoid, len(self.keys))
        self.softmax = ensure_tuple_rep(softmax, len(self.keys))
        self.other = ensure_tuple_rep(other, len(self.keys))
        self.converter = Activations()