From: Francois Fleuret Date: Mon, 15 Dec 2008 21:49:32 +0000 (+0100) Subject: automatic commit X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3e1c52fc152cbbbcc2c8c675f14efc0e653d6fd;p=mlp.git automatic commit --- diff --git a/Makefile b/Makefile index 48ecf1b..a13df7f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ # mlp-mnist is an implementation of a multi-layer neural network. # -# Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ -# Written by Francois Fleuret +# Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, +# http://www.epfl.ch +# +# Written by Francois Fleuret # # This file is part of mlp-mnist. # diff --git a/ann.cc b/ann.cc index c3e9e98..758b624 100644 --- a/ann.cc +++ b/ann.cc @@ -1,8 +1,10 @@ /* * mlp-mnist is an implementation of a multi-layer neural network. * - * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret + * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, + * http://www.epfl.ch + * + * Written by Francois Fleuret * * This file is part of mlp-mnist. * @@ -266,10 +268,10 @@ int main(int argc, char **argv) { ImageSet training_set, validation_set, test_set; if(nb_training_examples > 0) - training_set.extract_unused_pictures(image_set, nb_training_examples); + training_set.sample_among_unused_pictures(image_set, nb_training_examples); if(nb_validation_examples > 0) - validation_set.extract_unused_pictures(image_set, nb_validation_examples); + validation_set.sample_among_unused_pictures(image_set, nb_validation_examples); if(save_data && mlp) mlp->save_data(); @@ -304,7 +306,7 @@ int main(int argc, char **argv) { // Testing the perceptron //////////////////////////////////////////// if(nb_test_examples > 0) { - test_set.extract_unused_pictures(image_set, nb_test_examples); + test_set.sample_among_unused_pictures(image_set, nb_test_examples); cout << "Error rate " << mlp->error(&test_set) << " (" << mlp->classification_error(&test_set)*100 << "%)\n"; // This is to test the analytical gradient diff --git a/doit.sh b/doit.sh index bd6f195..4b4d324 100755 --- a/doit.sh +++ b/doit.sh @@ -2,8 +2,10 @@ # mlp-mnist is an implementation of a multi-layer neural network. # -# Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ -# Written by Francois Fleuret +# Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, +# http://www.epfl.ch +# +# Written by Francois Fleuret # # This file is part of mlp-mnist. # @@ -21,14 +23,22 @@ make -k ann -if [[ $1 == "--download-mnist" ]]; then - for f in train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubyte; do - if [[ ! -f "./$f" ]]; then - echo "Could not find $f, downloading it." - wget http://yann.lecun.com/exdb/mnist/$f.gz - gunzip $f.gz - fi - done +if [[ $1 ]]; then + + if [[ $1 == "--download-mnist" ]]; then + for f in train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubyte; do + if [[ ! -f "./$f" ]]; then + echo "Could not find $f, downloading it." + wget http://yann.lecun.com/exdb/mnist/$f.gz + gunzip $f.gz + fi + done + else + + echo "Unknown option $1" + exit 1 + + fi fi for f in train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubyte; do diff --git a/images.cc b/images.cc index e1b07b4..fac406b 100644 --- a/images.cc +++ b/images.cc @@ -1,8 +1,10 @@ /* * mlp-mnist is an implementation of a multi-layer neural network. * - * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret + * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, + * http://www.epfl.ch + * + * Written by Francois Fleuret * * This file is part of mlp-mnist. * @@ -68,29 +70,6 @@ int ImageSet::pick_unused_picture() { return m; } -void ImageSet::extract_unused_pictures(ImageSet &is, int nb) { - if(nb > is.nb_unused_pictures()) { - cerr << "Trying to extract " << nb << " pictures from a set of " << is.nb_unused_pictures() << "\n"; - exit(1); - } - - _nb_pics = nb; - _width = is._width; - _height = is._height; - _nb_obj = is._nb_obj; - _pixel_maps = is._pixel_maps->add_ref(); - _pixels = new unsigned char *[_nb_pics]; - _labels = new unsigned char[_nb_pics]; - _used_picture = new bool[_nb_pics]; - for(int n = 0; n < _nb_pics; n++) { - int m = is.pick_unused_picture(); - _pixels[n] = is._pixels[m]; - _labels[n] = is._labels[m]; - } - - reset_used_pictures(); -} - void ImageSet::load_mnist_format(char *picture_file_name, char *label_file_name) { unsigned int magic; @@ -151,3 +130,26 @@ void ImageSet::load_mnist_format(char *picture_file_name, char *label_file_name) reset_used_pictures(); } + +void ImageSet::sample_among_unused_pictures(ImageSet &is, int nb) { + if(nb > is.nb_unused_pictures()) { + cerr << "Trying to extract " << nb << " pictures from a set of " << is.nb_unused_pictures() << "\n"; + exit(1); + } + + _nb_pics = nb; + _width = is._width; + _height = is._height; + _nb_obj = is._nb_obj; + _pixel_maps = is._pixel_maps->add_ref(); + _pixels = new unsigned char *[_nb_pics]; + _labels = new unsigned char[_nb_pics]; + _used_picture = new bool[_nb_pics]; + for(int n = 0; n < _nb_pics; n++) { + int m = is.pick_unused_picture(); + _pixels[n] = is._pixels[m]; + _labels[n] = is._labels[m]; + } + + reset_used_pictures(); +} diff --git a/images.h b/images.h index 71e0440..6ba7ef7 100644 --- a/images.h +++ b/images.h @@ -1,8 +1,10 @@ /* * mlp-mnist is an implementation of a multi-layer neural network. * - * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret + * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, + * http://www.epfl.ch + * + * Written by Francois Fleuret * * This file is part of mlp-mnist. * @@ -68,7 +70,7 @@ public: void load_mnist_format(char *picture_file_name, char *label_file_name); - void extract_unused_pictures(ImageSet &is, int nb); + void sample_among_unused_pictures(ImageSet &is, int nb); }; diff --git a/misc.cc b/misc.cc index 2f6fa3d..a623ad6 100644 --- a/misc.cc +++ b/misc.cc @@ -1,8 +1,10 @@ /* * mlp-mnist is an implementation of a multi-layer neural network. * - * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret + * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, + * http://www.epfl.ch + * + * Written by Francois Fleuret * * This file is part of mlp-mnist. * diff --git a/misc.h b/misc.h index 3a8b43d..4470d45 100644 --- a/misc.h +++ b/misc.h @@ -1,8 +1,10 @@ /* * mlp-mnist is an implementation of a multi-layer neural network. * - * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret + * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, + * http://www.epfl.ch + * + * Written by Francois Fleuret * * This file is part of mlp-mnist. * @@ -29,6 +31,8 @@ #define ASSERT(x, s) #endif +const int buffer_size = 1024; + typedef float scalar_t; template T sq(T x) { return x*x; } diff --git a/neural.cc b/neural.cc index 275ad7e..8fd4b5a 100644 --- a/neural.cc +++ b/neural.cc @@ -1,8 +1,10 @@ /* * mlp-mnist is an implementation of a multi-layer neural network. * - * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret + * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, + * http://www.epfl.ch + * + * Written by Francois Fleuret * * This file is part of mlp-mnist. * diff --git a/neural.h b/neural.h index 6843212..a6f63a9 100644 --- a/neural.h +++ b/neural.h @@ -1,8 +1,10 @@ /* * mlp-mnist is an implementation of a multi-layer neural network. * - * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret + * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, + * http://www.epfl.ch + * + * Written by Francois Fleuret * * This file is part of mlp-mnist. *