https://github.com/devtronic/legendary-mind
Easy to use neural network written in PHP
https://github.com/devtronic/legendary-mind
neural-network php wrapper
Last synced: about 1 year ago
JSON representation
Easy to use neural network written in PHP
- Host: GitHub
- URL: https://github.com/devtronic/legendary-mind
- Owner: devtronic
- License: lgpl-3.0
- Created: 2016-09-20T17:57:34.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-11-26T20:32:43.000Z (over 8 years ago)
- Last Synced: 2025-03-28T02:21:27.347Z (about 1 year ago)
- Topics: neural-network, php, wrapper
- Language: PHP
- Homepage: https://docs.developer-heaven.de/docs/Devtronic/legendary-mind/master/
- Size: 34.2 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/Devtronic/legendary-mind)
[](https://github.com/Devtronic/legendary-mind/blob/master/LICENSE)
[](https://travis-ci.org/Devtronic/legendary-mind/)
[](https://github.com/Devtronic/legendary-mind)
# Legendary Mind
Legendary Mind is an easy to use Neural Network written in PHP
- Wrapper Class For Handling The Network
- Archive And Restore Neural Networks Serialized In Text-Files
### Installation
```bash
composer require devtronic/legendary-mind
```
### Usage
#### Standalone Network
```php
train($lessons);
// Setup the check lesson
$test = [1, 0];
$expected = [1];
// Propagate the check lesson
$mind->predict($test);
// Print the Output
print_r($mind->getOutput());
// Backpropagate
$mind->backPropagate($expected);
```
#### With Wrapper (recommended)
```php
['red', 'pink', 'blue', 'green'],
'hair_length' => ['short', 'long']
];
$outputs = [
'gender' => ['male', 'female']
];
// Setup the wrapper
$wrapper->initialize($properties, $outputs, $activator);
// Setup the lessons
$lessons = [
[
'input' => [
'color' => 'red',
'hair_length' => 'long',
],
'output' => [
'gender' => 'female'
],
],
[
'input' => [
'color' => 'blue',
'hair_length' => 'short',
],
'output' => [
'gender' => 'male'
],
],
[
'input' => [
'color' => 'red',
'hair_length' => 'short',
],
'output' => [
'gender' => 'male'
],
],
];
// Train the lessons
$wrapper->train($lessons);
// Setup the check lesson
$test_lesson = [
'input' => [
'color' => ['pink', 'green'],
'hair_length' => 'long',
],
'output' => [
'gender' => 'female'
]
];
// Propagate the check lesson
$wrapper->predict($test_lesson);
// Print the Output
print_r($wrapper->getResult());
// Backpropagate
$wrapper->backPropagate($test_lesson);
```
#### Archive and restore the network (only with wrapper, Line 16 and Line 67)
```php
restore($network_file);
} else {
// Possible input values
$properties = [
'color' => ['red', 'pink', 'blue', 'green'],
'hair_length' => ['short', 'long']
];
$outputs = [
'gender' => ['male', 'female']
];
// Setup the wrapper
$wrapper->initialize($properties, $outputs, $activator);
// Setup the lessons
$lessons = [
[
'input' => [
'color' => 'red',
'hair_length' => 'long',
],
'output' => [
'gender' => 'female'
],
],
[
'input' => [
'color' => 'blue',
'hair_length' => 'short',
],
'output' => [
'gender' => 'male'
],
],
[
'input' => [
'color' => 'red',
'hair_length' => 'short',
],
'output' => [
'gender' => 'male'
],
],
];
// Train the lessons
$wrapper->train($lessons);
// Archive the Network
$wrapper->archive($network_file);
}
// Setup the check lesson
$test_lesson = [
'input' => [
'color' => ['pink', 'green'],
'hair_length' => 'long',
],
'output' => [
'gender' => 'female'
]
];
// Propagate the check lesson
$wrapper->predict($test_lesson);
// Print the Output
print_r($wrapper->getResult());
// Backpropagate
$wrapper->backPropagate($test_lesson);
```