定制 coral-media/ext-fann 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

coral-media/ext-fann

最新稳定版本:v1.0.0

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-dev required (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

Execution and Basic Training

Training Data I/O and Dataset Utilities

Training Metrics and Error Handling

Training Algorithm and Hyperparameters

Activation Functions and Steepness

Network Introspection, Topology, and Weights

Input/Output Scaling (Runtime + Parameter Setup)

Cascade Training Controls

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

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: C

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固