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

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsFact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsZilliz
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 

Dernier (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsFact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 

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