Add a new option to add a labels file and a means file.

This commit is contained in:
2017-10-09 13:00:26 +02:00
parent 1e901507fa
commit e70c5f22ce
5 changed files with 92 additions and 34 deletions

View File

@@ -10,14 +10,14 @@ using namespace std;
static void show_help(const char *progname, int exitcode) {
cerr << "Usage: " << progname << " -m MODEL -w WEIGHTS INPUTS..." << endl
<< endl
<< R"END(
Simulate the specified network on the specified inputs.
<< R"END(Simulate the specified network on the specified inputs.
Options:
-h show this message
-m (required) the model file to simulate
-n (required) the model file to simulate
-w (required) the trained weights
)END" << endl;
-m means file. Will be substracted from input if available.
-l labels file. Will be used to print prediction labels if available.)END" << endl;
exit(exitcode);
}
@@ -32,10 +32,12 @@ static void check_file(const char *filename) {
Options Options::parse(const int argc, char *const argv[]) {
string model;
string weights;
string means;
string labels;
char c;
while ((c = getopt(argc, argv, "hm:w:")) != -1) {
while ((c = getopt(argc, argv, "hm:w:n:l:")) != -1) {
switch (c) {
case 'h':
show_help(argv[0], 0);
@@ -46,16 +48,27 @@ Options Options::parse(const int argc, char *const argv[]) {
weights = optarg;
break;
case 'm':
case 'n':
check_file(optarg);
model = optarg;
break;
case 'm':
check_file(optarg);
means = optarg;
break;
case 'l':
check_file(optarg);
labels = optarg;
break;
case '?':
show_help(argv[0], 1);
break;
default:
cerr << "Unhandled option: " << c << endl;
abort();
}
}
@@ -78,23 +91,36 @@ Options Options::parse(const int argc, char *const argv[]) {
show_help(argv[0], 1);
}
return Options(move(model), move(weights), move(inputs));
return Options(move(model), move(weights), move(means), move(labels), move(inputs));
}
Options::Options(string &&model, string &&weights, vector<string> &&inputs) noexcept:
Options::Options(string &&model, string &&weights, string&& means, string&& labels, vector<string> &&inputs) noexcept:
modelPath(move(model)),
weightsPath(move(weights)),
inputPaths(move(inputs)) {
meansPath(means),
labelsPath(labels),
inputPaths(move(inputs))
{
}
const string &Options::model() const {
const string& Options::model() const {
return modelPath;
}
const string &Options::weights() const {
const string& Options::weights() const {
return weightsPath;
}
const vector<string> &Options::inputs() const {
const vector<string>& Options::inputs() const {
return inputPaths;
}
const string& Options::means() const
{
return meansPath;
}
const string& Options::labels() const
{
return labelsPath;
}