Skip to content

Neural Network implemented in C++ and compiled as a native PHP extension.

Notifications You must be signed in to change notification settings

jpuck/neural-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

Neural Network implemented in C++ and compiled as a native PHP extension.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published