mlpack  2.0.1
simple_weight_update.hpp
Go to the documentation of this file.
1 
14 #ifndef _MLPACK_METHODS_PERCEPTRON_LEARNING_POLICIES_SIMPLE_WEIGHT_UPDATE_HPP
15 #define _MLPACK_METHODS_PERCEPTRON_LEARNING_POLICIES_SIMPLE_WEIGHT_UPDATE_HPP
16 
17 #include <mlpack/core.hpp>
18 
29 namespace mlpack {
30 namespace perceptron {
31 
33 {
34  public:
51  template<typename VecType>
52  void UpdateWeights(const VecType& trainingPoint,
53  arma::mat& weights,
54  arma::vec& biases,
55  const size_t incorrectClass,
56  const size_t correctClass,
57  const double instanceWeight = 1.0)
58  {
59  weights.col(incorrectClass) -= instanceWeight * trainingPoint;
60  biases(incorrectClass) -= instanceWeight;
61 
62  weights.col(correctClass) += instanceWeight * trainingPoint;
63  biases(correctClass) += instanceWeight;
64  }
65 };
66 
67 } // namespace perceptron
68 } // namespace mlpack
69 
70 #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.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...