TfELM
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
SubELMLayer.SubELMLayer Class Reference

Public Member Functions

 __init__ (self, number_neurons, number_subnets, neurons_subnets, activation='tanh', act_params=None, **params)
 
 build (self, input_shape)
 
 fit (self, x, y)
 
 predict (self, x)
 
 predict_proba (self, x)
 
 calc_output (self, x)
 
 apply_activation (self, x)
 
 __str__ (self)
 
 count_params (self)
 
 to_dict (self)
 
 load (cls, attributes)
 

Public Attributes

 error_history
 
 feature_map
 
 name
 
 beta
 
 bias
 
 alpha
 
 input
 
 output
 
 act_params
 
 denoising
 
 activation_name
 
 activation
 
 number_neurons
 
 number_subnets
 
 neurons_subnets
 
 A
 
 sub_inputweights
 
 sub_outputweights
 

Detailed Description

    Subnetwork Extreme Learning Machine (SubELM) layer.

    This layer implements the SubELM algorithm, which divides the input space into subspaces and learns
    separate subnetworks for each subspace. It utilizes random feature mapping and activation functions to
    map the input data into higher-dimensional spaces, followed by the construction of subnetworks.

    Parameters:
    -----------
    - number_neurons (int): Number of neurons in the hidden layer.
    - number_subnets (int): Number of subnetworks to create.
    - neurons_subnets (int): Number of neurons in each subnetwork.
    - activation (str): Activation function to use. Default is 'tanh'.
    - act_params (dict): Parameters for the activation function. Default is None.

    Attributes:
    -----------
    - error_history (None): History of training errors.
    - feature_map (None): Feature map generated during training.
    - name (str): Name of the layer.
    - beta (None or tf.Tensor): Output weights.
    - bias (None or tf.Tensor): Bias values.
    - alpha (None or tf.Tensor): Input weights.
    - input (None or tf.Tensor): Input data.
    - output (None or tf.Tensor): Output data.
    - act_params (dict): Parameters for the activation function.
    - activation_name (str): Name of the activation function.
    - number_neurons (int): Number of neurons in the hidden layer.
    - number_subnets (int): Number of subnetworks.
    - neurons_subnets (int): Number of neurons in each subnetwork.

    Methods:
    -----------
    - build(input_shape): Build the layer.
    - fit(x, y): Fit the layer to input-output pairs.
    - predict(x): Predict output for the given input.
    - predict_proba(x): Predict class probabilities for the given input.
    - calc_output(x): Calculate the output for the given input.
    - apply_activation(x): Apply the activation function to the given input.
    - count_params(): Count the number of trainable and non-trainable parameters.
    - to_dict(): Convert the layer's attributes to a dictionary.
    - load(attributes): Load a layer instance from attributes.

    Notes:
    -----------
    - This layer divides the input space into subspaces and learns separate subnetworks for each subspace.
    - It utilizes random feature mapping and activation functions for mapping input data into higher-dimensional spaces.

    Example:
    -----------
    Initialize a Subnetwork Extreme Learning Machine (SubELM) layer

    >>> layer = SubELMLayer(1000, 200, 70, 'mish')

    Create an SubELM model using the trained ELM layer

    >>> model = ELMModel(layer)

Member Function Documentation

◆ __str__()

SubELMLayer.SubELMLayer.__str__ ( self)
Returns a string representation of the ELM layer.

Returns:
str: String representation.

◆ apply_activation()

SubELMLayer.SubELMLayer.apply_activation ( self,
x )
    Apply the activation function to the given input.

    Parameters:
    - x (tf.Tensor): Input data.

    Returns:
    tf.Tensor: Output after applying activation function.

◆ build()

SubELMLayer.SubELMLayer.build ( self,
input_shape )
   Build the layer.

   Parameters:
   -----------
   - input_shape (tuple): Shape of the input data.

   Returns:
   -----------
   None

   Example:
   -----------
    >>> layer = SubELMLayer(1000, 200, 70, 'mish')
    >>> layer.build(X.shape)

◆ calc_output()

SubELMLayer.SubELMLayer.calc_output ( self,
x )
    Calculate the output for the given input.

    Parameters:
    - x (tf.Tensor): Input data.

    Returns:
    tf.Tensor: Output.

◆ count_params()

SubELMLayer.SubELMLayer.count_params ( self)
Counts the number of trainable and non-trainable parameters in the SubELM layer.

Returns:
dict: Dictionary containing counts for trainable, non-trainable, and total parameters.

◆ fit()

SubELMLayer.SubELMLayer.fit ( self,
x,
y )
    Fit the layer to input-output pairs.

    Parameters:
    -----------
    - x (tf.Tensor): Input data.
    - y (tf.Tensor): Output data.

    Returns:
    -----------
    None

    Example:
    -----------
    >>> layer = SubELMLayer(1000, 200, 70, 'mish')
    >>> layer.build(X.shape)
    >>> layer.fit(train_data, train_targets)

◆ load()

SubELMLayer.SubELMLayer.load ( cls,
attributes )
    Load a layer instance from attributes.

    Parameters:
    - attributes (dict): Attributes to initialize the layer.

    Returns:
    SubELMLayer: Loaded layer instance.

◆ predict()

SubELMLayer.SubELMLayer.predict ( self,
x )
   Predict output for the given input.

   Parameters:
   -----------
   - x (tf.Tensor): Input data.

   Returns:
   -----------
   tf.Tensor: Predicted output.

   Example:
   -----------
    >>> layer = SubELMLayer(1000, 200, 70, 'mish')
    >>> layer.build(X.shape)
    >>> layer.fit(train_data, train_targets)
    >>> pred = layer.predict(test_data)

◆ predict_proba()

SubELMLayer.SubELMLayer.predict_proba ( self,
x )
    Predict class probabilities for the given input.

    Parameters:
    -----------
    - x (tf.Tensor): Input data.

    Returns:
    -----------
    tf.Tensor: Predicted class probabilities.

    Example:
    -----------
    >>> layer = SubELMLayer(1000, 200, 70, 'mish')
    >>> layer.build(X.shape)
    >>> layer.fit(train_data, train_targets)
    >>> pred = layer.predict_proba(test_data)

◆ to_dict()

SubELMLayer.SubELMLayer.to_dict ( self)
    Convert the layer's attributes to a dictionary.

    Returns:
    dict: Dictionary containing the layer's attributes.

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