PHPackages                             synaptic-net/lab - 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. synaptic-net/lab

ActiveLibrary

synaptic-net/lab
================

A lightweight PHP library for building and training neural networks from scratch, featuring customizable neurons, activation functions, and backpropagation support.

v1.0.0(7mo ago)12MITPHPPHP &gt;=8.0

Since Oct 19Pushed 7mo agoCompare

[ Source](https://github.com/duvanCode/synaptic_net)[ Packagist](https://packagist.org/packages/synaptic-net/lab)[ RSS](/packages/synaptic-net-lab/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Synaptic Net
============

[](#synaptic-net)

**Synaptic Net** is a lightweight PHP library for building and training simple neural networks from scratch.
It’s designed for learning and experimenting with how neurons, layers, activation functions, and backpropagation interact internally — without relying on any external machine learning frameworks.

---

Features
--------

[](#features)

- Customizable neuron and layer classes
- Backpropagation training process implemented from scratch
- Multiple activation functions (Sigmoid, ReLU, etc.)
- Supports multilayer perceptrons (MLP)
- Educational and fully readable code structure

---

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

[](#installation)

```
composer require synaptic-net/lab
```

---

Basic Example
-------------

[](#basic-example)

Below is a simple example of how to create and train a multilayer neural network using **Synaptic Net** to learn the XOR problem:

```
$network = new SimpleNeuralNetwork([
    (object)[
        'type' => SimpleLayer::class,
        'typeNeuron' => SimpleNeuron::class,
        'sizeNeuron' => 4,
        'learningRate' => 0.2,
        'activateFunction' => SigmoidActivateFunction::class,
        'weights' => [
            [rand(-100, 100) / 100, rand(-100, 100) / 100],
            [rand(-100, 100) / 100, rand(-100, 100) / 100],
            [rand(-100, 100) / 100, rand(-100, 100) / 100],
            [rand(-100, 100) / 100, rand(-100, 100) / 100],
        ],
        'bias' => [0, 0, 0, 0]
    ],
    (object)[
        'type' => SimpleLayer::class,
        'typeNeuron' => SimpleNeuron::class,
        'sizeNeuron' => 1,
        'learningRate' => 0.2,
        'activateFunction' => SigmoidActivateFunction::class,
        'weights' => [
            [rand(-100, 100) / 100, rand(-100, 100) / 100, rand(-100, 100) / 100, rand(-100, 100) / 100]
        ],
        'bias' => [0]
    ]
]);

// XOR training data
$training = [
    [[0, 0], [0]],
    [[0, 1], [1]],
    [[1, 0], [1]],
    [[1, 1], [0]],
    [[0.1, 0.9], [1]],
    [[0.9, 0.1], [1]],
    [[0.8, 0.8], [0]],
    [[0.2, 0.2], [0]]
];

$stages = 5000;

$network->learn($stages, $training);

// Test results
$tests = [
    [[0, 0], [0]],
    [[0, 1], [1]],
    [[1, 0], [1]],
    [[1, 1], [0]],
    [[0.2, 0.8], [1]],
    [[0.9, 0.2], [1]],
    [[0.7, 0.7], [0]],
    [[0.3, 0.3], [0]]
];

echo "TEST MULTILAYER XOR RESULTS";

foreach ($tests as $val) {
    $inputs = $val[0];
    $expected = $val[1][0];

    $output = $network->activate($inputs);
    $result = round($output[0]);

    $color = $result == $expected ? 'green' : 'red';
    $text = $result == $expected ? 'good' : 'bad';

    echo "Input: [" . implode(',', $inputs) . "] → Output: " .
        number_format($output[0], 3) .
        " | Expected: $expected $text";
}
```

### Expected Output

[](#expected-output)

```
TEST MULTILAYER XOR RESULTS
Input: [0,0] → Output: 0.035 | Expected: 0 good
Input: [0,1] → Output: 0.981 | Expected: 1 good
Input: [1,0] → Output: 0.987 | Expected: 1 good
Input: [1,1] → Output: 0.042 | Expected: 0 good
Input: [0.2,0.8] → Output: 0.739 | Expected: 1 good
Input: [0.9,0.2] → Output: 0.867 | Expected: 1 good
Input: [0.7,0.7] → Output: 0.061 | Expected: 0 good
Input: [0.3,0.3] → Output: 0.059 | Expected: 0 good

```

---

License
-------

[](#license)

MIT License
See the [LICENSE](LICENSE) file for details.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance65

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

Unknown

Total

1

Last Release

212d ago

### Community

Maintainers

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

---

Top Contributors

[![duvanCode](https://avatars.githubusercontent.com/u/52578979?v=4)](https://github.com/duvanCode "duvanCode (8 commits)")

### Embed Badge

![Health badge](/badges/synaptic-net-lab/health.svg)

```
[![Health](https://phpackages.com/badges/synaptic-net-lab/health.svg)](https://phpackages.com/packages/synaptic-net-lab)
```

PHPackages © 2026

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