- fixed load and save
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@628 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+28
-2
@@ -217,10 +217,9 @@ arma::mat Stack::loadTraining()
|
||||
{
|
||||
uint32_t numTraining = 0;
|
||||
uint32_t numVisible = 0;
|
||||
FILE *pFile;
|
||||
|
||||
std::string filename = m_name + ".training.dat";
|
||||
pFile = fopen(filename.c_str(), "r");
|
||||
FILE *pFile = fopen(filename.c_str(), "r");
|
||||
|
||||
if (!pFile)
|
||||
{
|
||||
@@ -257,6 +256,33 @@ arma::mat Stack::loadTraining()
|
||||
return data;
|
||||
}
|
||||
|
||||
void Stack::saveTraining(const arma::mat& batch)
|
||||
{
|
||||
std::string filename = m_name + ".training.dat";
|
||||
FILE *pFile = fopen(filename.c_str(), "w");
|
||||
|
||||
if (!pFile)
|
||||
{
|
||||
std::cout << "Could not open " << filename << "!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(pFile, "%u\n", (uint32_t)batch.n_rows);
|
||||
fprintf(pFile, "%u\n", (uint32_t)batch.n_cols);
|
||||
|
||||
uint32_t i, j;
|
||||
|
||||
for (i=0; i < batch.n_rows; i++)
|
||||
{
|
||||
for (j=0; j < batch.n_cols; j++)
|
||||
{
|
||||
fprintf(pFile, "%3.6f\n", batch(i, j));
|
||||
}
|
||||
}
|
||||
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
size_t Stack::numTraining(const arma::mat &batch)
|
||||
{
|
||||
return batch.n_rows;
|
||||
|
||||
Reference in New Issue
Block a user