Adding i/o code for protonn outputs

This commit is contained in:
Suresh Parthasarathy 2017-11-21 10:30:20 +05:30
Родитель 6b4beadd01
Коммит fbc316b25b
4 изменённых файлов: 64 добавлений и 12 удалений

Просмотреть файл

@ -9,7 +9,7 @@ REM # Have a look at README.md and README_PROTONN_OSS.md for details on how to s
SET test_file=-I usps10/test.txt
SET model_file=-M usps10/ProtoNNResults/ProtoNNTrainer_pd_15_protPerClass_0_prot_200_spW_1.000000_spZ_1.000000_spB_1.000000_gammaNumer_1.000000_normal_3_seed_42_bs_1024_it_20_ep_20/model
SET normalization_file=-n usps10/ProtoNNResults/ProtoNNTrainer_pd_15_protPerClass_0_prot_200_spW_1.000000_spZ_1.000000_spB_1.000000_gammaNumer_1.000000_normal_3_seed_42_bs_1024_it_20_ep_20/minMaxParams
SET output_dir=-O usps10/ProtoNNResults
SET output_dir=-O usps10\ProtoNNResults
SET input_format=-F 0
SET ntest=-e 2007
REM SET batch_size=-b 1024

Просмотреть файл

@ -13,7 +13,7 @@ SET predefined_model=-P 0
SET problem_format=-C 1
SET train_file=-I usps10/train.txt
SET validation_file=-V usps10/test.txt
SET output_dir=-O usps10/ProtoNNResults
SET output_dir=-O usps10\ProtoNNResults
SET input_format=-F 0
REM ########################################################

Просмотреть файл

@ -57,7 +57,7 @@ ProtoNNPredictor::ProtoNNPredictor(
testData.loadDataFromFile(dataformatType,
trainFile,
validationFile,
testFile);
testFile);
testData.finalizeData();
normalize();
@ -120,7 +120,14 @@ ProtoNNPredictor::ProtoNNPredictor(
void ProtoNNPredictor::createOutputDirs()
{
std::string subdirName = model.hyperParams.subdirName();
#ifdef LINUX
outDir = outDir + "/ProtoNNPredictor_" + subdirName;
#endif
#ifdef WINDOWS
outDir = outDir + "\\ProtoNNPredictor_" + subdirName;
#endif
try {
std::string testcommand = "test -d " + outDir;
@ -134,29 +141,48 @@ void ProtoNNPredictor::createOutputDirs()
LOG_WARNING("Error in creating directory at this location: " + outDir);
#endif
#ifdef WINDOWS
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + " (Directory might already exist)");
#endif
#ifdef DUMP
#ifdef LINUX
testcommand = "test -d " + outDir + "/dump";
command = "mkdir " + outDir + "/dump";
#ifdef LINUX
if (system(testcommand.c_str()) == 0)
LOG_INFO("Directory " + outDir + "/dump already exists.");
else
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + "/dump");
#endif
#ifdef WINDOWS
command = "mkdir " + outDir + "\\dump";
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + "\dump" + " (Directory might already exist)");
#endif
#endif
#ifdef VERIFY
#ifdef LINUX
testcommand = "test -d " + outDir + "/verify";
command = "mkdir " + outDir + "/verify";
#ifdef LINUX
if (system(testcommand.c_str()) == 0)
LOG_INFO("Directory " + outDir + "/verify already exists.");
else
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + "/verify");
#endif
#ifdef WINDOWS
command = "mkdir " + outDir + "\\verify";
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + "\verify" + " (Directory might already exist)");
#endif
}
#endif
}
catch (...) {
LOG_WARNING("Error in creating one of the subdirectories. Some of the output may not be recorded.");
}
@ -444,10 +470,10 @@ EdgeML::ResultStruct ProtoNNPredictor::testPointWise()
EdgeML::ResultStruct res, tempRes;
for (dataCount_t i = 0; i < n; ++i) {
scoreSparseDataPoint(scores,
(const FP_TYPE*) testData.Xtest.valuePtr() + testData.Xtest.outerIndexPtr()[i],
(const featureCount_t*) testData.Xtest.innerIndexPtr() + testData.Xtest.outerIndexPtr()[i],
(featureCount_t) testData.Xtest.outerIndexPtr()[i + 1] - testData.Xtest.outerIndexPtr()[i]);
scoreSparseDataPoint(scores,
(const FP_TYPE*) testData.Xtest.valuePtr() + testData.Xtest.outerIndexPtr()[i],
(const featureCount_t*) testData.Xtest.innerIndexPtr() + testData.Xtest.outerIndexPtr()[i],
(featureCount_t) testData.Xtest.outerIndexPtr()[i + 1] - testData.Xtest.outerIndexPtr()[i]);
tempRes = evaluate(Yscores, testData.Ytest.middleCols(i, 1), model.hyperParams.problemType);
res.scaleAndAdd(tempRes, 1);

Просмотреть файл

@ -53,7 +53,14 @@ ProtoNNTrainer::ProtoNNTrainer(
void ProtoNNTrainer::createOutputDirs()
{
std::string subdirName = model.hyperParams.subdirName();
#ifdef LINUX
outDir = outDir + "/ProtoNNTrainer_" + subdirName;
#endif
#ifdef WINDOWS
outDir = outDir + "\\ProtoNNTrainer_" + subdirName;
#endif
try {
std::string testcommand = "test -d " + outDir;
@ -67,27 +74,46 @@ void ProtoNNTrainer::createOutputDirs()
LOG_WARNING("Error in creating directory at this location: " + outDir);
#endif
#ifdef WINDOWS
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + " (Directory might already exist)");
#endif
#ifdef DUMP
#ifdef LINUX
testcommand = "test -d " + outDir + "/dump";
command = "mkdir " + outDir + "/dump";
#ifdef LINUX
if (system(testcommand.c_str()) == 0)
LOG_INFO("Directory " + outDir + "/dump already exists.");
else
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + "/dump");
#endif
#ifdef WINDOWS
command = "mkdir " + outDir + "\\dump";
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + "\dump" + " (Directory might already exist)");
#endif
#endif
#ifdef VERIFY
#ifdef LINUX
testcommand = "test -d " + outDir + "/verify";
command = "mkdir " + outDir + "/verify";
#ifdef LINUX
if (system(testcommand.c_str()) == 0)
LOG_INFO("Directory " + outDir + "/verify already exists.");
else
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + "/verify");
#endif
#ifdef WINDOWS
command = "mkdir " + outDir + "\\verify";
if (system(command.c_str()) != 0)
LOG_WARNING("Error in creating directory at this location: " + outDir + "\verify" + " (Directory might already exist)");
#endif
#endif
}
catch (...) {