TfELM
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ReceptiveFieldGaussianGenerator.ReceptiveFieldGaussianGenerator Class Reference
Inheritance diagram for ReceptiveFieldGaussianGenerator.ReceptiveFieldGaussianGenerator:

Public Member Functions

 __init__ (self, input_size, exclusion_distance=3, q_threshold=10, num_classes=None, sigma=None)
 
 to_dict (self)
 
 load (cls, attributes)
 

Public Attributes

 sigma
 
 input_size
 
 exclusion_distance
 
 q_threshold
 
 num_classes
 

Protected Member Functions

 _apply_rectangle_mask (self, image, top_left, bottom_right)
 

Detailed Description

    Gaussian Receptive Field Generator.

    This class extends the ReceptiveFieldGenerator class to generate Gaussian receptive fields.

    Parameters:
    -----------
        input_size (tuple): The size of the input images (height, width, channels).
        exclusion_distance (int, optional): The minimum distance from the image border to exclude when generating
            receptive fields. Defaults to 3.
        q_threshold (int, optional): The minimum area of the generated receptive fields. Defaults to 10.
        num_classes (int, optional): Number of classes. Defaults to None.
        sigma (float, optional): Standard deviation of the Gaussian distribution. Defaults to None.

    Attributes:
    -----------
        sigma (float): Standard deviation of the Gaussian distribution.

    Methods:
    -----------
        to_dict(): Convert the generator to a dictionary of attributes.
        load(attributes): Load a generator instance from a dictionary of attributes.
        _apply_rectangle_mask(image, top_left, bottom_right): Apply a Gaussian mask to an image.

    Examples:
    -----------
    Initialization of Receptive Field Generator

    >>> rf = ReceptiveFieldGaussianGenerator(input_size=(28, 28, 1))

    Initialize an Extreme Learning Machine layer with receptive field (RF-ELM)

    >>> elm = ELMLayer(number_neurons=num_neurons, activation='mish', receptive_field_generator=rf)
    >>> model = ELMModel(elm)

    Define a cross-validation strategy

    >>> cv = RepeatedKFold(n_splits=n_splits, n_repeats=n_repeats)

    Perform cross-validation to evaluate the model performance

    >>> scores = cross_val_score(model, X, y, cv=cv, scoring='accuracy', error_score='raise')

    Print the mean accuracy score obtained from cross-validation

    >>> print(np.mean(scores))

    Fit the ELM model to the entire dataset

    >>> model.fit(X, y)

Member Function Documentation

◆ _apply_rectangle_mask()

ReceptiveFieldGaussianGenerator.ReceptiveFieldGaussianGenerator._apply_rectangle_mask ( self,
image,
top_left,
bottom_right )
protected
    Apply a Gaussian mask to an image.

    Parameters:
    -----------
        image (Tensor): The input image.
        top_left (Tensor): Coordinates of the top-left corner of the rectangle.
        bottom_right (Tensor): Coordinates of the bottom-right corner of the rectangle.

    Returns:
    -----------
        Tensor: The masked image.

◆ load()

ReceptiveFieldGaussianGenerator.ReceptiveFieldGaussianGenerator.load ( cls,
attributes )
    Load a generator instance from a dictionary of attributes.

    Parameters:
    -----------
        attributes (dict): A dictionary containing the attributes of the generator.

    Returns:
    -----------
        ReceptiveFieldGaussianGenerator: An instance of the ReceptiveFieldGaussianGenerator class
            loaded from the attributes.

◆ to_dict()

ReceptiveFieldGaussianGenerator.ReceptiveFieldGaussianGenerator.to_dict ( self)
    Convert the generator to a dictionary of attributes.

    Returns:
    -----------
        dict: A dictionary containing the attributes of the generator.

The documentation for this class was generated from the following file: