mlpack  1.0.12
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:
47  void UpdateWeights(const arma::mat& trainData,
48  arma::mat& weightVectors,
49  const size_t labelIndex,
50  const size_t vectorIndex,
51  const size_t rowIndex,
52  const arma::rowvec& D)
53  {
54  weightVectors.row(rowIndex) = weightVectors.row(rowIndex) -
55  D(labelIndex) * trainData.col(labelIndex).t();
56 
57  weightVectors.row(vectorIndex) = weightVectors.row(vectorIndex) +
58  D(labelIndex) * trainData.col(labelIndex).t();
59  }
60 };
61 
62 }; // namespace perceptron
63 }; // namespace mlpack
64 
65 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
void UpdateWeights(const arma::mat &trainData, arma::mat &weightVectors, const size_t labelIndex, const size_t vectorIndex, const size_t rowIndex, const arma::rowvec &D)
This function is called to update the weightVectors matrix.