On Implementation of Neuron
Network(Back-propagation)
Yu Liu
National Institute of Informatics
Nov 9, 2010
Yu Liu MapReduce For Machine Learning
Outline
1 Motivations
2 Brief introduction of background
The Neural Network
The Back-propagation Algorithm
The Problems of Back-propagation
3 Implementation using C++ STL, Sketo Lib and Intel TBB
and boost Mapreduce(next week)
Main Flow od data processing
Analysis of Parallelism
Optimization
4 The Benchmark Results
5 The Remained Problems
Yu Liu MapReduce For Machine Learning
Motivation
Do more practice of parallel programming.
Yu Liu MapReduce For Machine Learning
Motivation
Do more practice of parallel programming.
Using and comparing different parallel programming Libraries.
Yu Liu MapReduce For Machine Learning
Motivation
Do more practice of parallel programming.
Using and comparing different parallel programming Libraries.
Studying the principle of designing a good parallel
programming Library.
Yu Liu MapReduce For Machine Learning
MapReduce Programming model
What is MapReduce
The Computation of MapReduce Framework
Input: a set of key/value pairs
Main Concepts of MapReduce Programming Paradigm
Yu Liu MapReduce For Machine Learning
MapReduce Programming model
What is MapReduce
The Computation of MapReduce Framework
Input: a set of key/value pairs
Output: a set of key/value pairs.
Main Concepts of MapReduce Programming Paradigm
Yu Liu MapReduce For Machine Learning
MapReduce Programming model
What is MapReduce
The Computation of MapReduce Framework
Input: a set of key/value pairs
Output: a set of key/value pairs.
The user provide two functions: Map and Reduce.
Main Concepts of MapReduce Programming Paradigm
Yu Liu MapReduce For Machine Learning
MapReduce Programming model
What is MapReduce
The Computation of MapReduce Framework
Input: a set of key/value pairs
Output: a set of key/value pairs.
The user provide two functions: Map and Reduce.
Main Concepts of MapReduce Programming Paradigm
SPLIT: Splitting the input data and iterating over it;
Yu Liu MapReduce For Machine Learning
MapReduce Programming model
What is MapReduce
The Computation of MapReduce Framework
Input: a set of key/value pairs
Output: a set of key/value pairs.
The user provide two functions: Map and Reduce.
Main Concepts of MapReduce Programming Paradigm
SPLIT: Splitting the input data and iterating over it;
MAP: Computation key/value pairs on each split;
Yu Liu MapReduce For Machine Learning
MapReduce Programming model
What is MapReduce
The Computation of MapReduce Framework
Input: a set of key/value pairs
Output: a set of key/value pairs.
The user provide two functions: Map and Reduce.
Main Concepts of MapReduce Programming Paradigm
SPLIT: Splitting the input data and iterating over it;
MAP: Computation key/value pairs on each split;
SHUFFLE and SORT: Grouping intermediate values by key;
Yu Liu MapReduce For Machine Learning
MapReduce Programming model
What is MapReduce
The Computation of MapReduce Framework
Input: a set of key/value pairs
Output: a set of key/value pairs.
The user provide two functions: Map and Reduce.
Main Concepts of MapReduce Programming Paradigm
SPLIT: Splitting the input data and iterating over it;
MAP: Computation key/value pairs on each split;
SHUFFLE and SORT: Grouping intermediate values by key;
REDUCE: Iterating over the resulting groups and reducing
each group.
Yu Liu MapReduce For Machine Learning
MapReduce Programming model
The example of applying MapReduce on machine-learning
The paper: Map-Reduce for Machine Learning on Multicore give
us a programming framework model which using mapreduce
paradigm to do parallel data processing:
Yu Liu MapReduce For Machine Learning
The Artificial Neural Network
An Artificial Neural Network (ANN) is an information processing
paradigm that is inspired by the way biological nervous systems,
such as the brain, process information.It is composed of a large
number of highly interconnected processing elements (neurones)
working in unison to solve specific problems.
R.Rojas: Neural Networks. Springer-Verlag, Berlin, 1996
Yu Liu MapReduce For Machine Learning
The Artificial Neural Network
A simple mapreduce example
The neural network can be trained to recognise some patterns:
Yu Liu MapReduce For Machine Learning
The Back-Propagation Algorithm
Training the NN
In order to train a neural network, must adjust the weights of each
unit to make that the error between the desired output and the
actual output is reduced.
The back-propagation algorithm:
http://galaxy.agh.edu.pl/ ∼vlsi/AI/backp t en/backprop.html
Yu Liu MapReduce For Machine Learning
The Back-Propagation Algorithm
Back-Propagation concepts
1 Propagates inputs forward in the usual way, i.e.
All outputs are computed using sigmoid threshold of the inner
product of the corresponding weight and input vectors.
All outputs at stage n are connected to all the inputs at stage
n+1
2 Propagates the errors backwards by apportioning them to
each unit according to the amount of this error the unit is
responsible for.
Yu Liu MapReduce For Machine Learning
The Back-Propagation Algorithm
Back-Propagation process:
Yu Liu MapReduce For Machine Learning
The Back-Propagation Algorithm
Back-Propagation process:
Yu Liu MapReduce For Machine Learning
3 versions of implementations
Sequential, Sketo, and TBB
A neural network(NN) c++ class was implemented and
An instance of neural network can be created by given
arguments of number of input, layers, number of neurons ...
given an input pattern it will give a (set of) output signal(s).
it has B-P method to update all neuron’s weights.
it has other methods to do all kinds of operations. E.g, put
weights , get weights.
All the operations of the neural network are sequential.
Yu Liu MapReduce For Machine Learning
3 versions of implementations
Sequential, Sketo, and TBB
All three versions are implemented as same architecture.
The Training stage:
training data and instance of NN(BP algorithm) are inputs of
a map function;
out put of the map function are set of new weights.
input of reduce function are out put of map function.
out put of reduce function is the average of these new weights.
( here I simply average all the weights )
Yu Liu MapReduce For Machine Learning
3 versions of implementations
Sequential, Sketo, and TBB
When training finished, this Neural Network can be used to
recognizing the unknown data
inputs of map function are unknown patterns and Neural
Network algorithm;
out put of map function are set of signals which denote what
the input data are.
no reduce processing is needed.
Yu Liu MapReduce For Machine Learning
Sequential implementation(STL)
Training stage
The MAP and REDUCE functions:
Yu Liu MapReduce For Machine Learning
Sequential implementation(STL)
Training stage
The function object used by MAP:
Yu Liu MapReduce For Machine Learning
Implementation using Sketo Lib
Training stage
Forward and backward propagation:basic ideas
1 Each computing node has an instance of Neural Network with
same initial weights ;
2 This Neural Network is an extended Neural Network(each
layer has a ”1” input).
3 Let each computing node calculate same amount of training
samples;
4 Running fixed steps training.
5 Sum up each node’s weights and get average.
6 Update this average weights to each NN, and calculate the
total error.
7 Repeat 4-6 until total error less than a given value
Yu Liu MapReduce For Machine Learning
Implementation using STL, Sketo, TBB
Well Trained stage
Then the system can be use to analyse the data’s patterns:
1 Mapping/splitting the input data to each computing
node/core ;
2 Reduce is not needed.
This is a very good parallel processing: input data are all
independent.
For Sketo and TBB version implementation, the parallelism of this
stage is P, if there are P processors(cores).
Yu Liu MapReduce For Machine Learning
Implementation using STL, Sketo, TBB
TBB
I use tbb::parallel for and tbb::parallel reduce to implement the
MAP and REDUCE.
1 TBB version looks a little more complex than Sketo but also
very easy to use.
2 But TBB provides a lot of useful tools. such as concurrent
container, task management ... .
Yu Liu MapReduce For Machine Learning
Implementation using STL, Sketo, TBB
The source code: on google code:
http://skyto-neurl-network.googlecode.com/svn/trunk/skyto NN
Yu Liu MapReduce For Machine Learning
Performance Test
On multi-core machine
Test the performance on 8-core workstation.
(weaker than “kraken” but I have GPU :D)
8-core Xeon E5620 8GB RAM 2.4GHz : Training stage:
1 million input patterns.
Neural network: 4 inputs, 4 hidden layers, each hidden layer
has 4 neurons, 4 outputs.
TBB version 3.0, Gcc4.4.5, ubuntu 10.04LST 64bit.
Yu Liu MapReduce For Machine Learning
Performance Test
On multi-core machine
The STL version vs Sketo version( 1 core)
Training: 6.5992 s vs 7.1128 s
Using to recognize data
1.4782 s vs 1.4762 s
Yu Liu MapReduce For Machine Learning
Performance Test
On multi-core machine
The test result of Sketo version
Yu Liu MapReduce For Machine Learning
Performance Test
On multi-core machine
The test result of Sketo version - speedup
Yu Liu MapReduce For Machine Learning
Performance Test
On multi-core machine
The comparison of Sketo version and TBB version (8 cores)
Traing:
Sketo: 1.0110 s , TBB: 1.3924 s
Using to recognize data
Sketo: 0.1925 s , TBB: –
Yu Liu MapReduce For Machine Learning
The Remained Problems
The implementation is not completed yet (boost version). Some
details are not resolved:
Some B-P algorithm problems such as the ”local minima
problem” ;
Not tested with very big data ;
The size of neural network are hard to decide (still lack
knowledge of NN);
Yu Liu MapReduce For Machine Learning
The boost Mapreduce library
The Boost.MapReduce library is a MapReduce implementation
across a plurality of CPU cores rather than machines. The library
is implemented as a set of C++ class templates, and is a
header-only library.
provide map, reduce, combine and lost of utilities;
based on Boost.FileSystem and Boost.Thread; Like Hadoop,
using files as I/O media.
Now , it is not yet part of the Boost Library and is still under
development and review.
Yu Liu MapReduce For Machine Learning

On Implementation of Neuron Network(Back-propagation)

  • 1.
    On Implementation ofNeuron Network(Back-propagation) Yu Liu National Institute of Informatics Nov 9, 2010 Yu Liu MapReduce For Machine Learning
  • 2.
    Outline 1 Motivations 2 Briefintroduction of background The Neural Network The Back-propagation Algorithm The Problems of Back-propagation 3 Implementation using C++ STL, Sketo Lib and Intel TBB and boost Mapreduce(next week) Main Flow od data processing Analysis of Parallelism Optimization 4 The Benchmark Results 5 The Remained Problems Yu Liu MapReduce For Machine Learning
  • 3.
    Motivation Do more practiceof parallel programming. Yu Liu MapReduce For Machine Learning
  • 4.
    Motivation Do more practiceof parallel programming. Using and comparing different parallel programming Libraries. Yu Liu MapReduce For Machine Learning
  • 5.
    Motivation Do more practiceof parallel programming. Using and comparing different parallel programming Libraries. Studying the principle of designing a good parallel programming Library. Yu Liu MapReduce For Machine Learning
  • 6.
    MapReduce Programming model Whatis MapReduce The Computation of MapReduce Framework Input: a set of key/value pairs Main Concepts of MapReduce Programming Paradigm Yu Liu MapReduce For Machine Learning
  • 7.
    MapReduce Programming model Whatis MapReduce The Computation of MapReduce Framework Input: a set of key/value pairs Output: a set of key/value pairs. Main Concepts of MapReduce Programming Paradigm Yu Liu MapReduce For Machine Learning
  • 8.
    MapReduce Programming model Whatis MapReduce The Computation of MapReduce Framework Input: a set of key/value pairs Output: a set of key/value pairs. The user provide two functions: Map and Reduce. Main Concepts of MapReduce Programming Paradigm Yu Liu MapReduce For Machine Learning
  • 9.
    MapReduce Programming model Whatis MapReduce The Computation of MapReduce Framework Input: a set of key/value pairs Output: a set of key/value pairs. The user provide two functions: Map and Reduce. Main Concepts of MapReduce Programming Paradigm SPLIT: Splitting the input data and iterating over it; Yu Liu MapReduce For Machine Learning
  • 10.
    MapReduce Programming model Whatis MapReduce The Computation of MapReduce Framework Input: a set of key/value pairs Output: a set of key/value pairs. The user provide two functions: Map and Reduce. Main Concepts of MapReduce Programming Paradigm SPLIT: Splitting the input data and iterating over it; MAP: Computation key/value pairs on each split; Yu Liu MapReduce For Machine Learning
  • 11.
    MapReduce Programming model Whatis MapReduce The Computation of MapReduce Framework Input: a set of key/value pairs Output: a set of key/value pairs. The user provide two functions: Map and Reduce. Main Concepts of MapReduce Programming Paradigm SPLIT: Splitting the input data and iterating over it; MAP: Computation key/value pairs on each split; SHUFFLE and SORT: Grouping intermediate values by key; Yu Liu MapReduce For Machine Learning
  • 12.
    MapReduce Programming model Whatis MapReduce The Computation of MapReduce Framework Input: a set of key/value pairs Output: a set of key/value pairs. The user provide two functions: Map and Reduce. Main Concepts of MapReduce Programming Paradigm SPLIT: Splitting the input data and iterating over it; MAP: Computation key/value pairs on each split; SHUFFLE and SORT: Grouping intermediate values by key; REDUCE: Iterating over the resulting groups and reducing each group. Yu Liu MapReduce For Machine Learning
  • 13.
    MapReduce Programming model Theexample of applying MapReduce on machine-learning The paper: Map-Reduce for Machine Learning on Multicore give us a programming framework model which using mapreduce paradigm to do parallel data processing: Yu Liu MapReduce For Machine Learning
  • 14.
    The Artificial NeuralNetwork An Artificial Neural Network (ANN) is an information processing paradigm that is inspired by the way biological nervous systems, such as the brain, process information.It is composed of a large number of highly interconnected processing elements (neurones) working in unison to solve specific problems. R.Rojas: Neural Networks. Springer-Verlag, Berlin, 1996 Yu Liu MapReduce For Machine Learning
  • 15.
    The Artificial NeuralNetwork A simple mapreduce example The neural network can be trained to recognise some patterns: Yu Liu MapReduce For Machine Learning
  • 16.
    The Back-Propagation Algorithm Trainingthe NN In order to train a neural network, must adjust the weights of each unit to make that the error between the desired output and the actual output is reduced. The back-propagation algorithm: http://galaxy.agh.edu.pl/ ∼vlsi/AI/backp t en/backprop.html Yu Liu MapReduce For Machine Learning
  • 17.
    The Back-Propagation Algorithm Back-Propagationconcepts 1 Propagates inputs forward in the usual way, i.e. All outputs are computed using sigmoid threshold of the inner product of the corresponding weight and input vectors. All outputs at stage n are connected to all the inputs at stage n+1 2 Propagates the errors backwards by apportioning them to each unit according to the amount of this error the unit is responsible for. Yu Liu MapReduce For Machine Learning
  • 18.
    The Back-Propagation Algorithm Back-Propagationprocess: Yu Liu MapReduce For Machine Learning
  • 19.
    The Back-Propagation Algorithm Back-Propagationprocess: Yu Liu MapReduce For Machine Learning
  • 20.
    3 versions ofimplementations Sequential, Sketo, and TBB A neural network(NN) c++ class was implemented and An instance of neural network can be created by given arguments of number of input, layers, number of neurons ... given an input pattern it will give a (set of) output signal(s). it has B-P method to update all neuron’s weights. it has other methods to do all kinds of operations. E.g, put weights , get weights. All the operations of the neural network are sequential. Yu Liu MapReduce For Machine Learning
  • 21.
    3 versions ofimplementations Sequential, Sketo, and TBB All three versions are implemented as same architecture. The Training stage: training data and instance of NN(BP algorithm) are inputs of a map function; out put of the map function are set of new weights. input of reduce function are out put of map function. out put of reduce function is the average of these new weights. ( here I simply average all the weights ) Yu Liu MapReduce For Machine Learning
  • 22.
    3 versions ofimplementations Sequential, Sketo, and TBB When training finished, this Neural Network can be used to recognizing the unknown data inputs of map function are unknown patterns and Neural Network algorithm; out put of map function are set of signals which denote what the input data are. no reduce processing is needed. Yu Liu MapReduce For Machine Learning
  • 23.
    Sequential implementation(STL) Training stage TheMAP and REDUCE functions: Yu Liu MapReduce For Machine Learning
  • 24.
    Sequential implementation(STL) Training stage Thefunction object used by MAP: Yu Liu MapReduce For Machine Learning
  • 25.
    Implementation using SketoLib Training stage Forward and backward propagation:basic ideas 1 Each computing node has an instance of Neural Network with same initial weights ; 2 This Neural Network is an extended Neural Network(each layer has a ”1” input). 3 Let each computing node calculate same amount of training samples; 4 Running fixed steps training. 5 Sum up each node’s weights and get average. 6 Update this average weights to each NN, and calculate the total error. 7 Repeat 4-6 until total error less than a given value Yu Liu MapReduce For Machine Learning
  • 26.
    Implementation using STL,Sketo, TBB Well Trained stage Then the system can be use to analyse the data’s patterns: 1 Mapping/splitting the input data to each computing node/core ; 2 Reduce is not needed. This is a very good parallel processing: input data are all independent. For Sketo and TBB version implementation, the parallelism of this stage is P, if there are P processors(cores). Yu Liu MapReduce For Machine Learning
  • 27.
    Implementation using STL,Sketo, TBB TBB I use tbb::parallel for and tbb::parallel reduce to implement the MAP and REDUCE. 1 TBB version looks a little more complex than Sketo but also very easy to use. 2 But TBB provides a lot of useful tools. such as concurrent container, task management ... . Yu Liu MapReduce For Machine Learning
  • 28.
    Implementation using STL,Sketo, TBB The source code: on google code: http://skyto-neurl-network.googlecode.com/svn/trunk/skyto NN Yu Liu MapReduce For Machine Learning
  • 29.
    Performance Test On multi-coremachine Test the performance on 8-core workstation. (weaker than “kraken” but I have GPU :D) 8-core Xeon E5620 8GB RAM 2.4GHz : Training stage: 1 million input patterns. Neural network: 4 inputs, 4 hidden layers, each hidden layer has 4 neurons, 4 outputs. TBB version 3.0, Gcc4.4.5, ubuntu 10.04LST 64bit. Yu Liu MapReduce For Machine Learning
  • 30.
    Performance Test On multi-coremachine The STL version vs Sketo version( 1 core) Training: 6.5992 s vs 7.1128 s Using to recognize data 1.4782 s vs 1.4762 s Yu Liu MapReduce For Machine Learning
  • 31.
    Performance Test On multi-coremachine The test result of Sketo version Yu Liu MapReduce For Machine Learning
  • 32.
    Performance Test On multi-coremachine The test result of Sketo version - speedup Yu Liu MapReduce For Machine Learning
  • 33.
    Performance Test On multi-coremachine The comparison of Sketo version and TBB version (8 cores) Traing: Sketo: 1.0110 s , TBB: 1.3924 s Using to recognize data Sketo: 0.1925 s , TBB: – Yu Liu MapReduce For Machine Learning
  • 34.
    The Remained Problems Theimplementation is not completed yet (boost version). Some details are not resolved: Some B-P algorithm problems such as the ”local minima problem” ; Not tested with very big data ; The size of neural network are hard to decide (still lack knowledge of NN); Yu Liu MapReduce For Machine Learning
  • 35.
    The boost Mapreducelibrary The Boost.MapReduce library is a MapReduce implementation across a plurality of CPU cores rather than machines. The library is implemented as a set of C++ class templates, and is a header-only library. provide map, reduce, combine and lost of utilities; based on Boost.FileSystem and Boost.Thread; Like Hadoop, using files as I/O media. Now , it is not yet part of the Boost Library and is still under development and review. Yu Liu MapReduce For Machine Learning