<commit_before>"""An implementation of MVLSTM Model."""
import typing
import logging

import keras
import keras.backend as K

from matchzoo import engine

logger = logging.getLogger(__name__)


class MVLSTM(engine.BaseModel):
    """
    MVLSTM Model.

    Examples:
        >>> model = MVLSTM()
        >>> model.params['lstm_units'] = 32
        >>> model.params['top_k'] = 50
        >>> model.params['mlp_num_layers'] = 2
        >>> model.params['mlp_num_units'] = 20
        >>> model.params['mlp_num_fan_out'] = 10
        >>> model.params['mlp_activation_func'] = 'relu'
        >>> model.params['dropout_rate'] = 0.5
        >>> model.guess_and_fill_missing_params(verbose=0)
        >>> model.build()

    """

    @classmethod
    def get_default_params(cls) -> engine.ParamTable:
        """:return: model default parameters."""
        params = super().get_default_params(
            with_embedding=True, with_multi_layer_perceptron=True)
        params.add(engine.Param('lstm_units', 32))
        params.add(engine.Param('dropout_rate', 0.0))
        params.add(engine.Param(
            'top_k', value=10,
            hyper_space=engine.hyper_spaces.quniform(low=2, high=100)
        ))
        params['optimizer'] = 'adam'
        return params

    def build(self):
        """Build model structure."""
        query, doc = self._make_inputs()

        # Embedding layer
        embedding = self._make_embedding_layer()
        embed_query = embedding(query)
        embed_doc = embedding(doc)
<commit_msg>add param description<commit_after>"""An implementation of MVLSTM Model."""
import typing
import logging

import keras
import keras.backend as K

from matchzoo import engine

logger = logging.getLogger(__name__)


class MVLSTM(engine.BaseModel):
    """
    MVLSTM Model.

    Examples:
        >>> model = MVLSTM()
        >>> model.params['lstm_units'] = 32
        >>> model.params['top_k'] = 50
        >>> model.params['mlp_num_layers'] = 2
        >>> model.params['mlp_num_units'] = 20
        >>> model.params['mlp_num_fan_out'] = 10
        >>> model.params['mlp_activation_func'] = 'relu'
        >>> model.params['dropout_rate'] = 0.5
        >>> model.guess_and_fill_missing_params(verbose=0)
        >>> model.build()

    """

    @classmethod
    def get_default_params(cls) -> engine.ParamTable:
        """:return: model default parameters."""
        params = super().get_default_params(
            with_embedding=True, with_multi_layer_perceptron=True)
        params.add(engine.Param(name='lstm_units', value=32,
                                desc="Integer, the hidden size in the "
                                     "bi-directional LSTM layer."))
        params.add(engine.Param(name='dropout_rate', value=0.0,
                                desc="Float, the dropout rate."))
        params.add(engine.Param(
            'top_k', value=10,
            hyper_space=engine.hyper_spaces.quniform(low=2, high=100),
            desc="Integer, the size of top-k pooling layer."
        ))
        params['optimizer'] = 'adam'
        return params

    def build(self):
        """Build model structure."""
        query, doc = self._make_inputs()

        # Embedding layer
        embedding = self._make_embedding_layer()
        embed_query = embedding(query)
        embed_doc = embedding(doc)

{'fraction_non_alphanumeric': 0.13217703349282298, 'fraction_numerical': 0.013157894736842105, 'mean_word_length': 2.4627329192546585, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2851733', 'n_tokens_mistral': 1045, 'n_tokens_neox': 990, 'n_words': 192}