- improved cd_hinton()

- uniform() returns vector
This commit is contained in:
2024-02-01 19:03:13 +01:00
parent 8e44aff7a5
commit 5321e01cca
2 changed files with 25 additions and 42 deletions
+3 -28
View File
@@ -21,40 +21,15 @@
namespace Matutils
{
const size_t NORMALIZING_DIM = 1;
inline void uniform(arma::mat& srcDst, double stdDev=1.0, double mu=0.5)
inline arma::mat uniform(arma::mat const & sizeMat, double stdDev=1.0, double mu=0.5)
{
#if 0
for (size_t i=0; i < srcDst.n_rows; i++)
{
for (size_t j=0; j < srcDst.n_cols; j++)
{
srcDst(i, j) = stdDev*(Noise_Uniform(&m_noise) + mu - 0.5);
}
}
#else
srcDst = stdDev*(arma::randu(arma::size(srcDst)) + mu - 0.5);
#endif
return stdDev*(arma::randu(arma::size(sizeMat)) + mu - 0.5);
}
inline arma::mat sample(const arma::mat &src)
{
arma::mat rand = src;
uniform(rand);
#if 0
for (size_t i=0; i < src.n_rows; i++)
{
for (size_t j=0; j < src.n_cols; j++)
{
dst(i, j) = src(i, j) >= dst(i, j);
}
}
return dst;
#else
arma::umat res = (src > rand);
arma::umat res = (src > uniform(src));
return arma::conv_to<arma::mat>::from(res);
#endif
}
inline arma::mat prob(const arma::mat &src)