- 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 bv;
|
||||
bool result = true;
|
||||
result &= w.load(filePrefix(prj) + ".w.dat", arma::arma_ascii);
|
||||
result &= bh.load(filePrefix(prj) + ".bh.dat", arma::arma_ascii);
|
||||
result &= bv.load(filePrefix(prj) + ".bv.dat", arma::arma_ascii);
|
||||
result &= w.load(filePrefix(dir, prj) + ".w.dat", arma::arma_ascii);
|
||||
result &= bh.load(filePrefix(dir, prj) + ".bh.dat", arma::arma_ascii);
|
||||
result &= bv.load(filePrefix(dir, prj) + ".bv.dat", arma::arma_ascii);
|
||||
|
||||
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 result = true;
|
||||
result &= whv().save(filePrefix(prj) + ".w.dat", arma::arma_ascii);
|
||||
result &= bh().save(filePrefix(prj) + ".bh.dat", arma::arma_ascii);
|
||||
result &= bv().save(filePrefix(prj) + ".bv.dat", arma::arma_ascii);
|
||||
result &= whv().save(filePrefix(dir, prj) + ".w.dat", arma::arma_ascii);
|
||||
result &= bh().save(filePrefix(dir, prj) + ".bh.dat", arma::arma_ascii);
|
||||
result &= bv().save(filePrefix(dir, prj) + ".bv.dat", arma::arma_ascii);
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -83,7 +83,6 @@ Json::Value Layer::toJson() const
|
||||
Json::Value layer;
|
||||
layer["name"] = m_name;
|
||||
layer["id"] = (int)m_id;
|
||||
layer["weights_file"] = filePrefix("") + ".weights.dat";
|
||||
layer["numVisibleX"] = (int)m_numVisibleX;
|
||||
layer["numVisibleY"] = (int)m_numVisibleY;
|
||||
layer["numHidden"] = (int)whv().n_cols;
|
||||
|
||||
+2
-2
@@ -141,14 +141,14 @@ private:
|
||||
// Compatibility
|
||||
bool loadWeights(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);
|
||||
if (prjname.size() > 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
std::cout << "Loaded " << m_trainingBatch.n_rows << " training samples\n";
|
||||
return m_trainingBatch.n_rows;
|
||||
}
|
||||
return m_trainingBatch.n_rows;
|
||||
}
|
||||
|
||||
size_t Stack::saveTrainingBatch()
|
||||
@@ -256,8 +256,9 @@ size_t Stack::saveTrainingBatch()
|
||||
if (success)
|
||||
{
|
||||
std::cout << "Saved " << m_trainingBatch.n_rows << " training samples\n";
|
||||
return m_trainingBatch.n_rows;
|
||||
}
|
||||
|
||||
return m_trainingBatch.n_rows;
|
||||
}
|
||||
|
||||
size_t Stack::numTraining()
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ int main()
|
||||
const string project("test");
|
||||
|
||||
RbmListener statusDisplay;
|
||||
Stack stack(project);
|
||||
Stack stack(".", project);
|
||||
|
||||
stack.loadTrainingBatch();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user