Skip to content

rpn_config

Bases: config

The configuration class of RPN model.

It implements the configuration class for the RPN model specifically. The class can help instantiate the RPN model from its configuration file.

Attributes:

Name Type Description
name str, default = 'rpn_config'

Name of the rpn_config object.

Methods:

Name Description
__init__

The rpn_config initialization method.

instantiate_object_from_config

The rpn objects instantiation method from the configuration.

extract_config_from_object

The rpn configuration extraction method from the rpn objects.

Source code in tinybig/config/rpn_config.py
class rpn_config(config):
    """
    The configuration class of RPN model.

    It implements the configuration class for the RPN model specifically.
    The class can help instantiate the RPN model from its configuration file.

    Attributes
    ----------
    name: str, default = 'rpn_config'
        Name of the rpn_config object.

    Methods
    ----------

    __init__
        The rpn_config initialization method.

    instantiate_object_from_config
        The rpn objects instantiation method from the configuration.

    extract_config_from_object
        The rpn configuration extraction method from the rpn objects.
    """
    def __init__(self, name='rpn_config'):
        """
        The rpn config initialization method.

        It initializes the rpn config object based on the provided parameters.

        Parameters
        ----------
        name: str, default = 'rpn_config'
            Name of the rpn configuration object.
        """
        super().__init__(name=name)

    @staticmethod
    def instantiate_object_from_config(configs: dict):
        """
        The rpn object instantiation method from the configuration.

        It initializes a rpn object from its detailed configuration information.

        Parameters
        ----------
        configs: dict
            The rpn object detailed configuration.

        Returns
        -------
        dict
            The initialized object dictionary based on the configs.
        """
        object_dict = {}
        for config in configs:
            if '_configs' not in config: continue
            object_name_stem = config.split('_configs')[0]
            if "{}_class".format(object_name_stem) in configs[config]:
                class_name = configs[config]["{}_class".format(object_name_stem)]
                parameters = configs[config]["{}_parameters".format(object_name_stem)]
                obj = get_obj_from_str(class_name)(**parameters)
            else:
                obj = None
            object_dict[object_name_stem] = obj
        return object_dict

    @staticmethod
    def extract_config_from_object(objects, *args, **kwargs):
        """
        The rpn configuration extraction method from the rpn objects.

        It extracts the rpn object configuration and return it as a confi dictionary.

        Parameters
        ----------
        objects: object
            The rpn model and component object.

        Returns
        -------
        dict
            The configuration information of the input object.
        """
        pass

__init__(name='rpn_config')

The rpn config initialization method.

It initializes the rpn config object based on the provided parameters.

Parameters:

Name Type Description Default
name

Name of the rpn configuration object.

'rpn_config'
Source code in tinybig/config/rpn_config.py
def __init__(self, name='rpn_config'):
    """
    The rpn config initialization method.

    It initializes the rpn config object based on the provided parameters.

    Parameters
    ----------
    name: str, default = 'rpn_config'
        Name of the rpn configuration object.
    """
    super().__init__(name=name)

extract_config_from_object(objects, *args, **kwargs) staticmethod

The rpn configuration extraction method from the rpn objects.

It extracts the rpn object configuration and return it as a confi dictionary.

Parameters:

Name Type Description Default
objects

The rpn model and component object.

required

Returns:

Type Description
dict

The configuration information of the input object.

Source code in tinybig/config/rpn_config.py
@staticmethod
def extract_config_from_object(objects, *args, **kwargs):
    """
    The rpn configuration extraction method from the rpn objects.

    It extracts the rpn object configuration and return it as a confi dictionary.

    Parameters
    ----------
    objects: object
        The rpn model and component object.

    Returns
    -------
    dict
        The configuration information of the input object.
    """
    pass

instantiate_object_from_config(configs) staticmethod

The rpn object instantiation method from the configuration.

It initializes a rpn object from its detailed configuration information.

Parameters:

Name Type Description Default
configs dict

The rpn object detailed configuration.

required

Returns:

Type Description
dict

The initialized object dictionary based on the configs.

Source code in tinybig/config/rpn_config.py
@staticmethod
def instantiate_object_from_config(configs: dict):
    """
    The rpn object instantiation method from the configuration.

    It initializes a rpn object from its detailed configuration information.

    Parameters
    ----------
    configs: dict
        The rpn object detailed configuration.

    Returns
    -------
    dict
        The initialized object dictionary based on the configs.
    """
    object_dict = {}
    for config in configs:
        if '_configs' not in config: continue
        object_name_stem = config.split('_configs')[0]
        if "{}_class".format(object_name_stem) in configs[config]:
            class_name = configs[config]["{}_class".format(object_name_stem)]
            parameters = configs[config]["{}_parameters".format(object_name_stem)]
            obj = get_obj_from_str(class_name)(**parameters)
        else:
            obj = None
        object_dict[object_name_stem] = obj
    return object_dict