Пример #1
0
    def default_hparams():
        """Returns a dictionary of hyperparameters with default values.
        The dictionary has the following structure and default values.

        Returns:
            dict: Adictionary with following structure and values:
            .. code-block:: python
                {
                    "encoder_major_type": "UnidirectionalRNNEncoder",
                    "encoder_major_hparams": {},
                    "encoder_minor_type": "UnidirectionalRNNEncoder",
                    "encoder_minor_hparams": {},
                    "config_share": False,
                    "name": "hierarchical_encoder_wrapper"
                }

            Here:

            "encoder_major_type":
                The class name of major encoder which can be found in
                ~texar.modules.encoders or ~texar.custom.

            "encoder_major_hparams":
                The hparams for major encoder's construction.

            "config_share":
                :attr:`encoder_minor_type` and :attr:`encoder_minor_hparams`
                will be replaced by major's corresponding hparams if set to true.

            "name":
                Name of the encoder.
        """
        hparams = {
            "name": "hierarchical_encoder",
            "encoder_major_type": "UnidirectionalRNNEncoder",
            "encoder_major_hparams": {},
            "encoder_minor_type": "UnidirectionalRNNEncoder",
            "encoder_minor_hparams": {},
            "config_share": False,
            "@no_typecheck":
            ['encoder_major_hparams', 'encoder_minor_hparams']
        }
        hparams.update(EncoderBase.default_hparams())
        return hparams
    def default_hparams():
        """Returns a dictionary of hyperparameters with default values.

        .. role:: python(code)
           :language: python

        .. code-block:: python

            {
                "encoder_major_type": "UnidirectionalRNNEncoder",
                "encoder_major_hparams": {},
                "encoder_minor_type": "UnidirectionalRNNEncoder",
                "encoder_minor_hparams": {},
                "config_share": False,
                "name": "hierarchical_encoder_wrapper"
            }

        Here:

        "encoder_major_type" : str or class or instance
            The high-level encoder. Can be a RNN encoder class, its name or
            module path, or a class instance.
            Ignored if `encoder_major` is given to the encoder constructor.

        "encoder_major_hparams" : dict
            The hyperparameters for the high-level encoder. The high-level
            encoder is created with
            :python:`encoder_class(hparams=encoder_major_hparams)`.
            Ignored if `encoder_major` is given to the encoder constructor,
            or if "encoder_major_type" is an encoder instance.

        "encoder_minor_type" : str or class or instance
            The low-level encoder. Can be a RNN encoder class, its name or
            module path, or a class instance.
            Ignored if `encoder_minor` is given to the encoder constructor,
            or if "config_share" is True.

        "encoder_minor_hparams" : dict
            The hyperparameters for the low-level encoder. The high-level
            encoder is created with
            :python:`encoder_class(hparams=encoder_minor_hparams)`.
            Ignored if `encoder_minor` is given to the encoder constructor,
            or if "config_share" is True,
            or if "encoder_minor_type" is an encoder instance.

        "config_share":
            Whether to use encoder_major's hyperparameters
            to construct encoder_minor.

        "name":
            Name of the encoder.
        """
        hparams = {
            "name": "hierarchical_encoder",
            "encoder_major_type": "UnidirectionalRNNEncoder",
            "encoder_major_hparams": {},
            "encoder_minor_type": "UnidirectionalRNNEncoder",
            "encoder_minor_hparams": {},
            "config_share": False,
            "@no_typecheck":
            ['encoder_major_hparams', 'encoder_minor_hparams']
        }
        hparams.update(EncoderBase.default_hparams())
        return hparams