- refactored

git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@811 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2022-01-15 09:19:50 +00:00
parent eb8d399636
commit 4b7c29effd
3 changed files with 66 additions and 54 deletions
+44
View File
@@ -40,6 +40,50 @@ Rbm::~Rbm()
Noise_Free(&m_noise);
}
size_t Rbm::numHidden() const
{
return m_bhv.size();
}
size_t Rbm::numVisible() const
{
return m_bv.size();
}
Rbm::Params& Rbm::params()
{
return m_params;
}
arma::mat Rbm::rms_error(arma::mat diffErr)
{
arma::mat diffErr_squared = diffErr % diffErr;
return arma::sum(diffErr_squared, 1) * 1.0 / diffErr_squared.n_cols;
}
double Rbm::rms_error_accu(arma::mat diffErr)
{
arma::mat diffErr_squared = diffErr % diffErr;
return arma::accu(diffErr_squared) / diffErr_squared.n_elem;
}
arma::mat Rbm::toHiddenProbs(const arma::mat& visible) const
{
return Rbm::prob(v_to_h(visible));
}
arma::mat Rbm::toVisibleProbs(const arma::mat& hidden) const
{
return Rbm::prob(h_to_v(hidden));
}
void Rbm::weightsAssign(const arma::mat& w, const arma::mat& bhv, const arma::mat& bv)
{
m_whv.submat(0, 0, w.n_rows - 1, w.n_cols - 1) = w;
m_bhv.submat(0, 0, bhv.n_rows - 1, bhv.n_cols - 1) = bhv;
m_bv.submat(0, 0, bv.n_rows - 1, bv.n_cols - 1) = bv;
}
void Rbm::weightsInit(double stddev, double mu)
{
uniform(m_whv, stddev, mu);