SlideShare una empresa de Scribd logo
1 de 57
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)fefe7270
 
Symfony live 2017_php7_performances
Symfony live 2017_php7_performancesSymfony live 2017_php7_performances
Symfony live 2017_php7_performancesjulien pauli
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?Nikita Popov
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objectsjulien pauli
 
PHP 7 OPCache extension review
PHP 7 OPCache extension reviewPHP 7 OPCache extension review
PHP 7 OPCache extension reviewjulien pauli
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Nikita Popov
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate WorksGoro Fuji
 
C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)Yuki Tamura
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionjulien pauli
 
Introduction to advanced python
Introduction to advanced pythonIntroduction to advanced python
Introduction to advanced pythonCharles-Axel Dein
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5julien pauli
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perlgarux
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersLin Yo-An
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Lin Yo-An
 
Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)fefe7270
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Nikita Popov
 

La actualidad más candente (20)

PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
 
Building Custom PHP Extensions
Building Custom PHP ExtensionsBuilding Custom PHP Extensions
Building Custom PHP Extensions
 
Symfony live 2017_php7_performances
Symfony live 2017_php7_performancesSymfony live 2017_php7_performances
Symfony live 2017_php7_performances
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objects
 
Functions
FunctionsFunctions
Functions
 
PHP 7 OPCache extension review
PHP 7 OPCache extension reviewPHP 7 OPCache extension review
PHP 7 OPCache extension review
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate Works
 
C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)C++の話(本当にあった怖い話)
C++の話(本当にあった怖い話)
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
 
Introduction to advanced python
Introduction to advanced pythonIntroduction to advanced python
Introduction to advanced python
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perl
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
 
Usp
UspUsp
Usp
 
Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
 

Similar a Artificial Neural Networks with PHP & Symfony con 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
 
CLI, the other SAPI
CLI, the other SAPICLI, the other SAPI
CLI, the other SAPICombell NV
 
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
 

Similar a Artificial Neural Networks with PHP & Symfony con 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
 
CLI, the other SAPI
CLI, the other SAPICLI, the other SAPI
CLI, the other SAPI
 
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
 

Último

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
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
 

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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...
 
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 Neural Networks with PHP & Symfony con 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