openGPMP
Open Source Mathematics Package
|
Kohonen Neural Network Cluster Class. More...
#include <kohonen_net.hpp>
Public Member Functions | |
KohonenNet (int inputSize, int mapSize) | |
Constructor for the KohonenNet class. More... | |
~KohonenNet () | |
Destructor for the KohonenNet class. More... | |
void | train (const std::vector< std::vector< double >> &inputData, int epochs=1000) |
Trains the Kohonen network using input data. More... | |
int | classify (const std::vector< double > &inputVector) |
Classifies a given input vector and returns the index of the best matching unit. More... | |
Private Member Functions | |
void | initialize_weights () |
Initializes the weights of the Kohonen network. More... | |
int | best_matching_unit (const std::vector< double > &input_vector) |
Finds the index of the best matching unit (BMU) for a given input vector. More... | |
void | update_weights (int bmu, const std::vector< double > &input_vector, double learning_rate) |
Updates the weights of the Kohonen network based on the best matching unit and input vector. More... | |
double | euclidean_distance (const std::vector< double > &vec1, const std::vector< double > &vec2) |
Calculates the Euclidean distance between two vectors. More... | |
Private Attributes | |
int | input_size |
int | map_size |
std::vector< std::vector< double > > | weights |
Kohonen Neural Network Cluster Class.
Referred to as Self-Organizing Map
Definition at line 52 of file kohonen_net.hpp.
gpmp::ml::KohonenNet::KohonenNet | ( | int | inputSize, |
int | mapSize | ||
) |
Constructor for the KohonenNet class.
inputSize | The size of the input vector |
mapSize | The size of the map in the Kohonen network |
Definition at line 38 of file kohonen_net.cpp.
References initialize_weights().
gpmp::ml::KohonenNet::~KohonenNet | ( | ) |
|
private |
Finds the index of the best matching unit (BMU) for a given input vector.
input_vector | The input vector |
Definition at line 74 of file kohonen_net.cpp.
int gpmp::ml::KohonenNet::classify | ( | const std::vector< double > & | inputVector | ) |
Classifies a given input vector and returns the index of the best matching unit.
inputVector | The input vector to be classified |
Definition at line 70 of file kohonen_net.cpp.
|
private |
Calculates the Euclidean distance between two vectors.
vec1 | The first vector |
vec2 | The second vector |
Definition at line 101 of file kohonen_net.cpp.
|
private |
Initializes the weights of the Kohonen network.
Definition at line 46 of file kohonen_net.cpp.
Referenced by KohonenNet().
void gpmp::ml::KohonenNet::train | ( | const std::vector< std::vector< double >> & | inputData, |
int | epochs = 1000 |
||
) |
Trains the Kohonen network using input data.
inputData | The input data consisting of vectors |
epochs | The number of training epochs (default: 1000) |
Definition at line 58 of file kohonen_net.cpp.
|
private |
Updates the weights of the Kohonen network based on the best matching unit and input vector.
bmu | The index of the best matching unit |
input_vector | The input vector |
learning_rate | The learning rate for weight updates |
Definition at line 90 of file kohonen_net.cpp.
|
private |
The size of the input vector
Definition at line 82 of file kohonen_net.hpp.
|
private |
The size of the map in the Kohonen network
Definition at line 83 of file kohonen_net.hpp.
|
private |
Weight matrix for the Kohonen network
Definition at line 85 of file kohonen_net.hpp.