# 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 <francois.fleuret@idiap.ch>
+# Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+# http://www.epfl.ch
+#
+# Written by Francois Fleuret <francois@fleuret.org>
#
# This file is part of mlp-mnist.
#
/*
* 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 <francois.fleuret@idiap.ch>
+ * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ * http://www.epfl.ch
+ *
+ * Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of mlp-mnist.
*
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();
// 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
# 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 <francois.fleuret@idiap.ch>
+# Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+# http://www.epfl.ch
+#
+# Written by Francois Fleuret <francois@fleuret.org>
#
# This file is part of mlp-mnist.
#
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
/*
* 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 <francois.fleuret@idiap.ch>
+ * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ * http://www.epfl.ch
+ *
+ * Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of mlp-mnist.
*
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;
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();
+}
/*
* 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 <francois.fleuret@idiap.ch>
+ * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ * http://www.epfl.ch
+ *
+ * Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of mlp-mnist.
*
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);
};
/*
* 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 <francois.fleuret@idiap.ch>
+ * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ * http://www.epfl.ch
+ *
+ * Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of mlp-mnist.
*
/*
* 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 <francois.fleuret@idiap.ch>
+ * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ * http://www.epfl.ch
+ *
+ * Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of mlp-mnist.
*
#define ASSERT(x, s)
#endif
+const int buffer_size = 1024;
+
typedef float scalar_t;
template<class T> T sq(T x) { return x*x; }
/*
* 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 <francois.fleuret@idiap.ch>
+ * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ * http://www.epfl.ch
+ *
+ * Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of mlp-mnist.
*
/*
* 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 <francois.fleuret@idiap.ch>
+ * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ * http://www.epfl.ch
+ *
+ * Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of mlp-mnist.
*