SlideShare une entreprise Scribd logo
1  sur  57
Télécharger pour lire hors ligne
with PHP on a 
Symfony Console 
TicTacToe game 
Artificial 
Neural 
Networks
ANN with PHP SymfonyCon Madrid 2014 
Agenda 
1. Demo 
2. Symfony Console 
3. Symfony Console Helpers 
4. ANN Theory 
6. PHP + FANN 
7. Show me the code 
8. Demo 
9. Q&A
ANN with PHP SymfonyCon Madrid 2014 
Demo 
vs.
ANN with PHP SymfonyCon Madrid 2014 
Symfony Console
ANN with PHP SymfonyCon Madrid 2014 
Symfony Console - Installation 
bin/console 
#!/usr/bin/env php 
<?php 
require __DIR__ . ‘/../vendor/autoload.php'; 
use SymfonyComponentConsoleApplication; 
$app = new Application(); 
$app->run(); 
composer.json 
{ 
... 
"require": { 
"symfony/console": "~2.5" 
} 
... 
}
ANN with PHP SymfonyCon Madrid 2014 
Symfony Console - Installation 
bin/console 
#!/usr/bin/env php 
<?php 
require __DIR__ . ‘/../vendor/autoload.php'; 
use SymfonyComponentConsoleApplication; 
$app = new Application(); 
$app->run(); 
composer.json 
{ 
... 
"require": { 
"symfony/console": "~2.5" 
} 
... 
} 
$ php bin/console 
$ chmod +x bin/console 
$ bin/console
ANN with PHP SymfonyCon Madrid 2014
ANN with PHP SymfonyCon Madrid 2014 
Symfony console style guide 
https://github.com/symfony/symfony-docs/issues/4265 
Created by @javiereguiluz 
Improved by Symfony community
ANN with PHP SymfonyCon Madrid 2014 
Symfony Console Helpers 
Progress bar 
Table 
Question 
Formatter
ANN with PHP SymfonyCon Madrid 2014 
Command.php 
Progress bar 
<?php 
// create a new progress bar (10 units) 
$progress = new ProgressBar($output, 10); 
// start and displays the progress bar 
$progress->start(); 
$i = 0; 
while ($i++ < 10) { 
// ... do some work 
// advance the progress bar 1 unit 
$progress->advance(); 
} 
// ensure that the progress bar is at 100% 
$progress->finish();
ANN with PHP SymfonyCon Madrid 2014 
We all techies love progress bars
ANN with PHP SymfonyCon Madrid 2014 
Table 
Command.php 
<?php 
$table = new Table($output); 
$table 
->setHeaders(array('Component', 'Package')) 
->setRows(array( 
array('Console', 'symfony/console'), 
array('Form', 'symfony/form'), 
array('Finder', 'symfony/finder'), 
array('Config', 'symfony/config'), 
array('...', '...'), 
)) 
; 
$table->render();
ANN with PHP SymfonyCon Madrid 2014 
Question 
Command.php 
<?php 
$helper = $this->getHelper('question'); 
$question = new ConfirmationQuestion( 
'Dou you want to play again? ', 
false 
); 
if (!$helper->ask($input, $output, $question)) 
{ 
$output->writeln("Bye bye!"); 
return; 
} 
$output->writeln("Let's play again!");
ANN with PHP SymfonyCon Madrid 2014 
Formatter 
Command.php 
<?php 
$formatter = $this->getHelper('formatter'); 
$formattedLine = $formatter->formatSection( 
'Game finished', 
'Player one wins.' 
); 
$output->writeln($formattedLine); 
$errorMessages = array( 
'Error!', 
'Move already done.’ 
); 
$formattedBlock = $formatter 
->formatBlock($errorMessages, 'error'); 
$output->writeln($formattedBlock);
ANN with PHP SymfonyCon Madrid 2014 
Our helper
ANN with PHP SymfonyCon Madrid 2014 
Board 
Command.php 
<?php 
// Board example usage 
$board = new Board( 
$output, 
$this->getApplication() 
->getTerminalDimensions(), 
3, // Board size 
false // Don’t override the screen 
); 
// Update and display the board status 
$board->updateGame(0,0,1);
ANN with PHP SymfonyCon Madrid 2014 
Board 
Command.php 
<?php 
// Board example - four in a row 
$board = new BoardHelper( 
$output, 
$this->getApplication() 
->getTerminalDimensions(), 
4, // Board size 
false // Don’t override screen 
true // Board with backgrounded cells 
); 
// Update the board status (Player 1) 
$board->updateGame(0,0,1); 
// Update the board status (Player 2) 
$board->updateGame(0,1,2);
ANN with PHP SymfonyCon Madrid 2014 
Board 
Command.php 
<?php 
// Example TicTacToe with overwrite 
$board = new TicTacToeHelper( 
$output, 
$this->getApplication() 
->getTerminalDimensions(), 
3, // Board size 
true // Overwrite screen 
); 
// Update the board status and display 
$board->updateGame(1,1,1); 
$board->updateGame(0,0,2); 
$board->updateGame(2,0,1); 
$board->updateGame(0,2,2); 
$board->updateGame(0,1,1); 
$board->updateGame(2,1,2); 
$board->updateGame(1,0,1); 
$board->updateGame(1,2,2); 
$board->updateGame(2,2,1);
ANN with PHP SymfonyCon Madrid 2014 
Board 
Board.php 
<?php 
namespace PHPGamesConsoleHelper; 
class Board 
{ 
/** 
* @var SymfonyComponentConsoleOutputOutputInterface 
*/ 
private $output; 
/** 
* Clears the output buffer 
*/ 
private function clear() 
{ 
$this->output->write("e[2J"); 
} 
// ... 
Instruction that 
clears the screen
ANN with PHP SymfonyCon Madrid 2014 
There is a bonus helper
ANN with PHP SymfonyCon Madrid 2014 
Symfony Console - HAL 
Command.php 
<?php 
$hal = new HAL($output); 
$hal->sayHello();
ANN with PHP SymfonyCon Madrid 2014 
Artificial 
Neural 
Networks 
Computer model that intends to simulate how the brain works
ANN with PHP SymfonyCon Madrid 2014 
A typical ANN 
Input neuron 
Hidden neuron 
Output neuron 
Signal & weight
ANN with PHP SymfonyCon Madrid 2014 
Activation Functions 
Functions to process the input and produce a signal as output
ANN with PHP SymfonyCon Madrid 2014 
Activation Functions 
• Step - output is 0 or 1 
• Linear Combination - output is input sum plus 
a linear bias 
• Continuous Log-Sigmoid
ANN with PHP SymfonyCon Madrid 2014 
Activation Functions 
• Step - output is 0 or 1 
• Linear Combination - output is input sum plus 
a linear bias 
• Continuous Log-Sigmoid
ANN with PHP SymfonyCon Madrid 2014 
Activation Functions 
• Step - output is 0 or 1 
• Linear Combination - output is input sum plus 
a linear bias 
• Continuous Log-Sigmoid
ANN with PHP SymfonyCon Madrid 2014 
Backpropagation 
Backward propagation of errors 
Passes error signals backwards through the network during training to update the weights of the network
ANN with PHP SymfonyCon Madrid 2014 
ANN Types
ANN with PHP SymfonyCon Madrid 2014 
ANN types 
• Feedforward neural network 
Information goes only in one direction, forward. 
• Radial basis function network (RBF) 
Interpolation in multidimensional space. 
• Kohonen self-organizing network 
A set of artificial neurons learn to map points in an input space to 
coordinates in an output space.
ANN with PHP SymfonyCon Madrid 2014 
ANN types 
• Feedforward neural network 
Information goes only in one direction, forward. 
• Radial basis function network (RBF) 
Interpolation in multidimensional space. 
• Kohonen self-organizing network 
A set of artificial neurons learn to map points in an input space to 
coordinates in an output space.
ANN with PHP SymfonyCon Madrid 2014 
ANN types 
• Feedforward neural network 
Information goes only in one direction, forward. 
• Radial basis function network (RBF) 
Interpolation in multidimensional space. 
• Kohonen self-organizing network 
A set of artificial neurons learn to map points in an input space to 
coordinates in an output space.
ANN with PHP SymfonyCon Madrid 2014 
ANN Learning
ANN with PHP SymfonyCon Madrid 2014 
ANN Learning 
• Supervised 
• Unsupervised 
• Reinforcement
ANN with PHP SymfonyCon Madrid 2014 
ANN Learning 
• Supervised 
• Unsupervised 
• Reinforcement
ANN with PHP SymfonyCon Madrid 2014 
ANN Learning 
• Supervised 
• Unsupervised 
• Reinforcement
ANN with PHP SymfonyCon Madrid 2014 
We've used 
Reinforcement Learning 
With some slights adaptations to solve
ANN with PHP SymfonyCon Madrid 2014 
Temporal Credit Assignment 
Problem
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
What The Fann 
Artificial Neural Networks with PHP
ANN with PHP SymfonyCon Madrid 2014
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
Meet libfann & PECL fann 
$~> sudo apt-get install libfann; sudo pecl install fann
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
 OS X 
1. Install autoconf 
2. Install cmake 
3. Compile FANN 
4. Install php fann extension with PECL 
5. Add the extension to php.ini 
$ brew install autoconf
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
 OS X 
1. Install autoconf 
2. Install cmake 
3. Compile FANN 
4. Install php fann extension with PECL 
5. Add the extension to php.ini 
$ brew install cmake
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
 OS X 
1. Install autoconf 
2. Install cmake 
3. Compile FANN 
4. Install php fann extension with PECL 
5. Add the extension to php.ini 
$ cd FANN-2.2.X-Source 
$ cmake . 
$ sudo make install
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
 OS X 
1. Install autoconf 
2. Install cmake 
3. Compile FANN 
4. Install php fann extension with PECL 
5. Add the extension to php.ini 
$ sudo pecl install fann
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
 OS X 
1. Install autoconf 
2. Install cmake 
3. Compile FANN 
4. Install php fann extension with PECL 
5. Add the extension to php.ini 
extension=fann.so
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
Enjoy!
ANN with PHP SymfonyCon Madrid 2014 
(WTF) ANN with 
Show me the code!
ANN with PHP SymfonyCon Madrid 2014 
Demo 
vs.
ANN with PHP SymfonyCon Madrid 2014
ANN with PHP SymfonyCon Madrid 2014 
The two neurons behind this talk
ANN with PHP SymfonyCon Madrid 2014 
Eduardo Gulias 
@egulias 
• EmailValidator 
(Symfony >= 2.5, Drupal 8). 
• ListenersDebugCommandBundle 
(ezPublish 5). 
• PHPMad UG co-founder 
(Former Symfony Madrid). 
• Team leader at
ANN with PHP SymfonyCon Madrid 2014 
Ariel Ferrandini 
@aferrandini 
• Symfony simple password encoder 
service. (Symfony >=2.6). 
• Symfony DX application 
collaborator. 
• PHPMad UG co-founder. 
• Team leader at Paradigma 
Tecnológico
ANN with PHP SymfonyCon Madrid 2014 
Resources 
• Wikipedia (http://en.wikipedia.org/wiki/Artificial_neural_network) 
• Introduction for beginners (http://arxiv.org/pdf/cs/0308031.pdf) 
• Introduction to ANN (http://www.theprojectspot.com/tutorial-post/ 
introduction-to-artificial-neural-networks-part-1/7) 
• Reinforcement learning (http://www.willamette.edu/~gorr/classes/ 
cs449/Reinforcement/reinforcement0.html) 
• PHP FANN (http://www.php.net/fann)
ANN with PHP SymfonyCon Madrid 2014 
Resources 
• Repo PHPGames (https://github.com/phpgames/ANNTicTacToe) 
• Repo Board helper (https://github.com/phpgames/BoardHelper) 
• Repo HAL helper (https://github.com/phpgames/HALHelper)
ANN with PHP SymfonyCon Madrid 2014 
Thank you! 
https://joind.in/12951
ANN with PHP SymfonyCon Madrid 2014 
Questions? 
https://joind.in/12951

Contenu connexe

En vedette

Neural network & its applications
Neural network & its applications Neural network & its applications
Neural network & its applications Ahmed_hashmi
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural networkDEEPASHRI HK
 
Introduction Of Artificial neural network
Introduction Of Artificial neural networkIntroduction Of Artificial neural network
Introduction Of Artificial neural networkNagarajan
 
Compegence: Dr. Rajaram Kudli - An Introduction to Artificial Neural Network ...
Compegence: Dr. Rajaram Kudli - An Introduction to Artificial Neural Network ...Compegence: Dr. Rajaram Kudli - An Introduction to Artificial Neural Network ...
Compegence: Dr. Rajaram Kudli - An Introduction to Artificial Neural Network ...COMPEGENCE
 
Artificial neural network model & hidden layers in multilayer artificial neur...
Artificial neural network model & hidden layers in multilayer artificial neur...Artificial neural network model & hidden layers in multilayer artificial neur...
Artificial neural network model & hidden layers in multilayer artificial neur...Muhammad Ishaq
 
Artificial neural networks
Artificial neural networksArtificial neural networks
Artificial neural networksstellajoseph
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural networkmustafa aadel
 
Artificial Neural Network(Artificial intelligence)
Artificial Neural Network(Artificial intelligence)Artificial Neural Network(Artificial intelligence)
Artificial Neural Network(Artificial intelligence)spartacus131211
 
Artificial Neural Network Seminar - Google Brain
Artificial Neural Network Seminar - Google BrainArtificial Neural Network Seminar - Google Brain
Artificial Neural Network Seminar - Google BrainRawan Al-Omari
 
artificial neural network
artificial neural networkartificial neural network
artificial neural networkPallavi Yadav
 
Neural network
Neural networkNeural network
Neural networkSilicon
 
Artificial intelligence NEURAL NETWORKS
Artificial intelligence NEURAL NETWORKSArtificial intelligence NEURAL NETWORKS
Artificial intelligence NEURAL NETWORKSREHMAT ULLAH
 
Artificial Neural Network / Hand written character Recognition
Artificial Neural Network / Hand written character RecognitionArtificial Neural Network / Hand written character Recognition
Artificial Neural Network / Hand written character RecognitionDr. Uday Saikia
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural networkIldar Nurgaliev
 
Artificial Intelligence: Artificial Neural Networks
Artificial Intelligence: Artificial Neural NetworksArtificial Intelligence: Artificial Neural Networks
Artificial Intelligence: Artificial Neural NetworksThe Integral Worm
 
Handwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural networkHandwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural networkHarshana Madusanka Jayamaha
 
Neural networks
Neural networksNeural networks
Neural networksSlideshare
 
neural network
neural networkneural network
neural networkSTUDENT
 
Nueral Network
Nueral NetworkNueral Network
Nueral Networka_anks08
 

En vedette (20)

Neural network & its applications
Neural network & its applications Neural network & its applications
Neural network & its applications
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Introduction Of Artificial neural network
Introduction Of Artificial neural networkIntroduction Of Artificial neural network
Introduction Of Artificial neural network
 
Compegence: Dr. Rajaram Kudli - An Introduction to Artificial Neural Network ...
Compegence: Dr. Rajaram Kudli - An Introduction to Artificial Neural Network ...Compegence: Dr. Rajaram Kudli - An Introduction to Artificial Neural Network ...
Compegence: Dr. Rajaram Kudli - An Introduction to Artificial Neural Network ...
 
Artificial neural network model & hidden layers in multilayer artificial neur...
Artificial neural network model & hidden layers in multilayer artificial neur...Artificial neural network model & hidden layers in multilayer artificial neur...
Artificial neural network model & hidden layers in multilayer artificial neur...
 
Artificial neural networks
Artificial neural networksArtificial neural networks
Artificial neural networks
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Artificial Neural Network(Artificial intelligence)
Artificial Neural Network(Artificial intelligence)Artificial Neural Network(Artificial intelligence)
Artificial Neural Network(Artificial intelligence)
 
Artificial Neural Network Seminar - Google Brain
Artificial Neural Network Seminar - Google BrainArtificial Neural Network Seminar - Google Brain
Artificial Neural Network Seminar - Google Brain
 
artificial neural network
artificial neural networkartificial neural network
artificial neural network
 
Neural network
Neural networkNeural network
Neural network
 
Artificial intelligence NEURAL NETWORKS
Artificial intelligence NEURAL NETWORKSArtificial intelligence NEURAL NETWORKS
Artificial intelligence NEURAL NETWORKS
 
Artificial Neural Network / Hand written character Recognition
Artificial Neural Network / Hand written character RecognitionArtificial Neural Network / Hand written character Recognition
Artificial Neural Network / Hand written character Recognition
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Artificial Intelligence: Artificial Neural Networks
Artificial Intelligence: Artificial Neural NetworksArtificial Intelligence: Artificial Neural Networks
Artificial Intelligence: Artificial Neural Networks
 
Handwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural networkHandwritten character recognition using artificial neural network
Handwritten character recognition using artificial neural network
 
Neural networks
Neural networksNeural networks
Neural networks
 
neural network
neural networkneural network
neural network
 
Nueral Network
Nueral NetworkNueral Network
Nueral Network
 

Similaire à Artificial Neural Network in a Tic Tac Toe Symfony Console Application - SymfonyCon 2014

CodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHPCodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHPSteeven Salim
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6Wim Godden
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshopjulien pauli
 
Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)Vyacheslav Matyukhin
 
symfony: Simplify your professional web development with PHP (IPC Frankfurt 2...
symfony: Simplify your professional web development with PHP (IPC Frankfurt 2...symfony: Simplify your professional web development with PHP (IPC Frankfurt 2...
symfony: Simplify your professional web development with PHP (IPC Frankfurt 2...Fabien Potencier
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7Wim Godden
 
Symfony 2.0
Symfony 2.0Symfony 2.0
Symfony 2.0GrUSP
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldGraham Weldon
 
3. build your own php extension ai ti aptech
3. build your own php extension   ai ti aptech3. build your own php extension   ai ti aptech
3. build your own php extension ai ti aptechQuang Anh Le
 
07 build your-own_php_extension
07 build your-own_php_extension07 build your-own_php_extension
07 build your-own_php_extensionNguyen Duc Phu
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extensionVõ Duy Tuấn
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Wim Godden
 
Write Plugins for symfony (Symfony Camp 2007)
Write Plugins for symfony (Symfony Camp 2007)Write Plugins for symfony (Symfony Camp 2007)
Write Plugins for symfony (Symfony Camp 2007)Fabien Potencier
 
Symfony Live 09 Symfony 2
Symfony Live 09 Symfony 2Symfony Live 09 Symfony 2
Symfony Live 09 Symfony 2narkoza
 
Artificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationArtificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationEduardo Gulias Davis
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016Codemotion
 

Similaire à Artificial Neural Network in a Tic Tac Toe Symfony Console Application - SymfonyCon 2014 (20)

CodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHPCodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHP
 
Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3
 
PhpSpec extension points
PhpSpec extension pointsPhpSpec extension points
PhpSpec extension points
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)
 
symfony: Simplify your professional web development with PHP (IPC Frankfurt 2...
symfony: Simplify your professional web development with PHP (IPC Frankfurt 2...symfony: Simplify your professional web development with PHP (IPC Frankfurt 2...
symfony: Simplify your professional web development with PHP (IPC Frankfurt 2...
 
Running Symfony
Running SymfonyRunning Symfony
Running Symfony
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7
 
Symfony 2.0
Symfony 2.0Symfony 2.0
Symfony 2.0
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your world
 
3. build your own php extension ai ti aptech
3. build your own php extension   ai ti aptech3. build your own php extension   ai ti aptech
3. build your own php extension ai ti aptech
 
07 build your-own_php_extension
07 build your-own_php_extension07 build your-own_php_extension
07 build your-own_php_extension
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extension
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
 
Write Plugins for symfony (Symfony Camp 2007)
Write Plugins for symfony (Symfony Camp 2007)Write Plugins for symfony (Symfony Camp 2007)
Write Plugins for symfony (Symfony Camp 2007)
 
Symfony Live 09 Symfony 2
Symfony Live 09 Symfony 2Symfony Live 09 Symfony 2
Symfony Live 09 Symfony 2
 
Artificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console applicationArtificial Neural Networks on a Tic Tac Toe console application
Artificial Neural Networks on a Tic Tac Toe console application
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 

Dernier

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Dernier (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Artificial Neural Network in a Tic Tac Toe Symfony Console Application - SymfonyCon 2014

  • 1. with PHP on a Symfony Console TicTacToe game Artificial Neural Networks
  • 2. ANN with PHP SymfonyCon Madrid 2014 Agenda 1. Demo 2. Symfony Console 3. Symfony Console Helpers 4. ANN Theory 6. PHP + FANN 7. Show me the code 8. Demo 9. Q&A
  • 3. ANN with PHP SymfonyCon Madrid 2014 Demo vs.
  • 4. ANN with PHP SymfonyCon Madrid 2014 Symfony Console
  • 5. ANN with PHP SymfonyCon Madrid 2014 Symfony Console - Installation bin/console #!/usr/bin/env php <?php require __DIR__ . ‘/../vendor/autoload.php'; use SymfonyComponentConsoleApplication; $app = new Application(); $app->run(); composer.json { ... "require": { "symfony/console": "~2.5" } ... }
  • 6. ANN with PHP SymfonyCon Madrid 2014 Symfony Console - Installation bin/console #!/usr/bin/env php <?php require __DIR__ . ‘/../vendor/autoload.php'; use SymfonyComponentConsoleApplication; $app = new Application(); $app->run(); composer.json { ... "require": { "symfony/console": "~2.5" } ... } $ php bin/console $ chmod +x bin/console $ bin/console
  • 7. ANN with PHP SymfonyCon Madrid 2014
  • 8. ANN with PHP SymfonyCon Madrid 2014 Symfony console style guide https://github.com/symfony/symfony-docs/issues/4265 Created by @javiereguiluz Improved by Symfony community
  • 9. ANN with PHP SymfonyCon Madrid 2014 Symfony Console Helpers Progress bar Table Question Formatter
  • 10. ANN with PHP SymfonyCon Madrid 2014 Command.php Progress bar <?php // create a new progress bar (10 units) $progress = new ProgressBar($output, 10); // start and displays the progress bar $progress->start(); $i = 0; while ($i++ < 10) { // ... do some work // advance the progress bar 1 unit $progress->advance(); } // ensure that the progress bar is at 100% $progress->finish();
  • 11. ANN with PHP SymfonyCon Madrid 2014 We all techies love progress bars
  • 12. ANN with PHP SymfonyCon Madrid 2014 Table Command.php <?php $table = new Table($output); $table ->setHeaders(array('Component', 'Package')) ->setRows(array( array('Console', 'symfony/console'), array('Form', 'symfony/form'), array('Finder', 'symfony/finder'), array('Config', 'symfony/config'), array('...', '...'), )) ; $table->render();
  • 13. ANN with PHP SymfonyCon Madrid 2014 Question Command.php <?php $helper = $this->getHelper('question'); $question = new ConfirmationQuestion( 'Dou you want to play again? ', false ); if (!$helper->ask($input, $output, $question)) { $output->writeln("Bye bye!"); return; } $output->writeln("Let's play again!");
  • 14. ANN with PHP SymfonyCon Madrid 2014 Formatter Command.php <?php $formatter = $this->getHelper('formatter'); $formattedLine = $formatter->formatSection( 'Game finished', 'Player one wins.' ); $output->writeln($formattedLine); $errorMessages = array( 'Error!', 'Move already done.’ ); $formattedBlock = $formatter ->formatBlock($errorMessages, 'error'); $output->writeln($formattedBlock);
  • 15. ANN with PHP SymfonyCon Madrid 2014 Our helper
  • 16. ANN with PHP SymfonyCon Madrid 2014 Board Command.php <?php // Board example usage $board = new Board( $output, $this->getApplication() ->getTerminalDimensions(), 3, // Board size false // Don’t override the screen ); // Update and display the board status $board->updateGame(0,0,1);
  • 17. ANN with PHP SymfonyCon Madrid 2014 Board Command.php <?php // Board example - four in a row $board = new BoardHelper( $output, $this->getApplication() ->getTerminalDimensions(), 4, // Board size false // Don’t override screen true // Board with backgrounded cells ); // Update the board status (Player 1) $board->updateGame(0,0,1); // Update the board status (Player 2) $board->updateGame(0,1,2);
  • 18. ANN with PHP SymfonyCon Madrid 2014 Board Command.php <?php // Example TicTacToe with overwrite $board = new TicTacToeHelper( $output, $this->getApplication() ->getTerminalDimensions(), 3, // Board size true // Overwrite screen ); // Update the board status and display $board->updateGame(1,1,1); $board->updateGame(0,0,2); $board->updateGame(2,0,1); $board->updateGame(0,2,2); $board->updateGame(0,1,1); $board->updateGame(2,1,2); $board->updateGame(1,0,1); $board->updateGame(1,2,2); $board->updateGame(2,2,1);
  • 19. ANN with PHP SymfonyCon Madrid 2014 Board Board.php <?php namespace PHPGamesConsoleHelper; class Board { /** * @var SymfonyComponentConsoleOutputOutputInterface */ private $output; /** * Clears the output buffer */ private function clear() { $this->output->write("e[2J"); } // ... Instruction that clears the screen
  • 20. ANN with PHP SymfonyCon Madrid 2014 There is a bonus helper
  • 21. ANN with PHP SymfonyCon Madrid 2014 Symfony Console - HAL Command.php <?php $hal = new HAL($output); $hal->sayHello();
  • 22. ANN with PHP SymfonyCon Madrid 2014 Artificial Neural Networks Computer model that intends to simulate how the brain works
  • 23. ANN with PHP SymfonyCon Madrid 2014 A typical ANN Input neuron Hidden neuron Output neuron Signal & weight
  • 24. ANN with PHP SymfonyCon Madrid 2014 Activation Functions Functions to process the input and produce a signal as output
  • 25. ANN with PHP SymfonyCon Madrid 2014 Activation Functions • Step - output is 0 or 1 • Linear Combination - output is input sum plus a linear bias • Continuous Log-Sigmoid
  • 26. ANN with PHP SymfonyCon Madrid 2014 Activation Functions • Step - output is 0 or 1 • Linear Combination - output is input sum plus a linear bias • Continuous Log-Sigmoid
  • 27. ANN with PHP SymfonyCon Madrid 2014 Activation Functions • Step - output is 0 or 1 • Linear Combination - output is input sum plus a linear bias • Continuous Log-Sigmoid
  • 28. ANN with PHP SymfonyCon Madrid 2014 Backpropagation Backward propagation of errors Passes error signals backwards through the network during training to update the weights of the network
  • 29. ANN with PHP SymfonyCon Madrid 2014 ANN Types
  • 30. ANN with PHP SymfonyCon Madrid 2014 ANN types • Feedforward neural network Information goes only in one direction, forward. • Radial basis function network (RBF) Interpolation in multidimensional space. • Kohonen self-organizing network A set of artificial neurons learn to map points in an input space to coordinates in an output space.
  • 31. ANN with PHP SymfonyCon Madrid 2014 ANN types • Feedforward neural network Information goes only in one direction, forward. • Radial basis function network (RBF) Interpolation in multidimensional space. • Kohonen self-organizing network A set of artificial neurons learn to map points in an input space to coordinates in an output space.
  • 32. ANN with PHP SymfonyCon Madrid 2014 ANN types • Feedforward neural network Information goes only in one direction, forward. • Radial basis function network (RBF) Interpolation in multidimensional space. • Kohonen self-organizing network A set of artificial neurons learn to map points in an input space to coordinates in an output space.
  • 33. ANN with PHP SymfonyCon Madrid 2014 ANN Learning
  • 34. ANN with PHP SymfonyCon Madrid 2014 ANN Learning • Supervised • Unsupervised • Reinforcement
  • 35. ANN with PHP SymfonyCon Madrid 2014 ANN Learning • Supervised • Unsupervised • Reinforcement
  • 36. ANN with PHP SymfonyCon Madrid 2014 ANN Learning • Supervised • Unsupervised • Reinforcement
  • 37. ANN with PHP SymfonyCon Madrid 2014 We've used Reinforcement Learning With some slights adaptations to solve
  • 38. ANN with PHP SymfonyCon Madrid 2014 Temporal Credit Assignment Problem
  • 39. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with What The Fann Artificial Neural Networks with PHP
  • 40. ANN with PHP SymfonyCon Madrid 2014
  • 41. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with Meet libfann & PECL fann $~> sudo apt-get install libfann; sudo pecl install fann
  • 42. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with  OS X 1. Install autoconf 2. Install cmake 3. Compile FANN 4. Install php fann extension with PECL 5. Add the extension to php.ini $ brew install autoconf
  • 43. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with  OS X 1. Install autoconf 2. Install cmake 3. Compile FANN 4. Install php fann extension with PECL 5. Add the extension to php.ini $ brew install cmake
  • 44. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with  OS X 1. Install autoconf 2. Install cmake 3. Compile FANN 4. Install php fann extension with PECL 5. Add the extension to php.ini $ cd FANN-2.2.X-Source $ cmake . $ sudo make install
  • 45. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with  OS X 1. Install autoconf 2. Install cmake 3. Compile FANN 4. Install php fann extension with PECL 5. Add the extension to php.ini $ sudo pecl install fann
  • 46. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with  OS X 1. Install autoconf 2. Install cmake 3. Compile FANN 4. Install php fann extension with PECL 5. Add the extension to php.ini extension=fann.so
  • 47. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with Enjoy!
  • 48. ANN with PHP SymfonyCon Madrid 2014 (WTF) ANN with Show me the code!
  • 49. ANN with PHP SymfonyCon Madrid 2014 Demo vs.
  • 50. ANN with PHP SymfonyCon Madrid 2014
  • 51. ANN with PHP SymfonyCon Madrid 2014 The two neurons behind this talk
  • 52. ANN with PHP SymfonyCon Madrid 2014 Eduardo Gulias @egulias • EmailValidator (Symfony >= 2.5, Drupal 8). • ListenersDebugCommandBundle (ezPublish 5). • PHPMad UG co-founder (Former Symfony Madrid). • Team leader at
  • 53. ANN with PHP SymfonyCon Madrid 2014 Ariel Ferrandini @aferrandini • Symfony simple password encoder service. (Symfony >=2.6). • Symfony DX application collaborator. • PHPMad UG co-founder. • Team leader at Paradigma Tecnológico
  • 54. ANN with PHP SymfonyCon Madrid 2014 Resources • Wikipedia (http://en.wikipedia.org/wiki/Artificial_neural_network) • Introduction for beginners (http://arxiv.org/pdf/cs/0308031.pdf) • Introduction to ANN (http://www.theprojectspot.com/tutorial-post/ introduction-to-artificial-neural-networks-part-1/7) • Reinforcement learning (http://www.willamette.edu/~gorr/classes/ cs449/Reinforcement/reinforcement0.html) • PHP FANN (http://www.php.net/fann)
  • 55. ANN with PHP SymfonyCon Madrid 2014 Resources • Repo PHPGames (https://github.com/phpgames/ANNTicTacToe) • Repo Board helper (https://github.com/phpgames/BoardHelper) • Repo HAL helper (https://github.com/phpgames/HALHelper)
  • 56. ANN with PHP SymfonyCon Madrid 2014 Thank you! https://joind.in/12951
  • 57. ANN with PHP SymfonyCon Madrid 2014 Questions? https://joind.in/12951