- download the above files in your favorite directory then do:
> tar -zxvf torch3faced.tar.gz
> cd torch3faced
> make clean
> make depend
> make
> cd examples_vision/mlp
> make
> ./Linux_DBG_FLOAT/trainMLP
trainMLP (c) Sebastien Marcel, IDIAP 2004
This program will train a MLP for 2-class classification.
#
# usage: ./Linux_DBG_FLOAT/trainMLP [options]
#
Arguments:
-> the list files or one data file (<[-one_file] file_name>)
-> the list files or one data file (<[-one_file] file_name>)
-> number of inputs ()
Model Options:
-nhu -> number of hidden units [25]
Learning Options:
-iter -> max number of iterations [25]
-lr -> learning rate [0.01]
-e -> end accuracy [1e-05]
-lrd -> learning rate decay [0]
-kfold -> number of folds, if you want to do cross-validation [-1]
-wd -> weight decay [0]
-mse -> MSE criterion
-nll -> NLL criterion
-nll2class -> 2-class NLL criterion
Misc Options:
-P -> the number of input/output patterns to save as pgm [0]
-seed -> the random seed [-1]
-dir -> directory to save measures [.]
-save -> the model file []
-width -> width [-1]
-height -> height [-1]
> ./Linux_DBG_FLOAT/testMLP
testMLP (c) Sebastien Marcel 2004
This program will test a MLP
#
# usage: ./Linux_DBG_FLOAT/testMLP [options]
#
Arguments:
-> the model file ()
-> the list files or one data file (<[-one_file] file_name>)
-> input dimension of the data ()
Options:
-verbose -> verbose
-nbins -> number of patterns to output [100]
-o -> output basename [test]
- now you are ready to train and test an MLP, you just need data !!
> tar -zxvf datafaced.tar.gz
> ls datafaced/
face_test.bindata face_train.bindata nonface_test.bindata nonface_train.bindata xface_test.bindata
- create a directory for experiments again in your favorite dirtectory:
> mkdir expe
> cd expe
- copy the above programs (trainMLP and testMLP) in it
> cp /home/...../torch3faced/examples_vision/mlp/Linux_DBG_FLOAT/trainMLP .
> cp /home/...../torch3faced/examples_vision/mlp/Linux_DBG_FLOAT/testMLP .
- now in your favorite directory you should have:
> ls
datafaced/ torch3faced/ expe/
- let's train a MLP in the expe directory:
> ./trainMLP -one_file ../datafaced/face_train.bindata -one_file ../datafaced/nonface_train.bindata 361 -nhu 9 -mse -save face.mlp
# FileBinDataSet::FileBinDataSet() (2-class)
Class 1
+ 1 files
+ target assigned = 0.6
Class 2
+ 1 files
+ target assigned = -0.6
# FileBinDataSet: allocating inputs ...
file [0] = ../datafaced/face_train.bindata
+ n_examples = 204
+ n_inputs = 361
file [0] = ../datafaced/nonface_train.bindata
+ n_examples = 2417
+ n_inputs = 361
# IOMulti::IOMulti() n_sequences = 2621 frame_size = 361
# FileBinDataSet: allocating targets ...
# FileBinDataSet: loading inputs ...
# FileBinDataSet: setting targets ...
# FileBinDataSet: 2621 examples loaded from 1 and 1 files with 0.6 and -0.6 targets assigned respectively
# TwoClassFormat: two classes detected [-0.6 and 0.6]
# Number of parameters: 3268
# StochasticGradient: training
.........................
! Warning: StochasticGradient: you have reached the maximum number of iterations
> ls
classerr.measure face.mlp mse.measure
- the file mse.measure contains the MSE at each iteration
- the file classerr.measure contains the classification error at each iteration
- the file face.mlp contains the parameters of the MLP after training
- let's test this MLP on the train set:
> ../Linux_DBG_FLOAT/testMLP face.mlp -one_file ../datafaced/face_train.bindata 361 -o face_train
+ n_filenames = 1
filename[0] = ../datafaced/face_train.bindata
Number of inputs = 361
Number of hidden units = 9
Number of outputs = 1
# FileBinDataSet::FileBinDataSet()
+ 1 files
+ n_inputs expected = 361
+ target assigned = 0
# FileBinDataSet: allocating inputs ...
file [0] = ../datafaced/face_train.bindata
+ n_examples = 204
+ n_inputs = 361
# IOMulti::IOMulti() n_sequences = 204 frame_size = 361
# FileBinDataSet: allocating targets ...
# FileBinDataSet: loading inputs ...
# FileBinDataSet: setting targets ...
# FileBinDataSet: 204 examples loaded from 1 files with 0 targets assigned
# FileBinDataSet::info():
+ n_examples = 204
+ n_inputs = 361
+ n_targets = 1
min = -0.467268
max = 0.686449
> ../Linux_DBG_FLOAT/testMLP face.mlp -one_file ../datafaced/nonface_train.bindata 361 -o nonface_train
+ n_filenames = 1
filename[0] = ../datafaced/nonface_train.bindata
Number of inputs = 361
Number of hidden units = 9
Number of outputs = 1
# FileBinDataSet::FileBinDataSet()
+ 1 files
+ n_inputs expected = 361
+ target assigned = 0
# FileBinDataSet: allocating inputs ...
file [0] = ../datafaced/nonface_train.bindata
+ n_examples = 2417
+ n_inputs = 361
# IOMulti::IOMulti() n_sequences = 2417 frame_size = 361
# FileBinDataSet: allocating targets ...
# FileBinDataSet: loading inputs ...
# FileBinDataSet: setting targets ...
# FileBinDataSet: 2417 examples loaded from 1 files with 0 targets assigned
# FileBinDataSet::info():
+ n_examples = 2417
+ n_inputs = 361
+ n_targets = 1
min = -0.886931
max = -0.22878
> gnuplot
>> set data style lines
>> plot 'face_train.histo', 'nonface_train.histo'
- let's test this MLP on the test set:
> ../Linux_DBG_FLOAT/testMLP face.mlp -one_file ../datafaced/face_test.bindata 361 -o face_test
+ n_filenames = 1
filename[0] = ../datafaced/face_test.bindata
Number of inputs = 361
Number of hidden units = 9
Number of outputs = 1
# FileBinDataSet::FileBinDataSet()
+ 1 files
+ n_inputs expected = 361
+ target assigned = 0
# FileBinDataSet: allocating inputs ...
file [0] = ../datafaced/face_test.bindata
+ n_examples = 189
+ n_inputs = 361
# IOMulti::IOMulti() n_sequences = 189 frame_size = 361
# FileBinDataSet: allocating targets ...
# FileBinDataSet: loading inputs ...
# FileBinDataSet: setting targets ...
# FileBinDataSet: 189 examples loaded from 1 files with 0 targets assigned
# FileBinDataSet::info():
+ n_examples = 189
+ n_inputs = 361
+ n_targets = 1
min = -0.49881
max = 0.690204
> ../Linux_DBG_FLOAT/testMLP face.mlp -one_file ../datafaced/nonface_test.bindata 361 -o nonface_test
+ n_filenames = 1
filename[0] = ../datafaced/nonface_test.bindata
Number of inputs = 361
Number of hidden units = 9
Number of outputs = 1
# FileBinDataSet::FileBinDataSet()
+ 1 files
+ n_inputs expected = 361
+ target assigned = 0
# FileBinDataSet: allocating inputs ...
file [0] = ../datafaced/nonface_test.bindata
+ n_examples = 2417
+ n_inputs = 361
# IOMulti::IOMulti() n_sequences = 2417 frame_size = 361
# FileBinDataSet: allocating targets ...
# FileBinDataSet: loading inputs ...
# FileBinDataSet: setting targets ...
# FileBinDataSet: 2417 examples loaded from 1 files with 0 targets assigned
# FileBinDataSet::info():
+ n_examples = 2417
+ n_inputs = 361
+ n_targets = 1
min = -0.879974
max = 0.338487
> gnuplot
>> set data style lines
>> plot 'face_test.histo', 'nonface_test.histo'
- let's test this MLP an extra test set of faces:
> ../Linux_DBG_FLOAT/testMLP face.mlp -one_file ../datafaced/xface_test.bindata 361 -o xface_test
+ n_filenames = 1
filename[0] = ../datafaced/xface_test.bindata
Number of inputs = 361
Number of hidden units = 9
Number of outputs = 1
# FileBinDataSet::FileBinDataSet()
+ 1 files
+ n_inputs expected = 361
+ target assigned = 0
# FileBinDataSet: allocating inputs ...
file [0] = ../datafaced/xface_test.bindata
+ n_examples = 945
+ n_inputs = 361
# IOMulti::IOMulti() n_sequences = 945 frame_size = 361
# FileBinDataSet: allocating targets ...
# FileBinDataSet: loading inputs ...
# FileBinDataSet: setting targets ...
# FileBinDataSet: 945 examples loaded from 1 files with 0 targets assigned
# FileBinDataSet::info():
+ n_examples = 945
+ n_inputs = 361
+ n_targets = 1
min = -0.710837
max = 0.678885
> gnuplot
>> set data style lines
>> plot 'face_train.histo', 'nonface_train.histo', 'face_test.histo', 'nonface_test.histo', 'xface_test.histo'