API Reference‎ > ‎

perceptron_trainer_t


class perceptron_trainer_t : public nn_trainer_t<perceptron_t, vector_t<double>, double >;

    This trainer class is a specialization of generic nn_trainer_t for perceptron_t







Header


Namespace

  • nu

Constructors 

  • perceptron_trainer_t(perceptron_t & nn, size_t epochs, double min_errnoexcept;

    Creates a Perceptron neural network trainer

    • nn: a reference to training network
    • epochs: max epoch count at which to stop training
    • min_errmin error value at which to stop training

Inherited public methods

The following methods and properties are inherited from nn_trainer_t class:
  • size_t get_epochs() const noexcept;
    Return the max number of epochs
  • double get_min_err() const noexcept;
    Return the min error value at which to stop training
  • double get_error() const noexcept;
    Return current epoch error
  • bool train(const Inputinput, const Targettarget, cost_func_t err_cost_f);
    const Inputinput:    [in] sample input
    const Targettarget:  [in] target output corresponding the given input
    cost_func_t err_cost_f:
    [in] function object which is used to calculate the error at each iteration
    Train the net using a single sample. Return true if get_error() < get_min_error()
  • template <class TSet> 
    size_t train(const TSettraining_set, cost_func_t err_cost_f, progress_cbk_tprogress_cbk = nullptr);
    TSet is a generic collection of std::pair of <Input,Target>
    const TSettraining_set:      [in] training samples set
    cost_func_t err_cost_f:        [in] function object which is used to calculate the error at each iteration
    progress_cbk_t * progress_cbk: [in, opt] if specified is called back for each iteration.

    This template method trains the net using a training set of samples, repeating the training procedure for a max number of epoch equal to get_epochs()
    Every epoch it repeats the training for each sample in the set. 
    Training procedure terminates if err_cost_f() return an error value smaller than get_min_err().
    The method returns the number of last epoch within the range 0..get_epochs(). If return value equals get_epochs() then the min error is not reached and training procedure terminated because the maximum number of epochs has been completed.


Comments