- Added gaussian hidden units
This commit is contained in:
+15
-4
@@ -131,16 +131,23 @@ void Rbm::gibbs_hv(arma::mat &h_probs, arma::mat &v_probs) const
|
||||
void Rbm::contrastiveDivergence(arma::mat const &v_states, arma::mat &dw, arma::mat &dbhv, arma::mat &dbv)
|
||||
{
|
||||
arma::mat v_probs(v_states);
|
||||
arma::mat h_states = v_to_h(v_states);
|
||||
arma::mat h_probs = prob(h_states);
|
||||
arma::mat h_states;
|
||||
arma::mat h_probs;
|
||||
|
||||
// Sample hidden
|
||||
if (m_params.doRaoBlackwell)
|
||||
if (m_params.doGaussianVisible)
|
||||
{
|
||||
h_probs = v_to_h(v_states);
|
||||
h_states = h_probs + arma::randn(h_probs.n_rows, h_probs.n_cols);
|
||||
}
|
||||
else if (m_params.doRaoBlackwell)
|
||||
{
|
||||
h_probs = prob(v_to_h(v_states));
|
||||
h_states = h_probs;
|
||||
}
|
||||
else
|
||||
{
|
||||
h_probs = prob(v_to_h(v_states));
|
||||
h_states = sample(h_probs);
|
||||
}
|
||||
|
||||
@@ -163,7 +170,11 @@ void Rbm::contrastiveDivergence(arma::mat const &v_states, arma::mat &dw, arma::
|
||||
}
|
||||
|
||||
// Create hidden representation given v
|
||||
if (m_params.gibbsDoSampleVisible)
|
||||
if (m_params.doGaussianHidden)
|
||||
{
|
||||
h_probs = v_to_h(v_probs);
|
||||
}
|
||||
else if (m_params.gibbsDoSampleVisible)
|
||||
{
|
||||
h_probs = prob(v_to_h(sample(v_probs)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user