updated documentations

(cherry picked from commit 05b3dbdab9b6df041ac17af89610c5b018adeed2)
This commit is contained in:
Krishna Vedala 2020-06-16 08:13:02 -04:00
parent a78893eba5
commit 580c501c29
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -16,6 +16,7 @@
* \warning MSVC 2019 compiler generates code that does not execute as expected. * \warning MSVC 2019 compiler generates code that does not execute as expected.
* However, MinGW, Clang for GCC and Clang for MSVC compilers on windows perform * However, MinGW, Clang for GCC and Clang for MSVC compilers on windows perform
* as expected. Any insights and suggestions should be directed to the author. * as expected. Any insights and suggestions should be directed to the author.
* \see kohonen_som_trace.c
*/ */
#define _USE_MATH_DEFINES /**< required for MS Visual C */ #define _USE_MATH_DEFINES /**< required for MS Visual C */
#include <math.h> #include <math.h>
@ -219,6 +220,7 @@ void get_min_2d(double **X, int N, double *val, int *x_idx, int *y_idx)
* \param[in] num_features number of features per input sample * \param[in] num_features number of features per input sample
* \param[in] alpha learning rate \f$0<\alpha\le1\f$ * \param[in] alpha learning rate \f$0<\alpha\le1\f$
* \param[in] R neighborhood range * \param[in] R neighborhood range
* \returns minimum distance of sample and trained weights
*/ */
double update_weights(const double *X, struct array_3d *W, double **D, double update_weights(const double *X, struct array_3d *W, double **D,
int num_out, int num_features, double alpha, int R) int num_out, int num_features, double alpha, int R)
@ -308,7 +310,8 @@ void kohonen_som(double **X, struct array_3d *W, int num_samples,
for (int i = 0; i < num_out; i++) for (int i = 0; i < num_out; i++)
D[i] = (double *)malloc(num_out * sizeof(double)); D[i] = (double *)malloc(num_out * sizeof(double));
double dmin = 1.f; double dmin = 1.f; // average minimum distance of all samples
// Loop alpha from 1 to slpha_min // Loop alpha from 1 to slpha_min
for (double alpha = 1.f; alpha > alpha_min && dmin > 1e-3; for (double alpha = 1.f; alpha > alpha_min && dmin > 1e-3;
alpha -= 0.001, iter++) alpha -= 0.001, iter++)
@ -385,17 +388,6 @@ void test_2d_classes(double *const *data, int N)
* * `test1.csv`: random test samples points with a circular pattern * * `test1.csv`: random test samples points with a circular pattern
* * `w11.csv`: initial random map * * `w11.csv`: initial random map
* * `w12.csv`: trained SOM map * * `w12.csv`: trained SOM map
*
* The outputs can be readily plotted in [gnuplot](https:://gnuplot.info) using
* the following snippet
* ```gnuplot
* set datafile separator ','
* plot "test1.csv" title "original", \
* "w11.csv" title "w1", \
* "w12.csv" title "w2"
* ```
* ![Sample execution
* output](https://raw.githubusercontent.com/kvedala/C/docs/images/machine_learning/kohonen/test1.svg)
*/ */
void test1() void test1()
{ {
@ -496,17 +488,6 @@ void test_3d_classes1(double *const *data, int N)
* * `test2.csv`: random test samples points with a lamniscate pattern * * `test2.csv`: random test samples points with a lamniscate pattern
* * `w21.csv`: initial random map * * `w21.csv`: initial random map
* * `w22.csv`: trained SOM map * * `w22.csv`: trained SOM map
*
* The outputs can be readily plotted in [gnuplot](https:://gnuplot.info) using
* the following snippet
* ```gnuplot
* set datafile separator ','
* plot "test2.csv" title "original", \
* "w21.csv" title "w1", \
* "w22.csv" title "w2"
* ```
* ![Sample execution
* output](https://raw.githubusercontent.com/kvedala/C/docs/images/machine_learning/kohonen/test2.svg)
*/ */
void test2() void test2()
{ {
@ -610,17 +591,6 @@ void test_3d_classes2(double *const *data, int N)
* * `test3.csv`: random test samples points with a circular pattern * * `test3.csv`: random test samples points with a circular pattern
* * `w31.csv`: initial random map * * `w31.csv`: initial random map
* * `w32.csv`: trained SOM map * * `w32.csv`: trained SOM map
*
* The outputs can be readily plotted in [gnuplot](https:://gnuplot.info) using
* the following snippet
* ```gnuplot
* set datafile separator ','
* plot "test3.csv" title "original", \
* "w31.csv" title "w1", \
* "w32.csv" title "w2"
* ```
* ![Sample execution
* output](https://raw.githubusercontent.com/kvedala/C/docs/images/machine_learning/kohonen/test3.svg)
*/ */
void test3() void test3()
{ {