PHP Classes

PHP Neural Network Library: Implements a multilayer perceptron neural network

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 76 All time: 10,177 This week: 35Up
Version License PHP version Categories
php-nn 1.0.0The PHP License5PHP 5, Artificial intelligence
Description 

Author

This package implements a multilayer perceptron neural network.

It provides classes that implement networks, nodes and links that can be assembled to create a neural network.

The network can be activated using a matrix of weights that defines how the outputs of each node are computed from the input values.

It can also train the network with the same input data processing the epoch data several multiple times.

A very rudimentary MLP network implementation in PHP. Can be used for reference but no longer maintained

Picture of Rizza
  Performance   Level  

 

Example

<?php
require_once(__DIR__."/class/node.php");
require_once(
__DIR__."/class/network.php");
require_once(
__DIR__."/class/link.php");
require_once(
__DIR__."/func/activate.php");
ini_set('xdebug.var_display_max_depth', 5);
ini_set('xdebug.var_display_max_children', 256);
ini_set('xdebug.var_display_max_data', 1024);
ini_set('xdebug.max_nesting_level', 200);
srand(time());
$x=new \nn\network([2,2,2,1]);
echo
"<pre>";
//var_dump($x);
echo "</pre>";
error_reporting(E_ALL); ini_set('display_errors', 1);
//print_r($x->activate([1,2,2]));
foreach(
    [
        [[
1,1],[0]],
        [[
1,0],[1]],
        [[
0,1],[1]],
        [[
0,0],[0]]
    ]
    as
$y
   
){
       
      
print_r($y[0]);
      
print_r($x->activate($y[0]));
        echo(
"<br/>");
    }
set_time_limit(9001);
foreach(
range(1,100000) as $k){
   
$mse=0;
    foreach(
        [
            [[
1,1],[0]],
            [[
1,0],[1]],
            [[
0,1],[1]],
            [[
0,0],[0]]
        ]
        as
$y
       
){
           
$mse+=$x->epoch($y[0],$y[1]);
           
        }
       
//echo("<br/>");
        //echo $mse/2;
}

foreach(
    [
        [[
1,1],[1]],
        [[
1,0],[0]],
        [[
0,1],[0]],
        [[
0,0],[0]]
    ]
    as
$y
   
){
      
print_r($y[0]);
      
print_r($x->activate($y[0]));
        echo(
"<br/>");
    }


Details

php-nn

This is my first attempt at implamenting a multilayer perceptron neural network in php. Currently the network uses a standard backpropogation algorithm to train. This project will be updated with newer training methods shortly.


  Files folder image Files (13)  
File Role Description
Files folder imageOO (2 files, 2 directories)
Files folder imageProcedural (2 files, 1 directory)
Accessible without login Plain text file .buildpath Data Auxiliary data
Accessible without login Plain text file .project Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:76
This week:0
All time:10,177
This week:35Up