{"id":15022092,"url":"https://github.com/php/pecl-tools-fann","last_synced_at":"2025-10-19T22:31:48.089Z","repository":{"id":9773903,"uuid":"11745175","full_name":"php/pecl-tools-fann","owner":"php","description":"PECL fann - Artificial neural networks","archived":false,"fork":false,"pushed_at":"2014-01-01T17:39:01.000Z","size":344,"stargazers_count":6,"open_issues_count":0,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-29T21:25:34.656Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pecl.php.net/package/fann","language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-29T17:20:10.000Z","updated_at":"2022-11-21T03:20:54.000Z","dependencies_parsed_at":"2022-07-12T15:03:50.790Z","dependency_job_id":null,"html_url":"https://github.com/php/pecl-tools-fann","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-tools-fann","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-tools-fann/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-tools-fann/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-tools-fann/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php","download_url":"https://codeload.github.com/php/pecl-tools-fann/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237224776,"owners_count":19275085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T19:57:26.896Z","updated_at":"2025-10-19T22:31:42.745Z","avatar_url":"https://github.com/php.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP FANN wrapper\n\nThis is a PHP wrapper for [FANN (Fast Artificial Neural Network) library](http://leenissen.dk/fann/wp/).\n\n## API\n\nThe API is documented on http://www.php.net/manual/en/book.fann.php where is the complete documentation for PHP FANN.\n\nThe API is very similar to the official [FANN C API](http://leenissen.dk/fann/html/files/fann-h.html). Just functions for fixed `fann_type` have not been mapped because PHP always support `float`. In addition unnecessary arguments for some functions have been left out (for example array length that is not necessary for PHP arrays).\n\n## Installation\n\nThe extension can be installed on Linux and Windows.\n\n### Linux\n\nBefore you start installation make sure that `libfann` is installed on your system. It's part of the main repository in the most Linux distributions (search for `fann`). If not you need to install it first. Either download it from the [official site](http://leenissen.dk/fann/wp/) or get it from your distro repository. For example on Ubuntu:\n```\n$ sudo apt-get install libfann-dev\n```\nFann installation can be skipped if an RPM for Fedora is used (`libfann` is in the package dependencies).\n\n#### Fedora\n\nThe RPM package for PHP FANN is available in Remi's repository: http://rpms.famillecollet.com/\n\nIt is available only for Fedora. RHEL and clones (CentOS, SC and others) are not available as `libfann` is not available in EPEL.\n\nAfter downloading remi-release RPM, the package can be installed by executing following command:\n```\n$ sudo yum --enablerepo=remi install php-pecl-fann\n```\n\n#### PECL\n\nThis extension is available on PECL. The installation is very simple. Just run:\n\n```\n$ sudo pecl install fann\n```\n\n#### Manual Installation\n\nFirst download the source\n```\ngit clone https://github.com/bukka/php-fann.git\n```\n\nThen go to the created source directory and compile the extension. You need to have a php development package installed (command `phpize` must be available).\n```\ncd php-fann\nphpize\n./configure --with-fann\nmake\nsudo make install\n```\n\nFinally you need to add\n```\nextension=fann.so\n```\nto the php.ini\n\n### Windows\n\nPrecompiled binary `dll` libraries for php-fann and libfann are available on [the official Windows download site for PECL packages](http://windows.php.net/downloads/pecl/releases/fann/). The compiled version of libfann is 2.2.\n\n## Examples\n\nThese are just two basic examples for simple training and running supplied data on the trained network.\n\n### `simple_train.php`\n\n```php\n$num_input = 2;\n$num_output = 1;\n$num_layers = 3;\n$num_neurons_hidden = 3;\n$desired_error = 0.001;\n$max_epochs = 500000;\n$epochs_between_reports = 1000;\n\n$ann = fann_create_standard($num_layers, $num_input, $num_neurons_hidden, $num_output);\n\nif ($ann) {\n    fann_set_activation_function_hidden($ann, FANN_SIGMOID_SYMMETRIC);\n    fann_set_activation_function_output($ann, FANN_SIGMOID_SYMMETRIC);\n\n    $filename = dirname(__FILE__) . \"/xor.data\";\n    if (fann_train_on_file($ann, $filename, $max_epochs, $epochs_between_reports, $desired_error))\n        fann_save($ann, dirname(__FILE__) . \"/xor_float.net\");\n\n    fann_destroy($ann);\n}\n```\n### `simple_test.php`\n\n```php\n$train_file = (dirname(__FILE__) . \"/xor_float.net\");\nif (!is_file($train_file))\n    die(\"The file xor_float.net has not been created! Please run simple_train.php to generate it\");\n\n$ann = fann_create_from_file($train_file);\nif (!$ann)\n\tdie(\"ANN could not be created\");\n\n$input = array(-1, 1);\n$calc_out = fann_run($ann, $input);\nprintf(\"xor test (%f,%f) -\u003e %f\\n\", $input[0], $input[1], $calc_out[0]);\nfann_destroy($ann);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp%2Fpecl-tools-fann","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp%2Fpecl-tools-fann","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp%2Fpecl-tools-fann/lists"}