Discussion:
For advice on Pattern recognition
sumit
2007-03-21 21:31:20 UTC
Permalink
Hi
I used cascading training for my Simple OCR as advised by Steffen .
I am not getting bad result but not very good too .
It has some sort of affection for letter "A" . I am getting maximum error as
A instead of B,P,V,H,4.....
I also changed learning rate from default (0.7) to 0.25 ......... but no
luck .
Plz advise me for better result .............
My training data is huge some 2000 binary images (25x25)
I am writing my training code below


/*
Fast Artificial Neural Network Library (fann)
Copyright (C) 2003 Steffen Nissen (lukesky-***@public.gmane.org)

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <stdio.h>

#include "fann.h"


int main()
{
struct fann *ann;
struct fann_train_data *train_data, *test_data;
const float desired_error = (const float) 0.0000000;
unsigned int max_neurons = 10000;
unsigned int neurons_between_reports = 10;
const float learning_rate = (const float) 0.25;

printf("Reading data.\n");

train_data = fann_read_train_from_file("cascadeCapt.train");
test_data = fann_read_train_from_file("cascadeCapt.test");


printf("Creating network.\n");

ann = fann_create_shortcut(2, fann_num_input_train_data(train_data),
fann_num_output_train_data(train_data));

fann_set_training_algorithm(ann, FANN_TRAIN_RPROP);
fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_train_error_function(ann, FANN_ERRORFUNC_LINEAR);
fann_set_learning_rate(ann, learning_rate);

fann_print_parameters(ann);

printf("Training network.\n");

fann_cascadetrain_on_data(ann, train_data, max_neurons,
neurons_between_reports, desired_error);

fann_print_connections(ann);

printf("\nTrain error: %f, Test error: %f\n\n", fann_test_data(ann,
train_data),
fann_test_data(ann, test_data));

printf("Saving network.\n");

fann_save(ann, "cascadeCaptcha.net");

printf("Cleaning up.\n");
fann_destroy_train(train_data);
fann_destroy_train(test_data);
fann_destroy(ann);

return 0;
}

Regards
--
Sumit
IIT Kharagpur
Steffen Nissen
2007-03-21 22:36:30 UTC
Permalink
Hi,

Cascade usually likes to have a linear activation function for the output.

Steffen
Post by sumit
Hi
I used cascading training for my Simple OCR as advised by Steffen .
I am not getting bad result but not very good too .
It has some sort of affection for letter "A" . I am getting maximum error
as A instead of B,P,V,H,4.....
I also changed learning rate from default (0.7) to 0.25 ......... but no
luck .
Plz advise me for better result .............
My training data is huge some 2000 binary images (25x25)
I am writing my training code below
/*
Fast Artificial Neural Network Library (fann)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include "fann.h"
int main()
{
struct fann *ann;
struct fann_train_data *train_data, *test_data;
const float desired_error = (const float) 0.0000000;
unsigned int max_neurons = 10000;
unsigned int neurons_between_reports = 10;
const float learning_rate = (const float) 0.25;
printf("Reading data.\n");
train_data = fann_read_train_from_file("cascadeCapt.train");
test_data = fann_read_train_from_file(" cascadeCapt.test");
printf("Creating network.\n");
ann = fann_create_shortcut(2, fann_num_input_train_data(train_data),
fann_num_output_train_data(train_data));
fann_set_training_algorithm(ann, FANN_TRAIN_RPROP);
fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_train_error_function(ann, FANN_ERRORFUNC_LINEAR);
fann_set_learning_rate(ann, learning_rate);
fann_print_parameters(ann);
printf("Training network.\n");
fann_cascadetrain_on_data(ann, train_data, max_neurons,
neurons_between_reports, desired_error);
fann_print_connections(ann);
printf("\nTrain error: %f, Test error: %f\n\n", fann_test_data(ann,
train_data),
fann_test_data(ann, test_data));
printf("Saving network.\n");
fann_save(ann, " cascadeCaptcha.net");
printf("Cleaning up.\n");
fann_destroy_train(train_data);
fann_destroy_train(test_data);
fann_destroy(ann);
return 0;
}
Regards
--
Sumit
IIT Kharagpur
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Fann-general mailing list
https://lists.sourceforge.net/lists/listinfo/fann-general
--
Steffen Nissen - http://MySpace.com/SteffenNissen
Project Administrator - Fast Artificial Neural Network Library (fann)
http://fann.sf.net
Loading...