TfELM
|
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) | |
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)
SubELMLayer.SubELMLayer.__str__ | ( | self | ) |
Returns a string representation of the ELM layer. Returns: str: String representation.
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.
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)
SubELMLayer.SubELMLayer.calc_output | ( | self, | |
x ) |
Calculate the output for the given input. Parameters: - x (tf.Tensor): Input data. Returns: tf.Tensor: Output.
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.
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)
SubELMLayer.SubELMLayer.load | ( | cls, | |
attributes ) |
Load a layer instance from attributes. Parameters: - attributes (dict): Attributes to initialize the layer. Returns: SubELMLayer: Loaded layer instance.
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)
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)
SubELMLayer.SubELMLayer.to_dict | ( | self | ) |
Convert the layer's attributes to a dictionary. Returns: dict: Dictionary containing the layer's attributes.