- use arma::randu for uniform

- use arma functions for sample()

git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@798 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2022-01-13 10:27:10 +00:00
parent be64a88e04
commit 1eb631d254
+9 -3
View File
@@ -240,7 +240,8 @@ arma::mat Rbm::sample(const arma::mat &src)
{
arma::mat dst = src;
uniform(dst);
#if 0
for (size_t i=0; i < src.n_rows; i++)
{
for (size_t j=0; j < src.n_cols; j++)
@@ -249,6 +250,11 @@ arma::mat Rbm::sample(const arma::mat &src)
}
}
return dst;
#else
arma::umat res = (dst < src);
return arma::conv_to<arma::mat>::from(res);
#endif
}
arma::mat Rbm::v_to_h(const arma::mat &visible) const
@@ -275,7 +281,7 @@ arma::mat Rbm::normalize(const arma::mat& src)
void Rbm::uniform(arma::mat& srcDst, double stdDev, double mu)
{
#if 1
#if 0
for (size_t i=0; i < srcDst.n_rows; i++)
{
for (size_t j=0; j < srcDst.n_cols; j++)
@@ -284,7 +290,7 @@ void Rbm::uniform(arma::mat& srcDst, double stdDev, double mu)
}
}
#else
srcDst = stdDev*(arma::randu(srcDst.n_rows, srcDst.n_cols) + mu - 0.5);
srcDst = stdDev*(arma::randu(arma::size(srcDst)) + mu - 0.5);
#endif
}