- fully refactored traning

- removed non working stuff

git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@553 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-10-17 18:58:12 +00:00
parent b46c65c492
commit 0f2fe2b315
4 changed files with 105 additions and 284 deletions
+7 -40
View File
@@ -20,75 +20,44 @@ public:
struct Params
{
Params()
: m_constantSigma(1.0)
, m_sigmaDecay(0.0)
, m_weightDecay(0.0)
, m_lambda(1.0)
, m_sparsity(0.05)
, m_muWeights(0.1)
, m_muSparsity(0.01)
: m_weightDecay(0.01)
, m_learningRate(0.1)
, m_momentum(0.5)
, m_useVisibleGaussian(false)
, m_useHiddenGaussian(false)
, m_doRaoBlackwell(true)
, m_doSampleVisible(false)
, m_doSampleBatch(false)
, m_doSparse(false)
, m_doNormalizeData(false)
, m_doLearnVariance(false)
, m_numGibbs(1)
{
}
double m_constantSigma;
double m_sigmaDecay;
double m_weightDecay;
double m_lambda;
double m_sparsity;
double m_muWeights;
double m_muSparsity;
double m_learningRate;
double m_momentum;
bool m_useVisibleGaussian;
bool m_useHiddenGaussian;
bool m_doRaoBlackwell;
bool m_doSampleVisible;
bool m_doSampleBatch;
bool m_doSparse;
bool m_doNormalizeData;
bool m_doLearnVariance;
size_t m_numGibbs;
};
Rbm(Weights &weights, const MatrixXd &batch);
~Rbm();
void sample(MatrixXd &srcDst);
MatrixXd sample(MatrixXd const &src);
void sample(MatrixXd &dst, MatrixXd const &src);
static void probsLogistic(MatrixXd &srcDst);
static void probsLogistic(RowVectorXd &srcDst);
static MatrixXd probsLogistic(MatrixXd const &src);
static RowVectorXd probsLogistic(RowVectorXd const &src);
void sampleGaussian(MatrixXd &dst, MatrixXd const &src);
void sampleGaussian(MatrixXd &srcDst);
void normalizeData(MatrixXd &dst, MatrixXd const &src);
static MatrixXd normalizeData(MatrixXd const &src);
void train(size_t numEpochs, size_t miniBatchSize, double sigmaMin = 0.05);
double getProgress() const;
void toHidden(RowVectorXd &h, RowVectorXd const &v);
void toVisible(RowVectorXd &v, RowVectorXd const &h);
void setConstantSigma(double value);
RowVectorXd& getVariableSigma();
void setSigmaDecay(double value);
void setWeightDecay(double value);
void setLambda(double value);
void setSparsity(double value);
void setUseVisibleGaussian(bool flag);
void setUseHiddenGaussian(bool flag);
void setDoRaoBlackwell(bool flag);
void setDoSampleVisible(bool flag);
void setDoSampleBatch(bool flag);
void setDoSparse(bool flag);
void setNormalizeData(bool flag);
void setDoLearnVariance(bool flag);
void setNumGibbs(size_t value);
void setMuWeights(double value);
void setMuSparsity(double value);
void setMomentum(double value);
MatrixXd const& getHiddenBatch();
MatrixXd const& getBatch();
@@ -98,9 +67,7 @@ public:
private:
Weights &m_w;
MatrixXd const &m_batch;
MatrixXd m_batch_normalized;
MatrixXd m_h;
RowVectorXd m_variableSigma;
noise_gen_t m_noise;
double m_progress;
Params m_params;