- added param sparsity

- added gaussian visible unit
- added param sigma decay
- RBM modi and params are set using members
- use sigma instead of variance


git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@25 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-10-14 21:23:01 +00:00
parent 0166b986cb
commit 7f4438d698
5 changed files with 541 additions and 182 deletions
+21 -9
View File
@@ -65,24 +65,25 @@ public:
m_states.fill(value);
}
void probsUpdateLogistic(Layer &layer, Weights &weights, double lambda = 1.0, double variance = 1.0)
void probsUpdateLogistic(Layer &layer, Weights &weights, double lambda, double sigma)
{
uint32_t i;
for (i=0; i < m_numUnits; i++)
{
m_probs(i) = lambda/variance*accum(layer, weights, i);
m_probs(i) = lambda/sigma*accum(layer, weights, i);
}
logSigmoid(m_probs);
}
void probsUpdateGaussian(Layer &layer, Weights &weights, double lambda, double variance)
void probsUpdateGaussian(Layer &layer, Weights &weights, double lambda, double sigma)
{
uint32_t i;
for (i=0; i < m_numUnits; i++)
{
m_probs(i) = lambda*accum(layer, weights, i);
}
gaussProb(m_probs, variance);
gaussProb(m_probs, sigma);
}
void statesUpdateStochastic()
@@ -97,6 +98,16 @@ public:
}
}
void sampleGaussian(Layer &layer, Weights &weights, double lambda, double sigma)
{
uint32_t i;
for (i=0; i < m_numUnits; i++)
{
m_states(i) = Noise_Gaussian(&m_noise, 0, sigma) + lambda*accum(layer, weights, i);
}
}
VectorXd& probs()
{
return m_probs;
@@ -133,17 +144,18 @@ protected:
}
}
void gaussProb(const VectorXd &x, double var)
void gaussProb(const VectorXd &x, double sigma)
{
double k = 1.0/sqrt(var*2*3.14159265359);
double mu = 0;
double var = sigma*sigma;
double k = 1.0/sqrt(2*3.14159265359*var);
double mu = 1;
uint32_t i;
for (i=0; i < m_numUnits; i++)
{
double x2 = ((double)x[i]-mu) * ((double)x[i]-mu);
m_probs[i] = k*exp(-x2/(2*var));
double x2 = ((double)x[i]-mu);
m_probs[i] = k*exp(-x2*x2/(2*var));
}
}
};