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 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 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 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 input_format=-F 0
SET ntest=-e 2007 SET ntest=-e 2007
REM SET batch_size=-b 1024 REM SET batch_size=-b 1024

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

@ -13,7 +13,7 @@ SET predefined_model=-P 0
SET problem_format=-C 1 SET problem_format=-C 1
SET train_file=-I usps10/train.txt SET train_file=-I usps10/train.txt
SET validation_file=-V usps10/test.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 SET input_format=-F 0
REM ######################################################## REM ########################################################

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

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

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

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