24 #ifndef SOM_SOMTRAINER_H
25 #define SOM_SOMTRAINER_H
45 template <std::
size_t ND,
typename DistFunc,
typename InputIter,
typename InputToWeightFunc>
54 if (learn_factor == 0) {
59 for (
auto it = sampling_policy.start(begin, end); it != end; it = sampling_policy.next(it)) {
62 auto input_weights = weight_func(*it);
68 std::tie(bmu_x, bmu_y, nd_distance) = som.findBMU(*it, weight_func);
71 for (
auto cell_it = som.begin(); cell_it != som.end(); ++ cell_it) {
74 auto cell_x = cell_it.template axisValue<0>();
75 auto cell_y = cell_it.template axisValue<1>();
76 auto neighborhood_factor =
m_neighborhood_func({bmu_x, bmu_y}, {cell_x, cell_y}, i, iter_no);
79 if (neighborhood_factor != 0) {
80 auto& cell_weights = *cell_it;
82 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