simple_weight_update.hpp
Go to the documentation of this file.
1 
12 #ifndef _MLPACK_METHODS_PERCEPTRON_LEARNING_POLICIES_SIMPLE_WEIGHT_UPDATE_HPP
13 #define _MLPACK_METHODS_PERCEPTRON_LEARNING_POLICIES_SIMPLE_WEIGHT_UPDATE_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
27 namespace mlpack {
28 namespace perceptron {
29 
31 {
32  public:
49  template<typename VecType>
50  void UpdateWeights(const VecType& trainingPoint,
51  arma::mat& weights,
52  arma::vec& biases,
53  const size_t incorrectClass,
54  const size_t correctClass,
55  const double instanceWeight = 1.0)
56  {
57  weights.col(incorrectClass) -= instanceWeight * trainingPoint;
58  biases(incorrectClass) -= instanceWeight;
59 
60  weights.col(correctClass) += instanceWeight * trainingPoint;
61  biases(correctClass) += instanceWeight;
62  }
63 };
64 
65 } // namespace perceptron
66 } // namespace mlpack
67 
68 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
void UpdateWeights(const VecType &trainingPoint, arma::mat &weights, arma::vec &biases, const size_t incorrectClass, const size_t correctClass, const double instanceWeight=1.0)
This function is called to update the weightVectors matrix.
The core includes that mlpack expects; standard C++ includes and Armadillo.