24 #ifndef SOM_SOMTRAINER_H
25 #define SOM_SOMTRAINER_H
41 template <std::
size_t ND,
typename DistFunc,
typename InputIter,
typename InputToWeightFunc>
50 if (learn_factor == 0) {
55 for (
auto it = sampling_policy.start(begin, end); it != end; it = sampling_policy.next(it)) {
58 auto input_weights = weight_func(*it);
64 std::tie(bmu_x, bmu_y, nd_distance) = som.findBMU(*it, weight_func);
67 for (
auto cell_it = som.begin(); cell_it != som.end(); ++cell_it) {
70 auto cell_x = cell_it.template axisValue<0>();
71 auto cell_y = cell_it.template axisValue<1>();
72 auto neighborhood_factor =
m_neighborhood_func({bmu_x, bmu_y}, {cell_x, cell_y}, i, iter_no);
75 if (neighborhood_factor != 0) {
76 auto& cell_weights = *cell_it;
78 cell_weights[wi] = cell_weights[wi] + neighborhood_factor * learn_factor * (input_weights[wi] - cell_weights[wi]);
SOMTrainer(NeighborhoodFunc::Signature neighborhood_func, LearningRestraintFunc::Signature learning_restraint_func)
NeighborhoodFunc::Signature m_neighborhood_func
void train(SOM< ND, DistFunc > &som, std::size_t iter_no, InputIter begin, InputIter end, InputToWeightFunc weight_func, const SamplingPolicy::Interface< InputIter > &sampling_policy=SamplingPolicy::FullSet< InputIter >{})
LearningRestraintFunc::Signature m_learning_restraint_func