- improved training data normalization
This commit is contained in:
+14
-7
@@ -55,17 +55,24 @@ namespace Matutils
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline arma::mat normalize(const arma::mat& src)
|
inline arma::mat normalize(const arma::mat& src)
|
||||||
{
|
{
|
||||||
double mean = arma::accu(src)/src.n_elem;
|
std::cout << "Normalizing Training Data ..." << std::endl;
|
||||||
arma::mat x = src - mean;
|
#if 0
|
||||||
arma::mat x2 = x % x;
|
// Normalize over training all training pattern
|
||||||
double stddev = sqrt(arma::accu(x2)/x2.n_elem);
|
arma::mat xn = arma::normalise(src, 2, 0);
|
||||||
|
arma::mat mean = arma::mean(src, 0);
|
||||||
|
arma::mat stddev = arma::stddev(src, 0);
|
||||||
|
#else
|
||||||
|
// Normalize over single training pattern
|
||||||
|
arma::mat xn = arma::normalise(src, 2, 1);
|
||||||
|
arma::mat mean = arma::mean(src, 1);
|
||||||
|
arma::mat stddev = arma::stddev(src, 1);
|
||||||
|
#endif
|
||||||
std::cout << "mean" << " : " << std::endl << mean << std::endl;
|
std::cout << "mean" << " : " << std::endl << mean << std::endl;
|
||||||
std::cout << "stddev" << ": " << std::endl << stddev << std::endl;
|
std::cout << "stddev" << ": " << std::endl << stddev << std::endl;
|
||||||
return x/stddev;
|
return xn;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline arma::mat char2vec(char c, size_t len)
|
inline arma::mat char2vec(char c, size_t len)
|
||||||
|
|||||||
Reference in New Issue
Block a user