Skip to content
Snippets Groups Projects
Commit 746d7f9a authored by Rakesh MEHTA's avatar Rakesh MEHTA
Browse files

Spell Checks

parent aa5759ef
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,12 @@ The package implements a generalized boosting framework which incorporate differ ...@@ -5,12 +5,12 @@ The package implements a generalized boosting framework which incorporate differ
boosting approaches. The Boosting algorithms implemented in this package are boosting approaches. The Boosting algorithms implemented in this package are
1) Gradient Boost (generalized version of Adaboost) for univariate cases 1) Gradient Boost (generalized version of Adaboost) for univariate cases
2) TaylorBoost for univariante and multivariate cases 2) TaylorBoost for univariate and multivariate cases
The weak classfiers associated with these boosting algorithms are The weak classifiers associated with these boosting algorithms are
1) Stump classifiers 1) Stump classifiers
2) LUT based classfiers 2) LUT based classifiers
Check the following reference for the details: Check the following reference for the details:
...@@ -34,7 +34,7 @@ two categories: ...@@ -34,7 +34,7 @@ two categories:
one-vs-one and one-vs-all. Both the boosting algorithm (Gradient Boost and Taylor boost) one-vs-one and one-vs-all. Both the boosting algorithm (Gradient Boost and Taylor boost)
can be used for testing this scenario. can be used for testing this scenario.
2) Multivariate Test: It is the multi class classification problem. All the 10 digit classfication 2) Multivariate Test: It is the multi class classification problem. All the 10 digit classification
is considered in a single test. Only Multivariate Taylor boosting can be used for testing this scenario. is considered in a single test. Only Multivariate Taylor boosting can be used for testing this scenario.
Installation: Installation:
...@@ -52,10 +52,10 @@ get you a fully operational test and development environment. ...@@ -52,10 +52,10 @@ get you a fully operational test and development environment.
User Guide User Guide
---------- ----------
This section explains how to use the package in order to: a) test the MNIST dataset for binary clssification This section explains how to use the package in order to: a) test the MNIST dataset for binary classification
b) test the dataset for multi class classification. b) test the dataset for multi class classification.
a) The following command will run a single binary test for the digits specified and display the classifcation a) The following command will run a single binary test for the digits specified and display the classification
accuracy on the console: accuracy on the console:
$ ./bin/mnist_binary_one.py $ ./bin/mnist_binary_one.py
...@@ -68,10 +68,10 @@ To run the tests for all the combination of of ten digits use the following comm ...@@ -68,10 +68,10 @@ To run the tests for all the combination of of ten digits use the following comm
$ ./bin/mnist_binary_all.py $ ./bin/mnist_binary_all.py
This command tests all the possible comniation of digits which results in 45 different binary tests. The This command tests all the possible calumniation of digits which results in 45 different binary tests. The
accuracy of individual tests and the final average accuracy of all the tests is displayed on the console. accuracy of individual tests and the final average accuracy of all the tests is displayed on the console.
b) The following command can be used for the multivarite digits test: b) The following command can be used for the multivariate digits test:
$ ./bin/mnist_multi.py $ ./bin/mnist_multi.py
......
""" The module consist of the classes to generate a strong boosting classifier and test features using that classifier. """ The module consist of the classes to generate a strong boosting classifier and test features using that classifier.
Bossting algorithms have three main dimensions: weak trainers that are boosting, optimization strategy Boosting algorithms have three main dimensions: weak trainers that are boosting, optimization strategy
for boosting and loss function that guide the optimization. For each one of these the following for boosting and loss function that guide the optimization. For each one of these the following
choices are implemented. choices are implemented.
...@@ -35,7 +35,7 @@ class Boost: ...@@ -35,7 +35,7 @@ class Boost:
""" The class to boost the features from a set of training samples. """ The class to boost the features from a set of training samples.
It iteratively adds new trainer modelsto assemble a strong classifier. It iteratively adds new trainer models to assemble a strong classifier.
In each round of iteration a weak trainer is learned In each round of iteration a weak trainer is learned
by optimization of a differentiable function. The following parameters are involved by optimization of a differentiable function. The following parameters are involved
...@@ -56,12 +56,12 @@ class Boost: ...@@ -56,12 +56,12 @@ class Boost:
The type of weak trainer to be learned. Two types of weak trainers are The type of weak trainer to be learned. Two types of weak trainers are
supported currently. supported currently.
'LutTrainer': It is used for descrete feature types.LUT are used as weak 'LutTrainer': It is used for discrete feature types.LUT are used as weak
trainers and Taylor Boost is used as optimization strategy. trainers and Taylor Boost is used as optimization strategy.
Eg: LBP features, MCT features. Ex.: LBP features, MCT features.
'StumpTrainer': Decsion Stumps are used as weak trainer and GradBoost is 'StumpTrainer': Decision Stumps are used as weak trainer and GradBoost is
used as optimization strategy.It can be used with both descrete used as optimization strategy.It can be used with both discrete
and continuous type of features and continuous type of features
num_entries: Type int, Default = 256 num_entries: Type int, Default = 256
...@@ -73,7 +73,7 @@ class Boost: ...@@ -73,7 +73,7 @@ class Boost:
lut_loss: Type string, Default = 'expectational' lut_loss: Type string, Default = 'expectational'
For LutTrainer two types of loss function are supported: expectational and variational. For LutTrainer two types of loss function are supported: expectational and variational.
Variational perform margnally better than the expectational loss as reported in Cosmin's Variational perform marginally better than the expectational loss as reported in Cosmin's
thesis, however at the expense of high computational complexity. thesis, however at the expense of high computational complexity.
This parameter can be set to 'expectational' or 'variational'. This parameter can be set to 'expectational' or 'variational'.
...@@ -90,7 +90,7 @@ class Boost: ...@@ -90,7 +90,7 @@ class Boost:
def __init__(self, trainer_type): def __init__(self, trainer_type):
""" The function to initilize the boosting parameters. """ The function to initialize the boosting parameters.
The function set the default values for the following boosting parameters: The function set the default values for the following boosting parameters:
The number of rounds for boosting: 100 The number of rounds for boosting: 100
...@@ -118,7 +118,7 @@ class Boost: ...@@ -118,7 +118,7 @@ class Boost:
""" The function to train a boosting machine. """ The function to train a boosting machine.
The function boosts the discrete features (fset) and returns a strong classifier The function boosts the discrete features (fset) and returns a strong classifier
as a combintaion of weak classifier. as a combination of weak classifier.
Inputs: Inputs:
fset: (num_sam x num_features) features extracted from the samples fset: (num_sam x num_features) features extracted from the samples
...@@ -229,10 +229,10 @@ class BoostMachine(): ...@@ -229,10 +229,10 @@ class BoostMachine():
Return: Return:
prediction_labels: The predicted clsses for the test samples prediction_labels: The predicted classes for the test samples
Type: numpy array (#number of samples) Type: numpy array (#number of samples)
""" """
# Initilization # Initialization
num_trainer = len(self.weak_trainer) num_trainer = len(self.weak_trainer)
num_samp = test_features.shape[0] num_samp = test_features.shape[0]
pred_labels = -numpy.ones([num_samp, self.num_op]) pred_labels = -numpy.ones([num_samp, self.num_op])
......
...@@ -43,7 +43,7 @@ class ExpLossFunction(): ...@@ -43,7 +43,7 @@ class ExpLossFunction():
#return loss_grad #return loss_grad
def loss_sum(self, *args): def loss_sum(self, *args):
"""The function computes the sum of the exponential loss which is used to find the optmized values of alpha (x). """The function computes the sum of the exponential loss which is used to find the optimized values of alpha (x).
The functions computes sum of loss values which is required during the linesearch step for the optimization of the alpha. The functions computes sum of loss values which is required during the linesearch step for the optimization of the alpha.
This function is given as the input for the lbfgs optimization function. This function is given as the input for the lbfgs optimization function.
...@@ -55,7 +55,7 @@ class ExpLossFunction(): ...@@ -55,7 +55,7 @@ class ExpLossFunction():
targets: The targets for the samples targets: The targets for the samples
type: numpy array (# number of samples x #number of outputs) type: numpy array (# number of samples x #number of outputs)
pred_scores: The cummulative prediction scores of the samples until the previous round of the boosting. pred_scores: The cumulative prediction scores of the samples until the previous round of the boosting.
type: numpy array (# number of samples) type: numpy array (# number of samples)
curr_scores: The prediction scores of the samples for the current round of the boosting. curr_scores: The prediction scores of the samples for the current round of the boosting.
...@@ -82,7 +82,7 @@ class ExpLossFunction(): ...@@ -82,7 +82,7 @@ class ExpLossFunction():
def loss_grad_sum(self, *args): def loss_grad_sum(self, *args):
"""The function computes the sum of the exponential loss which is used to find the optmized values of alpha (x). """The function computes the sum of the exponential loss which is used to find the optimized values of alpha (x).
The functions computes sum of loss values which is required during the linesearch step for the optimization of the alpha. The functions computes sum of loss values which is required during the linesearch step for the optimization of the alpha.
This function is given as the input for the lbfgs optimization function. This function is given as the input for the lbfgs optimization function.
...@@ -94,7 +94,7 @@ class ExpLossFunction(): ...@@ -94,7 +94,7 @@ class ExpLossFunction():
targets: The targets for the samples targets: The targets for the samples
type: numpy array (# number of samples x #number of outputs) type: numpy array (# number of samples x #number of outputs)
pred_scores: The cummulative prediction scores of the samples until the previous round of the boosting. pred_scores: The cumulative prediction scores of the samples until the previous round of the boosting.
type: numpy array (# number of samples) type: numpy array (# number of samples)
curr_scores: The prediction scores of the samples for the current round of the boosting. curr_scores: The prediction scores of the samples for the current round of the boosting.
...@@ -104,7 +104,7 @@ class ExpLossFunction(): ...@@ -104,7 +104,7 @@ class ExpLossFunction():
Return: Return:
sum_loss: The sum of the loss gradient values for the current value of the alpha sum_loss: The sum of the loss gradient values for the current value of the alpha
type: float""" type: float"""
# initilize the values # initialize the values
x = args[0] x = args[0]
targets = args[1] targets = args[1]
pred_scores = args[2] pred_scores = args[2]
...@@ -158,7 +158,7 @@ class LogLossFunction(): ...@@ -158,7 +158,7 @@ class LogLossFunction():
return - targets* e* denom return - targets* e* denom
def loss_sum(self, *args): def loss_sum(self, *args):
"""The function computes the sum of the logit loss which is used to find the optmized values of alpha (x). """The function computes the sum of the logit loss which is used to find the optimized values of alpha (x).
The functions computes sum of loss values which is required during the linesearch step for the optimization of the alpha. The functions computes sum of loss values which is required during the linesearch step for the optimization of the alpha.
This function is given as the input for the lbfgs optimization function. This function is given as the input for the lbfgs optimization function.
...@@ -170,7 +170,7 @@ class LogLossFunction(): ...@@ -170,7 +170,7 @@ class LogLossFunction():
targets: The targets for the samples targets: The targets for the samples
type: numpy array (# number of samples x #number of outputs) type: numpy array (# number of samples x #number of outputs)
pred_scores: The cummulative prediction scores of the samples until the previous round of the boosting. pred_scores: The cumulative prediction scores of the samples until the previous round of the boosting.
type: numpy array (# number of samples) type: numpy array (# number of samples)
curr_scores: The prediction scores of the samples for the current round of the boosting. curr_scores: The prediction scores of the samples for the current round of the boosting.
...@@ -192,7 +192,7 @@ class LogLossFunction(): ...@@ -192,7 +192,7 @@ class LogLossFunction():
#@abstractmethod #@abstractmethod
def loss_grad_sum(self, *args): def loss_grad_sum(self, *args):
"""The function computes the sum of the logit loss gradient which is used to find the optmized values of alpha (x). """The function computes the sum of the logit loss gradient which is used to find the optimized values of alpha (x).
The functions computes sum of loss values which is required during the linesearch step for the optimization of the alpha. The functions computes sum of loss values which is required during the linesearch step for the optimization of the alpha.
This function is given as the input for the lbfgs optimization function. This function is given as the input for the lbfgs optimization function.
...@@ -204,7 +204,7 @@ class LogLossFunction(): ...@@ -204,7 +204,7 @@ class LogLossFunction():
targets: The targets for the samples targets: The targets for the samples
type: numpy array (# number of samples x #number of outputs) type: numpy array (# number of samples x #number of outputs)
pred_scores: The cummulative prediction scores of the samples until the previous round of the boosting. pred_scores: The cumulative prediction scores of the samples until the previous round of the boosting.
type: numpy array (# number of samples) type: numpy array (# number of samples)
curr_scores: The prediction scores of the samples for the current round of the boosting. curr_scores: The prediction scores of the samples for the current round of the boosting.
......
""" The module consists of the weak trainers which are used in the boosting framework. """ The module consists of the weak trainers which are used in the boosting framework.
currently two trianer types are implmented: Stump trainer and Lut trainer. currently two trainer types are implemented: Stump trainer and Lut trainer.
The modules structure is as follows: The modules structure is as follows:
StumpTrainer class provides the methods to compute the weak strump trainer StumpTrainer class provides the methods to compute the weak stump trainer
and test the features using these trainers. and test the features using these trainers.
LutTrainer class provides the methods to compute the weak LUT trainer LutTrainer class provides the methods to compute the weak LUT trainer
...@@ -15,12 +15,12 @@ import math ...@@ -15,12 +15,12 @@ import math
class StumpTrainer(): class StumpTrainer():
""" The weak trainer class for training stumps as classifiers. The trainer is parameterized """ The weak trainer class for training stumps as classifiers. The trainer is parametrized
the threshold and the polarity. the threshold and the polarity.
""" """
def __init__(self): def __init__(self):
""" Initilize the stump classifier""" """ Initialize the stump classifier"""
self.threshold = 0 self.threshold = 0
self.polarity = 0 self.polarity = 0
self.selected_indices = 0 self.selected_indices = 0
...@@ -58,7 +58,7 @@ class StumpTrainer(): ...@@ -58,7 +58,7 @@ class StumpTrainer():
for i in range(numFea): for i in range(numFea):
polarity[i],threshold[i], gain[i] = self.compute_thresh(fea[:,i],loss_grad) polarity[i],threshold[i], gain[i] = self.compute_thresh(fea[:,i],loss_grad)
# Find the optimum id and tis corresponding trainer # Find the optimum id and its corresponding trainer
opt_id = gain.argmax() opt_id = gain.argmax()
self.threshold = threshold[opt_id] self.threshold = threshold[opt_id]
self.polarity = polarity[opt_id] self.polarity = polarity[opt_id]
...@@ -72,7 +72,7 @@ class StumpTrainer(): ...@@ -72,7 +72,7 @@ class StumpTrainer():
""" Function computes the stump classifier (threshold) for a single feature """ Function computes the stump classifier (threshold) for a single feature
Function to compute the threshold for a single feature. The threshold is computed for Function to compute the threshold for a single feature. The threshold is computed for
the given feature values using the weak learner algorithm given in the Voila Jones Robust Face classification the given feature values using the weak learner algorithm of Viola Jones.
Inputs: Inputs:
...@@ -153,14 +153,14 @@ class StumpTrainer(): ...@@ -153,14 +153,14 @@ class StumpTrainer():
class LutTrainer(): class LutTrainer():
""" The LutTrainer class contain methods to learn weak trainer using LookUp Tables. """ The LutTrainer class contain methods to learn weak trainer using LookUp Tables.
It can be used for multi-variate binary classfication """ It can be used for multi-variate binary classification """
def __init__(self, num_entries, selection_type, num_op): def __init__(self, num_entries, selection_type, num_op):
""" Function to initilize the parameters. """ Function to initialize the parameters.
Function to initilize the weak LutTrainer. Each weak Luttrainer is specified with a Function to initialize the weak LutTrainer. Each weak Luttrainer is specified with a
LookUp Table and the feature index which corresponds to the feature on which the LookUp Table and the feature index which corresponds to the feature on which the
current classifier has to applied. current classifier has to applied.
...@@ -176,7 +176,7 @@ class LutTrainer(): ...@@ -176,7 +176,7 @@ class LutTrainer():
Type: string {'indep', 'shared'} Type: string {'indep', 'shared'}
num_op: The number of outputs for the classification task. num_op: The number of outputs for the classification task.
type: Interger type: Integer
""" """
self.num_entries = num_entries self.num_entries = num_entries
...@@ -235,7 +235,7 @@ class LutTrainer(): ...@@ -235,7 +235,7 @@ class LutTrainer():
elif self.selection_type == 'shared': elif self.selection_type == 'shared':
# for 'shared' feature selection the loss function is summed over multiple dimensions and # for 'shared' feature selection the loss function is summed over multiple dimensions and
# the feature that minimized this acumulative loss is used for all the outputs # the feature that minimized this cumulative loss is used for all the outputs
accum_loss = numpy.sum(sum_loss,1) accum_loss = numpy.sum(sum_loss,1)
selected_findex = accum_loss.argmin() selected_findex = accum_loss.argmin()
......
"""The module implements provide the interface for block based local feature extraction methods. """The module implements the interfaces for block based local feature extraction methods.
The features implemented are Local Binary Pattern and its variants (tLbp, dLBP, mLBP). The features The implemented features are Local Binary Pattern and its variants (tLbp, dLBP, mLBP). The features
are extracted using blocks of different scale. Integral images are used to effeciently extract the are extracted using blocks of different scale. Integral images are used to efficiently extract the
features. """ features. """
...@@ -17,10 +17,10 @@ class lbp_feature(): ...@@ -17,10 +17,10 @@ class lbp_feature():
The number of neighbouring blocks are fixed to eight that correspond to the original LBP structure. """ The number of neighbouring blocks are fixed to eight that correspond to the original LBP structure. """
def __init__(self, ftype): def __init__(self, ftype):
"""The function to initilize the feature type. """The function to initialize the feature type.
The function initilizes the type of feature to be extracted. The type of feature can be one of the following The function initializes the type of feature to be extracted. The type of feature can be one of the following
lbp: The original LBP features that take difference of center with the eight neighbours. lbp: The original LBP features that take difference of centre with the eight neighbours.
tlbp: It take the difference of the neighbours with the adjacent neighbour and central values is ignored. tlbp: It take the difference of the neighbours with the adjacent neighbour and central values is ignored.
dlbp: The difference between the pixels is taken along four different directions. dlbp: The difference between the pixels is taken along four different directions.
mlbp: The difference of the neighbouring values is taken with the average of neighbours and the central value.""" mlbp: The difference of the neighbouring values is taken with the average of neighbours and the central value."""
...@@ -28,15 +28,15 @@ class lbp_feature(): ...@@ -28,15 +28,15 @@ class lbp_feature():
def compute_integral_image(self,img): def compute_integral_image(self,img):
"""The function cumputes an intergal image for the given image. """The function computes an integral image for the given image.
The function computes the intergral image for the effecient computation of the block based features. The function computes the integral image for the efficient computation of the block based features.
Inouts: Inputs:
self: feature object self: feature object
img: Input images img: Input images
return: return:
int_img: The intergal image of the input image.""" int_img: The integral image of the input image."""
integral_y = numpy.cumsum(img,0) integral_y = numpy.cumsum(img,0)
integral_xy = numpy.cumsum(integral_y,1) integral_xy = numpy.cumsum(integral_y,1)
...@@ -59,7 +59,7 @@ class lbp_feature(): ...@@ -59,7 +59,7 @@ class lbp_feature():
Return: Return:
feature_vector: The concatenated feature vectors for all the scales.""" feature_vector: The concatenated feature vectors for all the scales."""
# Compute the intergal image and pad zeros along row and col for block processing # Compute the integral image and pad zeros along row and col for block processing
integral_imgc = self.compute_integral_image(img) integral_imgc = self.compute_integral_image(img)
rows, cols = img.shape rows, cols = img.shape
integral_img = numpy.zeros([rows+1,cols+1]) integral_img = numpy.zeros([rows+1,cols+1])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment