This is an example of how to use the netdem library.
using namespace std;
void TestClassifierTrimeshPlane() {
string root_dir = "local/examples/netdem/ann_models/trimesh_plane/";
arma::mat dataset;
bool loadedDataset =
mlpack::data::Load(root_dir + "dataset_detection.txt", dataset, true);
if (!loadedDataset) {
cout << "loading data erros ..." << endl;
return;
}
cout << "finished loading data ..." << endl;
arma::mat test_data = dataset;
int num_x{4}, num_y{1};
arma::mat test_x = test_data.rows(0, num_x - 1);
arma::mat test_y = test_data.row(num_x);
cout << "finished preparing training and testing data ..." << endl;
model.
Load(root_dir +
"ann_classifier.xml",
"detection");
cout << "finished loading ann model ..." << endl;
double test_accuracy =
arma::accu(pred_y == test_y) * 1.0 / test_y.n_elem * 100.0;
cout << "test accuracy: " << test_accuracy << " %" << endl;
arma::mat joined_yy = std::move(arma::join_cols(pred_y, test_y));
mlpack::data::Save(root_dir + "pred_vs_true_detection.txt", joined_yy, false,
true, mlpack::data::FileType::CSVASCII);
}
A class representing a general neural network.
Definition general_net.hpp:19
void Load(std::string const &filename, std::string const &label)
Loads a previously saved neural network model from a file.
Definition general_net.cpp:74
arma::mat Classify(const arma::mat &data_x)
Classifies input data based on the current neural network model.
Definition general_net.cpp:65
Definition bond_entry.hpp:7