PHPackages                             a1essandro/neural-network - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. a1essandro/neural-network

ActiveLibrary

a1essandro/neural-network
=========================

Artificial neural network

v0.1.2(9y ago)10844MITPHPPHP &gt;=5.5.0

Since Aug 4Pushed 8y ago2 watchersCompare

[ Source](https://github.com/A1essandro/neural-network)[ Packagist](https://packagist.org/packages/a1essandro/neural-network)[ RSS](/packages/a1essandro-neural-network/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

neural-network
==============

[](#neural-network)

[![Build Status](https://camo.githubusercontent.com/0f45adf499fbb2e3cf34bb329f30c1d4a6d91fea496d2d70796785ca75fb2fd3/68747470733a2f2f7472617669732d63692e6f72672f4131657373616e64726f2f6e657572616c2d6e6574776f726b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/A1essandro/neural-network)[![Coverage Status](https://camo.githubusercontent.com/7c1bb3477b52a9e7d0377544e2c6df8d23149b302b097c999b8a0ade6a3b5710/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4131657373616e64726f2f6e657572616c2d6e6574776f726b2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/A1essandro/neural-network?branch=master)[![Code Climate](https://camo.githubusercontent.com/deaf272111627307ac17ccca98a5f3e0eee1e322b7a5d77f6e4293a3e5f4eb91/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f4131657373616e64726f2f6e657572616c2d6e6574776f726b2f6261646765732f6770612e737667)](https://codeclimate.com/github/A1essandro/neural-network)[![Latest Stable Version](https://camo.githubusercontent.com/5482a5a18a75f1f95e59203d1b9ea79615da1fb5fb6677fa6f86cbbf18ce5a3d/68747470733a2f2f706f7365722e707567782e6f72672f6131657373616e64726f2f6e657572616c2d6e6574776f726b2f762f737461626c65)](https://packagist.org/packages/a1essandro/neural-network)[![Latest Unstable Version](https://camo.githubusercontent.com/5548fe0992424f7df5ea5d5666536a56f0adb3c3ea10a4b2ef3dc1f5bc63878f/68747470733a2f2f706f7365722e707567782e6f72672f6131657373616e64726f2f6e657572616c2d6e6574776f726b2f762f756e737461626c65)](https://packagist.org/packages/a1essandro/neural-network)[![Total Downloads](https://camo.githubusercontent.com/002a227a0a4fa6e8866201daee221d418de786f14b4f5c2fee283cbda8e5f9d8/68747470733a2f2f706f7365722e707567782e6f72672f6131657373616e64726f2f6e657572616c2d6e6574776f726b2f646f776e6c6f616473)](https://packagist.org/packages/a1essandro/neural-network)[![License](https://camo.githubusercontent.com/feeb5773d6270ec790138ab935bd5e7d522358fd6bc53df5c759bf45d498a602/68747470733a2f2f706f7365722e707567782e6f72672f6131657373616e64726f2f6e657572616c2d6e6574776f726b2f6c6963656e7365)](https://github.com/A1essandro/neural-network/blob/master/LICENSE)

###### Language choice:

[](#language-choice)

[![English](https://camo.githubusercontent.com/5078c572bdac28c2d978577aaa4c4905e44f3007257dd71b2e14f516695a8e25/68747470733a2f2f696d672e736869656c64732e696f2f3a726561646d652d454e2d3333363639392e737667)](https://github.com/A1essandro/neural-network/blob/master/README.md)[![Russian](https://camo.githubusercontent.com/465b8cab638cbf7a9b45440e3226239d1a49d1428d9125409ae3f5550c6ec4ca/68747470733a2f2f696d672e736869656c64732e696f2f3a726561646d652d52552d6363333330302e737667)](https://github.com/A1essandro/neural-network/blob/master/README.ru.md)

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage examples](#usage)
    - [XOR example](#xor-example)
    - [Manually configuration](#manually-configuration-of-network)
- [Specification](#specification)
    - [Network](#network)
    - [Layers](#layers)
    - [Nodes](#nodes)
    - [Synapses](#synapses)
- [Contribute](#contribute)
- [License](#license)

Requirements
------------

[](#requirements)

This package is only supported on PHP 5.5 and above.

Installation
------------

[](#installation)

#### Method #1(recommended): Composer package

[](#method-1recommended-composer-package)

See more [getcomposer.org](http://getcomposer.org).

Execute command

```
composer require a1essandro/neural-network ^0.1.0

```

Or add line to `composer.json`

```
"require": {
    ...
    "require a1essandro/neural-network": "^0.1.0"
},

```

#### Method #2: Clone repository

[](#method-2-clone-repository)

Execute command

```
git clone https://github.com/A1essandro/neural-network

```

Usage
-----

[](#usage)

### Common

[](#common)

#### XOR example:

[](#xor-example)

```
use Neural\BackpropagationTeacher;
use Neural\MultilayerPerceptron;

require_once '../vendor/autoload.php';

//Creation neural network, with 2 input-neurons, one hidden layer with 2 neurons and one output neuron:
$p = new MultilayerPerceptron([2, 2, 1]); //You may add more hidden layers or neurons to layers: [2, 3, 2, 1]
$p->generateSynapses(); //automatically add synapses

$t = new BackpropagationTeacher($p); //Teacher with backpropagation algorithm

//Teach until it learns
$learningResult = $t->teachKit(
    [[1, 0], [0, 1], [1, 1], [0, 0]], //kit for learning
    [[1], [1], [0], [0]], //appropriate expectations
    0.3, //error
    10000 //max iterations
);

if ($learningResult != -1) {
    echo '1,0: ' . round($p->input([1, 0])->output()[0]) . PHP_EOL;
    echo '0,1: ' . round($p->input([0, 1])->output()[0]) . PHP_EOL;
    echo '0,0: ' . round($p->input([0, 0])->output()[0]) . PHP_EOL;
    echo '1,1: ' . round($p->input([1, 1])->output()[0]) . PHP_EOL;
}

/* Result:
1,0: 1
0,1: 1
0,0: 0
1,1: 0
*/
```

#### Manually configuration of network

[](#manually-configuration-of-network)

```
$p = new MultilayerPerceptron([2, 2, 1]);

//Equivalent to:

$p = new MultilayerPerceptron();
$p->addLayer(new Layer())->toLastLayer()
    ->addNode(new Input())
    ->addNode(new Input())
    ->addNode(new Bias());
$p->addLayer(new Layer())->toLastLayer()
    ->addNode(new Neuron())
    ->addNode(new Neuron())
    ->addNode(new Bias());
$p->addLayer(new Layer())->toLastLayer()
    ->addNode(new Neuron());

//Do not forget to add synapses:

$p->generateSynapses();

//Or you may direct the process:

$neuronFilter = function($node) {
    return $node instanceof Neuron;
};

$secondLayerNeuron = iterator_to_array($p->getLayers()[1]->getNodes($neuronFilter))[0];
$input = iterator_to_array($p->getLayers()[0]->getNodes())[0];
$secondLayerNeuron->addSynapse(new Synapse($input));

//and so on...
```

Specification
-------------

[](#specification)

#### Network

[](#network)

Interface implementation of `INetwork` is a container comprising nodes (`INode`) interconnected by synapses (`Synapse`).

#### Layers

[](#layers)

Interface implementations of `ILayer` are formal groups of `INode` in a `LayeredNetwork`.

#### Nodes

[](#nodes)

`INode` - neurons, input-neurons etc.

#### Synapses

[](#synapses)

`Synapse` - is a connection between two nodes (`INode`). Synapse gets output (call `output()`) of neuron-transmitter and convert the value via its weight. Result value gets neuron-reciever (it call `output()` of `ISynapse`).

Contribute
----------

[](#contribute)

Contributions to the package are always welcome!

License
-------

[](#license)

The code base is licensed under the MIT license.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~82 days

Total

3

Last Release

3405d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f54bc66315e4f47b9b435c908356a913db282dd15994a049ac37e217703fdf3b?d=identicon)[A1essandro](/maintainers/A1essandro)

---

Top Contributors

[![A1essandro](https://avatars.githubusercontent.com/u/4727083?v=4)](https://github.com/A1essandro "A1essandro (47 commits)")

---

Tags

kohonenmlpneural-networkperceptron

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/a1essandro-neural-network/health.svg)

```
[![Health](https://phpackages.com/badges/a1essandro-neural-network/health.svg)](https://phpackages.com/packages/a1essandro-neural-network)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
