-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with fann_set_callback #30
Comments
Looks like |
As I said, I've just added one line to your test script, so: function ann_callback( $ann, $train_data, $max_epochs, $epochs_between_reports, $desired_error, $epochs ) {
var_dump($ann);
var_dump($train_data);
var_dump($max_epochs);
var_dump($epochs_between_reports);
var_dump($desired_error);
var_dump($epochs);
}
$num_input = 2;
$num_output = 1;
$num_layers = 3;
$num_neurons_hidden = 3;
$desired_error = 0.001;
$max_epochs = 50000;
$epochs_between_reports = 1000;
$ann = fann_create_standard($num_layers, $num_input, $num_neurons_hidden, $num_output);
fann_set_callback($ann, 'ann_callback');
$filename = ( dirname( __FILE__ ) . "/fann_set_callback.tmp" );
$content = <<<EOF
4 2 1
-1 -1
-1
-1 1
1
1 -1
1
1 1
-1
EOF;
file_put_contents( $filename, $content );
$train_data = fann_read_train_from_file( $filename );
fann_train_on_data( $ann, $train_data, $max_epochs, $epochs_between_reports, $desired_error );
fann_save($ann, dirname( __FILE__ ) . "/fann_result.net"); |
Fix:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
I'm trying to use fann_set_callback based on your test:
https://github.com/bukka/php-fann/blob/master/tests/fann_set_callback_basic.phpt
When I run it, callback function is called only once. And if I try to save result to file in the end of the test I get error. So I added:
fann_save($ann, dirname( __FILE__ ) . "/fann_result.net");
and get:
PHP Warning: fann_save() expects parameter 1 to be resource, null given in fann_callback_test.php on line 40
Indeed, $ann is null. Without setting callback everything is fine. Any ideas?
Thanks, Alex.
The text was updated successfully, but these errors were encountered: