mlpack
3.4.2
mlpack-3.4.2
src
mlpack
methods
perceptron
learning_policies
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
30
class
SimpleWeightUpdate
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
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack::perceptron::SimpleWeightUpdate::UpdateWeights
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.
Definition:
simple_weight_update.hpp:50
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition:
add_to_cli11.hpp:21
mlpack::perceptron::SimpleWeightUpdate
Definition:
simple_weight_update.hpp:31
Generated by
1.8.20