{"id":18864324,"url":"https://github.com/devtronic/legendary-mind","last_synced_at":"2025-04-14T13:12:20.416Z","repository":{"id":56967124,"uuid":"68738880","full_name":"devtronic/legendary-mind","owner":"devtronic","description":"Easy to use neural network written in PHP","archived":false,"fork":false,"pushed_at":"2017-11-26T20:32:43.000Z","size":35,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T02:21:27.347Z","etag":null,"topics":["neural-network","php","wrapper"],"latest_commit_sha":null,"homepage":"https://docs.developer-heaven.de/docs/Devtronic/legendary-mind/master/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devtronic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-20T17:57:34.000Z","updated_at":"2022-02-03T15:15:56.000Z","dependencies_parsed_at":"2022-08-21T06:10:22.949Z","dependency_job_id":null,"html_url":"https://github.com/devtronic/legendary-mind","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Flegendary-mind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Flegendary-mind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Flegendary-mind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Flegendary-mind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devtronic","download_url":"https://codeload.github.com/devtronic/legendary-mind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886325,"owners_count":21177644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["neural-network","php","wrapper"],"created_at":"2024-11-08T04:40:53.021Z","updated_at":"2025-04-14T13:12:20.264Z","avatar_url":"https://github.com/devtronic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub tag](https://img.shields.io/packagist/v/Devtronic/legendary-mind.svg)](https://github.com/Devtronic/legendary-mind)\n[![Packagist](https://img.shields.io/packagist/l/Devtronic/legendary-mind.svg)](https://github.com/Devtronic/legendary-mind/blob/master/LICENSE)\n[![Travis](https://img.shields.io/travis/Devtronic/legendary-mind.svg)](https://travis-ci.org/Devtronic/legendary-mind/)\n[![Packagist](https://img.shields.io/packagist/dt/Devtronic/legendary-mind.svg)](https://github.com/Devtronic/legendary-mind)\n\n# Legendary Mind\n\nLegendary Mind is an easy to use Neural Network written in PHP\n  - Wrapper Class For Handling The Network\n  - Archive And Restore Neural Networks Serialized In Text-Files\n\n### Installation\n```bash\ncomposer require devtronic/legendary-mind\n```\n\n### Usage\n#### Standalone Network\n```php\n\u003c?php\n\nuse Devtronic\\Layerless\\Activator\\TanHActivator;\nuse Devtronic\\LegendaryMind\\Mind;\n\nrequire_once 'vendor/autoload.php';\n\n// Create the topology for the net\n$topology = [2, 3, 1];\n\n// Set the activator\n$activator = new TanHActivator();\n\n// Instantiate the Mind\n$mind = new Mind($topology, $activator);\n\n// Setup XOR Lessons\n$lessons = [\n    [\n        [0, 0], # Inputs\n        [0]     # Outputs\n    ],\n    [\n        [0, 1], # Inputs\n        [1]     # Outputs\n    ],\n    [\n        [1, 0], # Inputs\n        [1]     # Outputs\n    ],\n    [\n        [1, 1], # Inputs\n        [0]     # Outputs\n    ],\n];\n\n// Train the lessons\n$mind-\u003etrain($lessons);\n\n// Setup the check lesson\n$test = [1, 0];\n$expected = [1];\n\n// Propagate the check lesson\n$mind-\u003epredict($test);\n\n// Print the Output\nprint_r($mind-\u003egetOutput());\n\n// Backpropagate\n$mind-\u003ebackPropagate($expected);\n```\n\n#### With Wrapper (recommended)\n```php\n\u003c?php\n\nuse Devtronic\\Layerless\\Activator\\TanHActivator;\nuse Devtronic\\LegendaryMind\\Wrapper;\n\nrequire_once 'vendor/autoload.php';\n\n// Set the activator function\n$activator = new TanHActivator();\n\n$wrapper = new Wrapper($hiddenNeurons = 3, $hiddenLayers = 1);\n\n// Possible input values\n$properties = [\n    'color' =\u003e ['red', 'pink', 'blue', 'green'],\n    'hair_length' =\u003e ['short', 'long']\n];\n\n$outputs = [\n    'gender' =\u003e ['male', 'female']\n];\n\n// Setup the wrapper\n$wrapper-\u003einitialize($properties, $outputs, $activator);\n\n// Setup the lessons\n$lessons = [\n    [\n        'input' =\u003e [\n            'color' =\u003e 'red',\n            'hair_length' =\u003e 'long',\n        ],\n        'output' =\u003e [\n            'gender' =\u003e 'female'\n        ],\n    ],\n    [\n        'input' =\u003e [\n            'color' =\u003e 'blue',\n            'hair_length' =\u003e 'short',\n        ],\n        'output' =\u003e [\n            'gender' =\u003e 'male'\n        ],\n    ],\n    [\n        'input' =\u003e [\n            'color' =\u003e 'red',\n            'hair_length' =\u003e 'short',\n        ],\n        'output' =\u003e [\n            'gender' =\u003e 'male'\n        ],\n    ],\n];\n\n// Train the lessons\n$wrapper-\u003etrain($lessons);\n\n// Setup the check lesson\n$test_lesson = [\n    'input' =\u003e [\n        'color' =\u003e ['pink', 'green'],\n        'hair_length' =\u003e 'long',\n    ],\n    'output' =\u003e [\n        'gender' =\u003e 'female'\n    ]\n];\n\n// Propagate the check lesson\n$wrapper-\u003epredict($test_lesson);\n\n// Print the Output\nprint_r($wrapper-\u003egetResult());\n\n// Backpropagate\n$wrapper-\u003ebackPropagate($test_lesson);\n```\n\n#### Archive and restore the network (only with wrapper, Line 16 and Line 67)\n```php\n\u003c?php\n\nuse Devtronic\\Layerless\\Activator\\TanHActivator;\nuse Devtronic\\LegendaryMind\\Wrapper;\n\nrequire_once 'vendor/autoload.php';\n\n// Set the activation function\n$activator = new TanHActivator();\n$wrapper = new Wrapper($hiddenNeurons = 3, $hiddenLayers = 1);\n\n$network_file = 'network.txt';\n\nif (is_file($network_file)) {\n    // Restore the Network\n    $wrapper-\u003erestore($network_file);\n} else {\n\n    // Possible input values\n    $properties = [\n        'color' =\u003e ['red', 'pink', 'blue', 'green'],\n        'hair_length' =\u003e ['short', 'long']\n    ];\n\n    $outputs = [\n        'gender' =\u003e ['male', 'female']\n    ];\n\n    // Setup the wrapper\n    $wrapper-\u003einitialize($properties, $outputs, $activator);\n\n    // Setup the lessons\n    $lessons = [\n        [\n            'input' =\u003e [\n                'color' =\u003e 'red',\n                'hair_length' =\u003e 'long',\n            ],\n            'output' =\u003e [\n                'gender' =\u003e 'female'\n            ],\n        ],\n        [\n            'input' =\u003e [\n                'color' =\u003e 'blue',\n                'hair_length' =\u003e 'short',\n            ],\n            'output' =\u003e [\n                'gender' =\u003e 'male'\n            ],\n        ],\n        [\n            'input' =\u003e [\n                'color' =\u003e 'red',\n                'hair_length' =\u003e 'short',\n            ],\n            'output' =\u003e [\n                'gender' =\u003e 'male'\n            ],\n        ],\n    ];\n\n    // Train the lessons\n    $wrapper-\u003etrain($lessons);\n\n    // Archive the Network\n    $wrapper-\u003earchive($network_file);\n}\n\n// Setup the check lesson\n$test_lesson = [\n    'input' =\u003e [\n        'color' =\u003e ['pink', 'green'],\n        'hair_length' =\u003e 'long',\n    ],\n    'output' =\u003e [\n        'gender' =\u003e 'female'\n    ]\n];\n\n// Propagate the check lesson\n$wrapper-\u003epredict($test_lesson);\n\n// Print the Output\nprint_r($wrapper-\u003egetResult());\n\n// Backpropagate\n$wrapper-\u003ebackPropagate($test_lesson);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtronic%2Flegendary-mind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevtronic%2Flegendary-mind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtronic%2Flegendary-mind/lists"}