Skip to content
Snippets Groups Projects
Commit 35341ccf authored by Franck Dary's avatar Franck Dary
Browse files

Added a way to ensure neural network shape is not changing during decoding

parent 4ccc8d2f
Branches
Tags
No related merge requests found
......@@ -211,7 +211,6 @@ void train_nn(context * ctx)
classifier_print_desc_file(classif->filename, classif);
classifier_delete_mlp(classif);
//classifier_init_mlp(classif, new Mlp(classif->mlp_model_filename, classif->mlp_struct_filename, ctx->maca_data_path));
}
}
......
......@@ -69,7 +69,6 @@ class Mlp{
Mlp(std::vector<Layer> layers, unsigned int batch_size = 0);
Mlp(char * model_filename, char * struct_filename, char * absolute_path);
unsigned int predict(int * features, int nb_features);
unsigned int predict(float * features, int nb_features);
void train(int nb_iter_max, Fann_file & fann_train, Fann_file & fann_dev,
std::function<void(std::vector< std::vector<float> >&,
......
......@@ -162,21 +162,19 @@ unsigned int Mlp::predict(dynet::Expression x){
return argmax;
}
unsigned int Mlp::predict(int * features, int nb_features){
unsigned int Mlp::predict(float * features, int nb_features){
computation_graph.clear();
unsigned int nb_inputs = layers[0].input_dim;
std::vector<float> features_vector(features, features + nb_features);
dynet::Expression x = input(computation_graph, {nb_inputs}, features_vector);
return predict(x);
if(features_vector.size() != nb_inputs)
{
fprintf(stderr, "ERROR (%s) : example size=%lu nb_inputs=%u mismatch\n",
__func__, features_vector.size(), nb_inputs);
exit(1);
}
unsigned int Mlp::predict(float * features, int nb_features){
computation_graph.clear();
unsigned int nb_inputs = layers[0].input_dim;
std::vector<float> features_vector(features, features + nb_features);
dynet::Expression x = input(computation_graph, {nb_inputs}, features_vector);
return predict(x);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment