Neural Network implemented in C++ and compiled as a native PHP extension.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
Makefile
README.md
composer.json
composer.lock
phpunit.xml.dist

README.md

Neural Network PHP Extension

This neural network was written in C++ by Dr. Mike Gashler and is released under the CC0 license. The native PHP module is compiled using PHP-CPP.

Dependencies

Install build utilities. (Ubuntu e.g.)

sudo apt-get install build-essential php7.0 php7.0-dev -y

Install PHP-CPP.

git clone https://github.com/CopernicaMarketingSoftware/PHP-CPP.git
cd PHP-CPP
make
sudo make install

Installation

Build, install, and enable the module.

make
sudo make install
sudo phpenmod jpuck-neural-network

Usage

See the tests for more detailed usage.

<?php

// intialize with the number of inputs,
// number of nodes per hidden layer (must have at least 1),
// and lastly the number of outputs.
// e.g. 3 inputs, 1 hidden layer with 16 nodes, and 2 outputs
$nn = new jpuck\NeuralNetwork(3, 16, 2);

// train the network with some features, labels, and a bias.
$inputs = [
    0.12,
    -0.38,
    0.77,
];
$outputs = [
    0.54,
    -0.25,
];
$nn->refine($inputs, $outputs, 0.02);

// get a prediction
$prediction = $nn->predict(...$inputs);