File: som_interface.h

package info (click to toggle)
python-pyclustering 0.10.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 38,888; python: 24,311; sh: 384; makefile: 105
file content (156 lines) | stat: -rwxr-xr-x 5,291 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*!

@authors Andrei Novikov (pyclustering@yandex.ru)
@date 2014-2020
@copyright BSD-3-Clause

*/

#pragma once


#include <cstddef>

#include <pyclustering/nnet/som.hpp>

#include <pyclustering/interface/pyclustering_package.hpp>

#include <pyclustering/definitions.hpp>


/**
*
* @brief    Creates self-organized feature map (SOM).
* @details  Caller should destroy created instance by 'som_destroy' when it is not required.
*
* @param[in] num_rows: amount of neurons in each row of the map.
* @param[in] num_cols: amount of neurons in each column of the map.
* @param[in] type_conn: type of connections between neurons (grid-four, grid-eight, honeycomb, defined by neighbor function, etc.).
* @param[in] parameters: pointer to parameters of the map.
*
* @return Pointer to instance of self-organized feature map.
*
* @see  som_destroy
*
*/
extern "C" DECLARATION void * som_create(const size_t num_rows, const size_t num_cols, const size_t type_conn, const void * parameters);

/**
*
* @brief Destroy instance of self-organized feature map (SOM).
*
* @param[in] pointer: pointer to instance of self-organized feature map.
*
*/
extern "C" DECLARATION void som_destroy(const void * pointer);

/**
*
* @brief    Load network parameters such weights, amount of won objects by each neuron (optional), captuted objects by each neuron (optional).
*
* @param[in] p_pointer: pointer to instance of self-organized feature map.
* @param[in] p_weights: weights that should be load to the network.
* @param[in] p_awards: amount of captured objects by each neuron (optional parameter and can be 'nullptr').
* @param[in] p_captured_objects: captured objects by each neuron (optional parameter and can be 'nullptr').
*
* @see  som_destroy
*
*/
extern "C" DECLARATION void som_load(const void * p_pointer, const pyclustering_package * p_weights, const pyclustering_package * p_awards, const pyclustering_package * p_captured_objects);

/**
*
* @brief   Trains self-organized feature map (SOM).
*
* @param[in] pointer: pointer to instance of self-organized feature map.
* @param[in] sample: pointer to input dataset for training.
* @param[in] epochs: number of epochs for training.
* @param[in] autostop: stop learining when convergance is too low.
*
* @return  Returns number of learining iterations.
*
*/
extern "C" DECLARATION size_t som_train(const void * pointer, const pyclustering_package * const sample, const size_t epochs, const bool autostop);

/**
*
* @brief   Processes input pattern (no learining) and returns index of neuron-winner.
* @details Using index of neuron winner catched object can be obtained by som_get_capture_objects().
*
* @param[in] pointer: pointer to instance of self-organized feature map.
* @param[in] p_pattern: input pattern for processing.
*
* @return  Returns index of neuron-winner.
*
* @see som_get_capture_objects()
*
*/
extern "C" DECLARATION size_t som_simulate(const void * pointer, const pyclustering_package * const p_pattern);

/**
*
* @brief  Returns number of neuron winners at the last step of learning process.
*
* @param[in] pointer: pointer to instance of self-organized feature map.
*
* @return Returns amout of neurons that are winners.
*
*/
extern "C" DECLARATION size_t som_get_winner_number(const void * pointer);

/**
*
* @brief  Returns size of self-organized map (number of neurons in the map).
*
* @param[in] pointer: pointer to instance of self-organized feature map.
*
*/
extern "C" DECLARATION size_t som_get_size(const void * pointer);

/**
*
* @brief  Returns neuron weights in pyclustering package.
* @details  Allocated puclustering package should be freed by caller using 'free_pyclustering_package'.
*
* @param[in] pointer: pointer to instance of self-organized feature map.
*
* @return Neuron weights in pyclustering package.
*
*/
extern "C" DECLARATION pyclustering_package * som_get_weights(const void * pointer);

/**
*
* @brief  Returns sequence of captured objects by each neuron during training.
* @details  Allocated puclustering package should be freed by caller using 'free_pyclustering_package'.
*
* @param[in] pointer: pointer to instance of self-organized feature map.
*
* @return Captured objects by each neuron in pyclustering package.
*
*/
extern "C" DECLARATION pyclustering_package * som_get_capture_objects(const void * pointer);

/**
*
* @brief  Returns amount of captured objects by each neuron during training.
* @details  Allocated puclustering package should be freed by caller using 'free_pyclustering_package'.
*
* @param[in] pointer: pointer to instance of self-organized feature map.
*
* @return Amount of captured objects by each neuron in pyclustering package.
*
*/
extern "C" DECLARATION pyclustering_package * som_get_awards(const void * pointer);

/**
*
* @brief  Returns neighbor indexes of each neuron.
* @details  Allocated puclustering package should be freed by caller using 'free_pyclustering_package'.
*
* @param[in] pointer: pointer to instance of self-organized feature map.
*
* @return Neighbor indexes of each neuron in pyclustering package.
*
*/
extern "C" DECLARATION pyclustering_package * som_get_neighbors(const void * pointer);