coral-media/ext-fann
Composer 安装命令:
pie install coral-media/ext-fann
包简介
FANN (Fast Artificial Neural Network) bindings for PHP
README 文档
README
coral-media/ext-fann is a PHP extension that wraps the Fast Artificial Neural Network (FANN) C library using vendored sources (lib/libfann).
Requirements
- PHP
>= 8.1 - A C toolchain (
phpize,make, compiler) - No system
libfann-devrequired (vendored build)
Install (PIE)
From the extension root:
pie install --with-fann
Build From Source (manual)
phpize ./configure --with-fann make -j"$(nproc)" make test
The extension module will be built as fann.
Minimal Example
<?php $ann = fann_create_standard(3, 2, 3, 1); fann_set_training_algorithm($ann, FANN_TRAIN_INCREMENTAL); fann_set_learning_rate($ann, 0.7); fann_set_activation_function_hidden($ann, FANN_SIGMOID_SYMMETRIC); fann_set_activation_function_output($ann, FANN_SIGMOID_SYMMETRIC); for ($epoch = 0; $epoch < 200; $epoch++) { fann_train($ann, [0.0, 0.0], [0.0]); fann_train($ann, [0.0, 1.0], [1.0]); fann_train($ann, [1.0, 0.0], [1.0]); fann_train($ann, [1.0, 1.0], [0.0]); } $out = fann_run($ann, [0.0, 1.0]); var_dump($out); fann_destroy($ann);
Tests
Run all PHPT tests:
make test
API Coverage
Implemented functions are grouped below.
Full API reference: docs/api/index.md.
Network Creation, Persistence, and Lifecycle
fann_create_standard,fann_create_standard_arrayfann_create_sparse,fann_create_sparse_arrayfann_create_shortcut,fann_create_shortcut_arrayfann_create_from_file,fann_copy,fann_destroyfann_save,fann_save_to_fixedfann_print_parameters,fann_print_connections
Execution and Basic Training
fann_run,fann_testfann_train,fann_train_on_data,fann_train_on_filefann_train_epoch,fann_test_datafann_cascadetrain_on_data,fann_cascadetrain_on_file
Training Data I/O and Dataset Utilities
fann_create_train,fann_read_train_from_filefann_save_train,fann_save_train_to_fixedfann_destroy_trainfann_shuffle_train_datafann_scale_input_train_data,fann_scale_output_train_data,fann_scale_train_datafann_merge_train_data,fann_duplicate_train_data,fann_subset_train_datafann_length_train_data,fann_num_input_train_data,fann_num_output_train_data
Training Metrics and Error Handling
fann_get_MSE,fann_reset_MSE,fann_get_bit_failfann_get_errno,fann_reset_errno,fann_reset_errstrfann_get_errstr,fann_print_error,fann_set_error_log
Training Algorithm and Hyperparameters
fann_set_training_algorithm,fann_get_training_algorithmfann_set_learning_rate,fann_get_learning_ratefann_set_learning_momentum,fann_get_learning_momentumfann_set_train_error_function,fann_get_train_error_functionfann_set_train_stop_function,fann_get_train_stop_functionfann_set_bit_fail_limit,fann_get_bit_fail_limitfann_set_quickprop_decay,fann_get_quickprop_decayfann_set_quickprop_mu,fann_get_quickprop_mufann_set_rprop_increase_factor,fann_get_rprop_increase_factorfann_set_rprop_decrease_factor,fann_get_rprop_decrease_factorfann_set_rprop_delta_min,fann_get_rprop_delta_minfann_set_rprop_delta_max,fann_get_rprop_delta_maxfann_set_rprop_delta_zero,fann_get_rprop_delta_zerofann_set_sarprop_weight_decay_shift,fann_get_sarprop_weight_decay_shiftfann_set_sarprop_step_error_threshold_factor,fann_get_sarprop_step_error_threshold_factorfann_set_sarprop_step_error_shift,fann_get_sarprop_step_error_shiftfann_set_sarprop_temperature,fann_get_sarprop_temperature
Activation Functions and Steepness
fann_set_activation_function_hidden,fann_set_activation_function_outputfann_set_activation_function,fann_set_activation_function_layerfann_get_activation_functionfann_set_activation_steepness,fann_set_activation_steepness_layerfann_set_activation_steepness_hidden,fann_set_activation_steepness_outputfann_get_activation_steepness
Network Introspection, Topology, and Weights
fann_get_num_input,fann_get_num_output,fann_get_num_layersfann_get_total_neurons,fann_get_total_connectionsfann_get_network_type,fann_get_connection_ratefann_get_layer_array,fann_get_bias_array,fann_get_connection_arrayfann_set_weight_array,fann_set_weightfann_randomize_weights,fann_init_weights
Input/Output Scaling (Runtime + Parameter Setup)
fann_set_input_scaling_params,fann_set_output_scaling_params,fann_set_scaling_paramsfann_clear_scaling_paramsfann_scale_train,fann_descale_trainfann_scale_input,fann_scale_output,fann_descale_input,fann_descale_output
Cascade Training Controls
fann_get_cascade_output_change_fraction,fann_set_cascade_output_change_fractionfann_get_cascade_output_stagnation_epochs,fann_set_cascade_output_stagnation_epochsfann_get_cascade_candidate_change_fraction,fann_set_cascade_candidate_change_fractionfann_get_cascade_candidate_stagnation_epochs,fann_set_cascade_candidate_stagnation_epochsfann_get_cascade_weight_multiplier,fann_set_cascade_weight_multiplierfann_get_cascade_candidate_limit,fann_set_cascade_candidate_limitfann_get_cascade_max_out_epochs,fann_set_cascade_max_out_epochsfann_get_cascade_min_out_epochs,fann_set_cascade_min_out_epochsfann_get_cascade_max_cand_epochs,fann_set_cascade_max_cand_epochsfann_get_cascade_min_cand_epochs,fann_set_cascade_min_cand_epochsfann_get_cascade_num_candidatesfann_get_cascade_activation_functions_count,fann_get_cascade_activation_functions,fann_set_cascade_activation_functionsfann_get_cascade_activation_steepnesses_count,fann_get_cascade_activation_steepnesses,fann_set_cascade_activation_steepnessesfann_get_cascade_num_candidate_groups,fann_set_cascade_num_candidate_groups
Constants
- Full exposure of currently registered
FANN_*constants (training algorithms, activation functions, stop/error functions, net types, and error codes).
Vendored Dependency
- FANN source is vendored under
lib/libfann - License file:
lib/libfann/COPYING.txt
coral-media/ext-fann 适用场景与选型建议
coral-media/ext-fann 是一款 基于 C 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「machine-learning」 「neural-network」 「fann」 「php-ext」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 coral-media/ext-fann 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 coral-media/ext-fann 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 coral-media/ext-fann 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple PHP client for Qdrant vector database. Easy-to-use library for storing, searching, and managing vector embeddings in AI and machine learning applications.
#1 PHP client for the Replicate API, compatible with Laravel and native PHP, built on Saloon v4
🚀 GigaChat PHP SDK - полнофункциональная библиотека для интеграции с Sber GigaChat API. Простое подключение GigaChat к PHP-приложениям с поддержкой Laravel. Генерация текста, чат-боты, AI-ассистенты. Полная документация, примеры кода, OAuth авторизация.
PHP-ML Machine Learning library for PHP
Laravel integration for Instructor PHP - Structured LLM outputs made simple
A dead simple neural network. For educational purposes only.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 41
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-14