/** * Train ANN incrementally * @param array input vector * @param array output vector * @return bool true on success, false on error */ public function train(array $input_vector, array $output_vector) { $this->checkIfAnnIsAssigned(); return fann_train($this->annId, $input_vector, $output_vector); }
* long fann_get_total_connections(resource ann) * * If you have any questions or comments, please e-mail Evan Nemerson * <*****@*****.**> */ /* If you don't want to compile FANN into PHP... */ if (!extension_loaded('fann')) { if (!dl('fann.so')) { exit("You must install the FANN extension. You can get it from http://fann.sf.net/\n"); } } /* Create an artificial neural network */ $ann = fann_create(array(2, 4, 1), 1.0, 0.7); /* To load from a file, you can use. If your version of PHP includes the streams API (4.3.0+ ?), * this can be anything accessible through streams (http, ftp, https, etc) */ // $ann = fann_create("http://example.com/xor_float.net"); /* Train the network using the same data as is in the xor.data file */ fann_train($ann, array(array(array(0, 0), array(0)), array(array(0, 1), array(1)), array(array(1, 0), array(1)), array(array(1, 1), array(0))), 100000, 1.0E-5, 1000); /* To achieve the same effect as the above with the data stored in an external file... Also works * with the streams API, when available. */ // fann_train($ann, '/home/tadpole/local/src/fann/examples/xor.data', 100000, 0.00001, 1000); print_r(fann_run($ann, array(0, 0))); // Should be ~ 0 print_r(fann_run($ann, array(0, 1))); // Should be ~ 1 print_r(fann_run($ann, array(1, 0))); // Should be ~ 1 print_r(fann_run($ann, array(1, 1))); // Should be ~ 0 /* This function is pretty simple. It will use the streams API if available. */ fann_save($ann, 'xor_float.net');