- use dir in file names
- fixed missing returns - fixed test app git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@782 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+6
-7
@@ -49,9 +49,9 @@ bool Layer::weightsLoad(std::string const &dir, std::string const &prj)
|
|||||||
arma::mat bh;
|
arma::mat bh;
|
||||||
arma::mat bv;
|
arma::mat bv;
|
||||||
bool result = true;
|
bool result = true;
|
||||||
result &= w.load(filePrefix(prj) + ".w.dat", arma::arma_ascii);
|
result &= w.load(filePrefix(dir, prj) + ".w.dat", arma::arma_ascii);
|
||||||
result &= bh.load(filePrefix(prj) + ".bh.dat", arma::arma_ascii);
|
result &= bh.load(filePrefix(dir, prj) + ".bh.dat", arma::arma_ascii);
|
||||||
result &= bv.load(filePrefix(prj) + ".bv.dat", arma::arma_ascii);
|
result &= bv.load(filePrefix(dir, prj) + ".bv.dat", arma::arma_ascii);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
@@ -65,9 +65,9 @@ bool Layer::weightsLoad(std::string const &dir, std::string const &prj)
|
|||||||
bool Layer::weightsSave(std::string const &dir, std::string const &prj)
|
bool Layer::weightsSave(std::string const &dir, std::string const &prj)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
result &= whv().save(filePrefix(prj) + ".w.dat", arma::arma_ascii);
|
result &= whv().save(filePrefix(dir, prj) + ".w.dat", arma::arma_ascii);
|
||||||
result &= bh().save(filePrefix(prj) + ".bh.dat", arma::arma_ascii);
|
result &= bh().save(filePrefix(dir, prj) + ".bh.dat", arma::arma_ascii);
|
||||||
result &= bv().save(filePrefix(prj) + ".bv.dat", arma::arma_ascii);
|
result &= bv().save(filePrefix(dir, prj) + ".bv.dat", arma::arma_ascii);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,6 @@ Json::Value Layer::toJson() const
|
|||||||
Json::Value layer;
|
Json::Value layer;
|
||||||
layer["name"] = m_name;
|
layer["name"] = m_name;
|
||||||
layer["id"] = (int)m_id;
|
layer["id"] = (int)m_id;
|
||||||
layer["weights_file"] = filePrefix("") + ".weights.dat";
|
|
||||||
layer["numVisibleX"] = (int)m_numVisibleX;
|
layer["numVisibleX"] = (int)m_numVisibleX;
|
||||||
layer["numVisibleY"] = (int)m_numVisibleY;
|
layer["numVisibleY"] = (int)m_numVisibleY;
|
||||||
layer["numHidden"] = (int)whv().n_cols;
|
layer["numHidden"] = (int)whv().n_cols;
|
||||||
|
|||||||
+2
-2
@@ -141,14 +141,14 @@ private:
|
|||||||
// Compatibility
|
// Compatibility
|
||||||
bool loadWeights(const std::string &prjname="");
|
bool loadWeights(const std::string &prjname="");
|
||||||
bool saveWeights(const std::string &prjname="");
|
bool saveWeights(const std::string &prjname="");
|
||||||
std::string filePrefix(const std::string &prjname) const
|
std::string filePrefix(const std::string &dir, const std::string &prjname) const
|
||||||
{
|
{
|
||||||
std::string filename = m_name + "." + std::to_string((int)m_id);
|
std::string filename = m_name + "." + std::to_string((int)m_id);
|
||||||
if (prjname.size() > 0)
|
if (prjname.size() > 0)
|
||||||
{
|
{
|
||||||
filename = prjname + "." + filename;
|
filename = prjname + "." + filename;
|
||||||
}
|
}
|
||||||
return filename;
|
return dir + "/" + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-2
@@ -244,8 +244,8 @@ size_t Stack::loadTrainingBatch(bool doNormalize)
|
|||||||
m_trainingBatch = Rbm::normalize(m_trainingBatch);
|
m_trainingBatch = Rbm::normalize(m_trainingBatch);
|
||||||
}
|
}
|
||||||
std::cout << "Loaded " << m_trainingBatch.n_rows << " training samples\n";
|
std::cout << "Loaded " << m_trainingBatch.n_rows << " training samples\n";
|
||||||
return m_trainingBatch.n_rows;
|
|
||||||
}
|
}
|
||||||
|
return m_trainingBatch.n_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Stack::saveTrainingBatch()
|
size_t Stack::saveTrainingBatch()
|
||||||
@@ -256,8 +256,9 @@ size_t Stack::saveTrainingBatch()
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
std::cout << "Saved " << m_trainingBatch.n_rows << " training samples\n";
|
std::cout << "Saved " << m_trainingBatch.n_rows << " training samples\n";
|
||||||
return m_trainingBatch.n_rows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return m_trainingBatch.n_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Stack::numTraining()
|
size_t Stack::numTraining()
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ int main()
|
|||||||
const string project("test");
|
const string project("test");
|
||||||
|
|
||||||
RbmListener statusDisplay;
|
RbmListener statusDisplay;
|
||||||
Stack stack(project);
|
Stack stack(".", project);
|
||||||
|
|
||||||
stack.loadTrainingBatch();
|
stack.loadTrainingBatch();
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
"numGibbs" : 1,
|
"numGibbs" : 1,
|
||||||
"weightDecay" : 0.0
|
"weightDecay" : 0.0
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"weights_file" : "Layer.0.weights.dat"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 1,
|
"id" : 1,
|
||||||
@@ -40,12 +39,55 @@
|
|||||||
"learningRate" : 0.050000000000000003,
|
"learningRate" : 0.050000000000000003,
|
||||||
"miniBatchSize" : 100,
|
"miniBatchSize" : 100,
|
||||||
"momentum" : 0.5,
|
"momentum" : 0.5,
|
||||||
"numEpochs" : 5000,
|
"numEpochs" : 500,
|
||||||
"numGibbs" : 1,
|
"numGibbs" : 1,
|
||||||
"weightDecay" : 0.0
|
"weightDecay" : 0.0
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"weights_file" : "Layer.1.weights.dat"
|
},
|
||||||
|
{
|
||||||
|
"id" : 2,
|
||||||
|
"name" : "Layer",
|
||||||
|
"numContext" : 0,
|
||||||
|
"numHidden" : 2,
|
||||||
|
"numVisibleX" : 4,
|
||||||
|
"numVisibleY" : 1,
|
||||||
|
"rbm" : {
|
||||||
|
"params" : {
|
||||||
|
"doRaoBlackwell" : 1,
|
||||||
|
"doSampleBatch" : 0,
|
||||||
|
"gibbsDoSampleHidden" : 1,
|
||||||
|
"gibbsDoSampleVisible" : 0,
|
||||||
|
"learningRate" : 0.025000000000000001,
|
||||||
|
"miniBatchSize" : 100,
|
||||||
|
"momentum" : 0.5,
|
||||||
|
"numEpochs" : 250,
|
||||||
|
"numGibbs" : 1,
|
||||||
|
"weightDecay" : 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 3,
|
||||||
|
"name" : "Layer",
|
||||||
|
"numContext" : 0,
|
||||||
|
"numHidden" : 1,
|
||||||
|
"numVisibleX" : 2,
|
||||||
|
"numVisibleY" : 1,
|
||||||
|
"rbm" : {
|
||||||
|
"params" : {
|
||||||
|
"doRaoBlackwell" : 1,
|
||||||
|
"doSampleBatch" : 0,
|
||||||
|
"gibbsDoSampleHidden" : 1,
|
||||||
|
"gibbsDoSampleVisible" : 0,
|
||||||
|
"learningRate" : 0.012500000000000001,
|
||||||
|
"miniBatchSize" : 100,
|
||||||
|
"momentum" : 0.5,
|
||||||
|
"numEpochs" : 125,
|
||||||
|
"numGibbs" : 1,
|
||||||
|
"weightDecay" : 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name" : "test"
|
"name" : "test"
|
||||||
|
|||||||
Reference in New Issue
Block a user