Skip to content

piotrw/simple-php-nn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleNN

Simple Neural Network implementation in PHP-OOP. Just for fun.

Inspired by Sentdex tutorial https://github.com/Sentdex/NNfSiX

Prerequisite

Installation

composer install

Usage

php demo.php

File demo.php contains:

<?php
 
use NumPHP\Core\NumArray;
use SimpleNN\AbstractActivation;
use SimpleNN\Layer;

require_once "vendor/autoload.php";

// Input data
$X = [
    [1, 2, 3, 2.5],
    [2, 5, -1, 2],
    [-1.5, 2.7, 3.3, -0.8],
];

// Initialize pseudo-random generator, for testing
srand(0);

// Define layers and activation functions
$layer1 = new Layer(4, 5);
$layer2 = new Layer(5, 2);
$activation1 = new Activation\ReLU();
$activation2 = new Activation\ReLU(); // todo SoftPlus

// Forward network
$layer1->forward($X);
$activation1->forward($layer1->getOutput());
$layer2->forward($activation1->getOutput());
$activation2->forward($layer2->getOutput());

// display output of network
\SimpleNN\Tools\Matrix::print($activation2->getOutput());

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages